// /AIWK_COMMON/loader/aiwk_loader.js
// AIWK EXT4 v041
(function () {
    "use strict";

    const AIWK = window.AIWK;

    AIWK.loader = {
        init: async function () {
            await AIWK.cssLoader.load(AIWK.paths.tailwindCss, "aiwk-ext4-tailwind-css");
            await AIWK.cssLoader.load(AIWK.paths.baseCss, "aiwk-ext4-base-css");
            await AIWK.cssLoader.load(AIWK.paths.skinDarkCss, "aiwk-ext4-skin-dark-css");

            const ko = await AIWK.jsonLoader.load(AIWK.paths.i18nKo);
            const en = await AIWK.jsonLoader.load(AIWK.paths.i18nEn);
            const template = await AIWK.jsonLoader.load(AIWK.paths.templateDev);
            const skin = await AIWK.jsonLoader.load(AIWK.paths.skinDarkJson);

            AIWK.state.set("i18n", { ko: ko, en: en });
            AIWK.i18n.setLang("ko", ko);
            AIWK.state.set("template.win-dev", template);
            AIWK.state.set("skin.dark", skin);
            AIWK.state.set("skin.current", "dark");

            if (AIWK.domainLoader && typeof AIWK.domainLoader.scanCurrentAndStore === "function") {
                AIWK.domainLoader.scanCurrentAndStore().catch(function (err) {
                    console.warn("AIWK domain scan skipped", err && err.message ? err.message : err);
                });
            }

            return {
                ko: ko,
                en: en,
                template: template,
                skin: skin
            };
        }
    };
}());
