{"release_id":"01a1998d-9802-0000-b0f7-33a23307f4ed","chunk_id":"01a1998d-98f6-73a1-a2db-0238cf5a1adf","file":"Bgy8lUj4.mjs","mappings":"gWAcO,MAAMA,EAAiBC,EAA0C,IAAI,EAG/DC,EAAYD,EAAS,EAAK,EAGhC,SAASE,GAAwB,CAEvC,OACC,OAAO,WAAW,4BAA4B,EAAE,SAE/C,UAAmD,aAAe,EAErE,CAIO,SAASC,GAAiB,CAEhC,MAAMC,EAAK,UAAU,UACrB,MACC,oBAAoB,KAAKA,CAAE,GAAM,YAAY,KAAKA,CAAE,GAAK,UAAU,eAAiB,CAEtF,CAEO,SAASC,GAAqB,CAEpC,MAAO,WAAW,KAAK,UAAU,SAAS,CAC3C,CAIO,SAASC,GAA0B,CAEzC,MAAO,8DAA8D,KAAK,UAAU,SAAS,CAC9F,CAEA,IAAIC,EAAc,GAIX,SAASC,GAAgB,CACfD,IAChBA,EAAc,GAEVL,EAAA,GAAgBD,EAAU,IAAI,EAAI,EAEtC,OAAO,iBAAiB,sBAAwBQ,GAAM,CAErDA,EAAE,eAAA,EACFV,EAAe,IAAIU,CAA6B,CACjD,CAAC,EAED,OAAO,iBAAiB,eAAgB,IAAM,CAC7CV,EAAe,IAAI,IAAI,EACvBE,EAAU,IAAI,EAAI,CACnB,CAAC,EACF,CAIA,eAAsBS,GAAmE,CACxF,MAAMC,EAAMC,EAAIb,CAAc,EAC9B,GAAI,CAACY,EAAK,MAAO,cACjB,MAAMA,EAAI,OAAA,EACV,KAAM,CAAE,QAAAE,CAAA,EAAY,MAAMF,EAAI,WAE9B,OAAAZ,EAAe,IAAI,IAAI,EAChBc,CACR","names":["deferredPrompt","writable","installed","isStandalone","isIOS","ua","isAndroid","isInAppBrowser","initialized","initPwa","e","promptInstall","evt","get","outcome"],"sources":["../../../../../../src/lib/stores/pwa.ts"],"sourcesContent":["import { writable } from 'svelte/store';\nimport { get } from 'svelte/store';\nimport { browser } from '$app/environment';\n\n/** Chromium-only event fired when the browser deems the app installable. Not in\n *  the TS DOM lib yet, so we model the two members we use. */\nexport type BeforeInstallPromptEvent = Event & {\n\tprompt: () => Promise<void>;\n\tuserChoice: Promise<{ outcome: 'accepted' | 'dismissed'; platform: string }>;\n};\n\n/** The deferred install event, captured globally so any surface (the /install\n *  page, the nudge) can fire the native prompt. Null until the browser offers it\n *  — and only Chromium browsers ever do. */\nexport const deferredPrompt = writable<BeforeInstallPromptEvent | null>(null);\n\n/** True once the app is running as an installed PWA (or just got installed). */\nexport const installed = writable(false);\n\n/** Running inside an installed PWA (standalone window / iOS home-screen app). */\nexport function isStandalone(): boolean {\n\tif (!browser) return false;\n\treturn (\n\t\twindow.matchMedia('(display-mode: standalone)').matches ||\n\t\t// iOS Safari exposes this non-standard flag instead of display-mode.\n\t\t(navigator as Navigator & { standalone?: boolean }).standalone === true\n\t);\n}\n\n/** iOS / iPadOS — the platform with no install prompt (manual Share → Add to\n *  Home Screen only). iPadOS 13+ masquerades as Mac, so sniff touch too. */\nexport function isIOS(): boolean {\n\tif (!browser) return false;\n\tconst ua = navigator.userAgent;\n\treturn (\n\t\t/iphone|ipad|ipod/i.test(ua) || (/Macintosh/.test(ua) && navigator.maxTouchPoints > 1)\n\t);\n}\n\nexport function isAndroid(): boolean {\n\tif (!browser) return false;\n\treturn /android/i.test(navigator.userAgent);\n}\n\n/** Inside an in-app webview (Instagram/TikTok/Facebook/etc.) — installing from\n *  here doesn't work; the user must open in the real browser first. */\nexport function isInAppBrowser(): boolean {\n\tif (!browser) return false;\n\treturn /FBAN|FBAV|Instagram|Line|Twitter|TikTok|Snapchat|Pinterest/i.test(navigator.userAgent);\n}\n\nlet initialized = false;\n\n/** Attach the global install listeners exactly once (called from the root\n *  layout's onMount). */\nexport function initPwa(): void {\n\tif (!browser || initialized) return;\n\tinitialized = true;\n\n\tif (isStandalone()) installed.set(true);\n\n\twindow.addEventListener('beforeinstallprompt', (e) => {\n\t\t// Stop Chrome's mini-infobar so we own when/where the prompt shows.\n\t\te.preventDefault();\n\t\tdeferredPrompt.set(e as BeforeInstallPromptEvent);\n\t});\n\n\twindow.addEventListener('appinstalled', () => {\n\t\tdeferredPrompt.set(null);\n\t\tinstalled.set(true);\n\t});\n}\n\n/** Fire the native install prompt (Chromium). Returns 'unavailable' when there's\n *  no deferred event (iOS, already installed, or not yet offered). */\nexport async function promptInstall(): Promise<'accepted' | 'dismissed' | 'unavailable'> {\n\tconst evt = get(deferredPrompt);\n\tif (!evt) return 'unavailable';\n\tawait evt.prompt();\n\tconst { outcome } = await evt.userChoice;\n\t// The event can only be used once.\n\tdeferredPrompt.set(null);\n\treturn outcome;\n}\n"],"version":3}