{"version":3,"file":"pwa-env.cjs","names":[],"sources":["../../src/hooks/pwa-env.ts"],"sourcesContent":["/**\n * The Chromium-only `beforeinstallprompt` event. iOS Safari never fires it —\n * for those users the app falls back to manual \"Add to Home Screen\"\n * instructions. Ported into the SDK so consumers get the type without a global\n * augmentation.\n */\nexport interface BeforeInstallPromptEvent extends Event {\n    /** Platforms the prompt can target (e.g. `[\"web\", \"android\"]`). */\n    readonly platforms: readonly string[];\n    /** Resolves once the user accepts or dismisses the prompt. */\n    readonly userChoice: Promise<{\n        outcome: \"accepted\" | \"dismissed\";\n        platform: string;\n    }>;\n    /** Shows the native install prompt. */\n    prompt: () => Promise<void>;\n}\n\n/**\n * Detects iOS / iPadOS Safari, including modern iPads that report `MacIntel`\n * plus multi-touch instead of an `iPad` user agent.\n *\n * @returns `true` when running on iOS/iPadOS.\n */\nexport function isIOS(): boolean {\n    if (typeof navigator === \"undefined\") return false;\n    const ua = navigator.userAgent;\n    if (/iPad|iPhone|iPod/.test(ua)) return true;\n    return ua.includes(\"Mac\") && navigator.maxTouchPoints > 1;\n}\n\n/**\n * Detects Android browsers that ship a Chromium fork with the\n * `beforeinstallprompt` event stripped or unreliable. Those users must install\n * via the browser menu manually, identical to iOS Safari.\n *\n * @returns `true` when running on such an Android browser.\n */\nexport function isAndroidWithoutPromptApi(): boolean {\n    if (typeof navigator === \"undefined\") return false;\n    const ua = navigator.userAgent;\n    if (!/Android/i.test(ua)) return false;\n    return /MiuiBrowser|XiaoMi|UCBrowser|Opera Mini|KAIOS|HuaweiBrowser/i.test(ua);\n}\n\n/**\n * Detects any Android browser.\n *\n * @returns `true` when the user agent reports Android.\n */\nexport function isAndroid(): boolean {\n    if (typeof navigator === \"undefined\") return false;\n    return /Android/i.test(navigator.userAgent);\n}\n\n/**\n * Builds an `intent://` URL that re-opens the current page inside Chrome on\n * Android. When Chrome is missing, the fallback URL points to the Play Store so\n * the user can still recover. Returns `null` outside Android.\n *\n * @returns The `intent://` URL, or `null` when not on Android or without a DOM.\n * @see https://developer.chrome.com/docs/multidevice/android/intents\n */\nexport function buildOpenInChromeIntent(): string | null {\n    if (typeof window === \"undefined\") return null;\n    if (!isAndroid()) return null;\n    const host = window.location.host;\n    const path = window.location.pathname + window.location.search;\n    const fallback = encodeURIComponent(\n        \"https://play.google.com/store/apps/details?id=com.android.chrome\",\n    );\n    return `intent://${host}${path}#Intent;scheme=https;package=com.android.chrome;S.browser_fallback_url=${fallback};end`;\n}\n\n/**\n * Reports whether the app is running as an installed PWA (Android Chrome, iOS,\n * or desktop). Use it to suppress install CTAs once the user is already in the\n * standalone shell.\n *\n * @returns `true` when the display mode is standalone or iOS reports standalone.\n */\nexport function isStandalone(): boolean {\n    if (typeof window === \"undefined\") return false;\n    if (window.matchMedia?.(\"(display-mode: standalone)\")?.matches) return true;\n    return (window.navigator as Navigator & { standalone?: boolean }).standalone === true;\n}\n"],"mappings":"AAwBA,SAAgB,GAAiB,CAC7B,GAAI,OAAO,UAAc,IAAa,MAAO,GAC7C,IAAM,EAAK,UAAU,UAErB,MADI,mBAAmB,KAAK,CAAE,EAAU,GACjC,EAAG,SAAS,KAAK,GAAK,UAAU,eAAiB,CAC5D,CASA,SAAgB,GAAqC,CACjD,GAAI,OAAO,UAAc,IAAa,MAAO,GAC7C,IAAM,EAAK,UAAU,UAErB,MADK,WAAW,KAAK,CAAE,EAChB,+DAA+D,KAAK,CAAE,EAD5C,EAErC,CAOA,SAAgB,GAAqB,CAEjC,OADI,OAAO,UAAc,IAAoB,GACtC,WAAW,KAAK,UAAU,SAAS,CAC9C,CAUA,SAAgB,GAAyC,CAQrD,OAPI,OAAO,OAAW,KAClB,CAAC,EAAU,EAAU,KAMlB,YALM,OAAO,SAAS,OAChB,OAAO,SAAS,SAAW,OAAO,SAAS,OAIzB,4JACnC,CASA,SAAgB,GAAwB,CAGpC,OAFI,OAAO,OAAW,IAAoB,GACtC,OAAO,aAAa,4BAA4B,CAAC,EAAE,QAAgB,GAC/D,OAAO,UAAmD,aAAe,EACrF"}