import type { PageLoad } from './$types';

// Data loading for IDAA Recovery Meetings [event_id] has been moved to the $effect in +page.svelte
// (gated on novi_verified / trusted_access). +page.ts runs before layout effects and
// fires during SvelteKit link prefetch, making it unsafe for private IDAA content.

export const load = (async ({ params, parent }) => {
    const log_lvl: number = 0;

    const data = await parent();
    data.log_lvl = log_lvl;

    const account_id = data.account_id;
    let ae_acct = data[account_id];

    if (!ae_acct) {
        console.warn(
            `ae IDAA Recovery Meeting [event_id] +page.ts: Account ${account_id} not found in data. Initializing ghost acct.`
        );
        ae_acct = {
            api: data.ae_api || {},
            slct: { account_id: account_id }
        };
    }

    ae_acct.slct.event_id = params.event_id;

    data[account_id] = ae_acct;
    return data;
}) satisfies PageLoad;
