<script lang="ts">
/**
 * events/[event_id]/(launcher)/+layout.svelte
 * Root layout for the launcher area.
 * Ensures background sync runs globally regardless of active tab.
 */
import { ae_loc } from '$lib/stores/ae_stores';
import { launcher_loc } from '$lib/stores/ae_events_stores__launcher.svelte';
import Launcher_Background_Sync from './launcher_background_sync.svelte';

interface Props {
    children?: import('svelte').Snippet;
}

let { children }: Props = $props();

// WHY: When running inside Electron (is_native), app_mode must be 'native' for
// the file launch path to work correctly. On a fresh install the persisted store
// has no value set, so we auto-initialize it here. This preserves the three-mode
// design (default / onsite / native) — browser sessions are unaffected because
// is_native is only ever true inside the Electron shell.
$effect(() => {
    if ($ae_loc.is_native && launcher_loc.current.app_mode !== 'native') {
        launcher_loc.current.app_mode = 'native';
    }
});
</script>

<!-- Background Sync Process (Invisible) -->
<Launcher_Background_Sync log_lvl={1} />

<!-- Render the rest of the launcher UI -->
{@render children?.()}
