// Tauri doesn't have a Node.js server to do proper SSR
// so we use adapter-static with a fallback to index.html to put the site in SPA mode
// See: https://svelte.dev/docs/kit/single-page-apps
// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: vitePreprocess(),
  // Suppress specific build-time warnings that are intentional patterns:
  // - a11y_click_events_have_key_events: all overlay/context-menu divs use svelte:window handlers
  // - state_referenced_locally: InputDialog intentionally captures the initial prop value
  onwarn: (warning, handler) => {
    if (
      warning.code === "a11y_click_events_have_key_events" ||
      warning.code === "state_referenced_locally" ||
      // SvelteSet is already reactive; $state wrapping is unnecessary per ESLint,
      // but vite-plugin-svelte incorrectly fires non_reactive_update on SvelteSet mutations
      warning.code === "non_reactive_update"
    )
      return;
    handler(warning);
  },
  kit: {
    adapter: adapter({
      fallback: "index.html",
    }),
  },
};

export default config;
