import type { CapacitorConfig } from "@capacitor/cli";

// Android/iOS shell around the same static export as the website.
// webDir must never be ./out: that is the live website build.
const config: CapacitorConfig = {
    // Permanent after the first store upload; also set in android/app/build.gradle.
    appId: "ir.rangook.app",
    appName: "رنگوک",
    webDir: "build/native/www",
    backgroundColor: "#F5EFE4",

    server: {
        // Changing the scheme wipes the app's stored data, and the IranHLS player only plays on https.
        androidScheme: "https",
        // Shown on a too-old WebView or a failed page load (source: scripts/native/error.html).
        errorPath: "native-error.html",
    },

    android: {
        // Flavor for `npx cap run android`; release builds choose their own.
        flavor: "direct",
        // The bundle needs Chrome 71+. native-build.js also writes this into the error page
        // and into a guard that covers WebViews Capacitor cannot check (Huawei's).
        minWebViewVersion: 71,
    },

    plugins: {
        SplashScreen: {
            // The app hides it once it has painted; auto-hide is the fallback.
            launchAutoHide: true,
            launchShowDuration: 4000,
            launchFadeOutDuration: 200,
            backgroundColor: "#F5EFE4",
            showSpinner: false,
        },

        SystemBars: {
            // No dark theme: keep dark icons on the paper status bar.
            style: "LIGHT",
            insetsHandling: "css",
        },

        // Keep off: they patch fetch/XHR and document.cookie globally.
        CapacitorHttp: { enabled: false },
        CapacitorCookies: { enabled: false },
    },
};

export default config;
