import { Plugin, PluginOption, UserConfig, ConfigEnv, UserConfigFnObject, UserConfigFnPromise, UserConfigFn } from 'vite';

/**
 * Forwards `/__l5e/assets-v1/*` requests from the Vite dev server to the
 * Lovable preview proxy so assets resolve when the page is loaded directly
 * from the sandbox dev server (e.g. `localhost:8080`) instead of via
 * `*.lovable.app` / `*.lovableproject.com`.
 *
 * No-op unless `LOVABLE_PREVIEW_HOST` is set (host only, no scheme), e.g.
 * `id-preview--<project-id>.lovable.app`.
 */
declare function lovableAssetsProxyPlugin(): Plugin;

interface LovableViteTanstackOptions {
    plugins?: PluginOption[];
    vite?: UserConfig;
    serverFnErrorLogger?: boolean;
    ssrErrorLogger?: boolean;
    /**
     * Options forwarded to `nitro()` from `nitro/vite`.
     *
     * Behavior:
     * - **undefined** (default): nitro runs on every production build, defaulting
     *   to the `cloudflare-module` preset via Nitro's `defaultPreset` — zero-config
     *   target auto-detection (`NITRO_PRESET`, Vercel/Netlify/Cloudflare Pages)
     *   still wins, so a self-deploy auto-targets its own platform. If the optional
     *   `nitro` peer dep isn't installed, it's skipped (no deploy intent to honor).
     * - **`true`**: same as undefined, but fails fast if the `nitro` peer dep is
     *   missing — the explicit opt-in signals deploy intent.
     * - **object**: force-on, with these overrides. Set `preset`
     *   (e.g. `{ preset: "vercel" }`) to hard-pin a target from your own CI.
     * - **`false`**: skip nitro entirely.
     *
     * Inside a Lovable build the preset and output layout are forced to
     * Cloudflare; `preset`/`output`/`cloudflare` overrides apply only outside it.
     *
     * The option surface is narrow on purpose — Nitro v3 is still pre-RC, so
     * we only expose stable build-time knobs to reduce churn if
     * `NitroPluginConfig` schema changes. File an issue if you need more.
     */
    nitro?: true | {
        preset?: string;
        output?: {
            dir?: string;
            publicDir?: string;
            serverDir?: string;
        };
        cloudflare?: {
            nodeCompat?: boolean;
            deployConfig?: boolean;
        };
    } | false;
    /** Options forwarded to tanstackStart(). */
    tanstackStart?: Record<string, unknown>;
    /** Options forwarded to viteReact(). */
    react?: Record<string, unknown>;
    /** Set to false to disable automatic VITE_* env define injection. Default: true. */
    envDefine?: boolean;
    /**
     * Options for the HMR gate plugin (@lovable.dev/vite-plugin-hmr-gate).
     * Enabled by default in sandbox mode. Set to false to disable, or pass options
     * to customise behaviour. Set to true or an options object to enable outside sandbox.
     */
    hmrGate?: boolean | Record<string, unknown>;
}
declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
declare function defineConfig(config: UserConfigFnObject): (env: ConfigEnv) => Promise<UserConfig>;
declare function defineConfig(config: UserConfigFnPromise): (env: ConfigEnv) => Promise<UserConfig>;
declare function defineConfig(config: UserConfigFn): (env: ConfigEnv) => Promise<UserConfig>;
declare function defineConfig(options?: LovableViteTanstackOptions): (env: ConfigEnv) => Promise<UserConfig>;

export { type LovableViteTanstackOptions, defineConfig, lovableAssetsProxyPlugin };
