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

// Data loading for IDAA BB has been moved to +page.svelte $effect (gated on novi_verified).
// +page.ts runs before layout effects and fires during SvelteKit link prefetch,
// making it unsafe for private IDAA content — see BOOTSTRAP__AI_Agent_Quickstart.md.

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

    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 Bulletin Board +page.ts: Account ${account_id} not found in parent data. Initializing ghost acct.`
        );
        ae_acct = {
            api: data.ae_api || {},
            slct: { account_id: account_id }
        };
    }

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