// import adapter from '@sveltejs/adapter-auto';
import adapter_node from '@sveltejs/adapter-node';
// import adapter_static from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
    extensions: ['.svelte'],
    // Consult https://kit.svelte.dev/docs/integrations#preprocessors
    // for more information about preprocessors
    preprocess: [vitePreprocess()],

    // Suppress known false-positive / intentional-pattern warnings
    onwarn: (warning, handler) => {
        // <label> is used as a visual section-group header in many internal forms
        // (launcher cfg, admin forms). These are not real form labels — they're
        // styled dividers/headings. Suppressed globally; real form a11y is tested
        // manually.
        if (warning.code === 'a11y_label_has_associated_control') return;

        // autofocus is intentional in a few modal inputs for UX.
        if (warning.code === 'a11y_autofocus') return;

        // TipTap renders its content dynamically via JS. The :global(.tiptap) *
        // selectors in AE_Comp_Editor_TipTap.svelte are real and actively used —
        // svelte-check just can't see the rendered DOM at compile time.
        if (
            warning.code === 'css_unused_selector' &&
            warning.filename?.includes('TipTap')
        )
            return;

        handler(warning);
    },

    vitePlugin: {
        inspector: true
    },
    kit: {
        serviceWorker: {
            register: true
        },
        adapter: adapter_node()

        // adapter: adapter_static({
        // 	// default options are shown. On some platforms
        // 	// these options are set automatically — see below
        // 	pages: 'build',
        // 	assets: 'build',
        // 	fallback: '200.html', // undefined,
        // 	precompress: false,
        // 	strict: true
        // })

        // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
        // If your environment is not supported or you settled on a specific environment, switch out the adapter.
        // See https://kit.svelte.dev/docs/adapters for more information about adapters.
        // adapter: adapter()

        // target: "#svelte",
        // vite: {
        // 	optimizeDeps: {
        // 		include: ["highlight.js/lib/core"],
        // 	},
        // },
    },

    onwarn: (warning, defaultHandler) => {
        // Suppress the 'state_referenced_locally', 'non_reactive_update', and 'css_unused_selector' warnings
        if (warning.code === 'state_referenced_locally' || warning.code === 'non_reactive_update' || warning.code === 'css_unused_selector') {
            return;
        }

        // Handle other warnings with the default handler
        defaultHandler(warning);
    }
};
export default config;
