/** @type {import('./$types').LayoutLoad} */
console.log(`IDAA BB - [account_id] +layout.ts start`);

// import { error } from '@sveltejs/kit';
import { browser } from '$app/environment';
// import { page } from '$app/state';
import { posts_func } from '$lib/ae_posts/ae_posts_functions';

export async function load({ params, parent }) {
    // route
    // let log_lvl: number = 0;
    // let data = await parent();
    // data.log_lvl = log_lvl;
    // let account_id = data.account_id;
    // let ae_acct = data[account_id];
    // // let post_id = params.post_id;
    // // let post_id = page.url.searchParams.has('post_id') ?? null;
    // // let post_id = page.url.searchParams.get('post_id') ?? null;
    // // if (!post_id) {
    // //     console.log(`ae Posts - [post_id] +page.ts: The post_id was not found in the params.post_id!!!`);
    // //     // error(404, {
    // // 	// 	message: 'Post ID not found'
    // // 	// });
    // // } else {
    // //     console.log(`ae Posts - [post_id] +page.ts: post_id = `, post_id);
    // //     ae_acct.slct.post_id = post_id;
    // // }
    // // ae_acct.slct.post_id = post_id;
    // if (browser) {
    //     let load_post_obj_li = posts_func.load_ae_obj_li__post({
    //         api_cfg: ae_acct.api,
    //         for_obj_type: 'account',
    //         for_obj_id: account_id,
    //         inc_comment_li: true,
    //         enabled: 'enabled',
    //         hidden: 'not_hidden',
    //         limit: 29,
    //         order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
    //         try_cache: true,
    //         log_lvl: log_lvl
    //     });
    //     if (log_lvl) {
    //         console.log(`load_post_obj_li = `, load_post_obj_li);
    //     }
    //     ae_acct.slct.post_obj_li = load_post_obj_li;
    // }
    // // WARNING: Precaution against shared data between sites and sessions.
    // data[account_id] = ae_acct;
    // return data;
}
