{"release_id":"01a21177-ea43-0000-5cf2-858dc27dec6b","chunk_id":"01a21177-ea53-7160-b21a-a0134e0d46a5","file":"B1n7Ts-K.mjs","mappings":"8bAYO,MAAMA,EAAwB,wBAGxBC,EAAsB,kBAEtBC,EAAkB,iBAGlBC,EAAsB,kBAqBtBC,EAAUC,EAAuB,CAAE,KAAM,GAAO,QAAS,OAAQ,KAAM,MAAA,CAAQ,EAErF,SAASC,EAAYC,EAInB,CACR,MAAMC,EAAOD,EAAK,MAAQ,OAK1B,GAAI,CAACE,EAAK,KAAK,KAAM,CACpBC,EAAWR,EAAiB,CAAE,QAASK,EAAK,QAAS,KAAAC,EAAM,EAC3DG,EAAcF,EAAK,IAAI,SAAWA,EAAK,IAAI,OAAQ,gBAAgB,EACnEG,EAAa,SAAU,CAAE,QAASL,EAAK,QAAS,KAAAC,EAAM,EACtD,MACD,CACAJ,EAAQ,IAAI,CAAE,KAAM,GAAM,QAASG,EAAK,QAAS,KAAAC,EAAM,OAAQD,EAAK,MAAA,CAAQ,EAC5EK,EAAa,QAAS,CAAE,QAASL,EAAK,QAAS,KAAAC,EAAM,CACtD,CAIO,SAASK,EAAeN,EAA4D,CAC1FH,EAAQ,IAAI,CAAE,KAAM,GAAM,QAASG,EAAK,QAAS,KAAMA,EAAK,KAAM,SAAU,EAAA,CAAM,CACnF,CAEO,SAASO,GAAqB,CACpCV,EAAQ,OAAQW,IAAO,CAAE,GAAGA,EAAG,KAAM,GAAO,OAAQ,OAAW,SAAU,EAAA,EAAQ,CAClF,CAKO,SAASC,EACfC,EACAV,EACU,CACV,MAAI,CAACU,GAAM,SAAWA,EAAK,YAAoB,IAC/CX,EAAYC,CAAI,EACT,GACR","names":["AGE_GATE_DONE_MESSAGE","AGE_GATE_RETURN_KEY","RESUME_AGE_GATE","AGE_GATE_RESULT_KEY","ageGate","writable","openAgeGate","opts","mode","page","saveResume","openAuthSheet","trackAgeGate","resumeAgeCheck","closeAgeGate","s","requireAge","data"],"sources":["../../../../../../src/lib/stores/ageGate.ts"],"sourcesContent":["import { writable } from 'svelte/store';\nimport { page } from '$app/state';\nimport { trackAgeGate } from '$lib/analytics';\nimport { saveResume } from '$lib/oauth-resume';\nimport { openAuthSheet } from '$lib/stores/authSheet';\nimport type { AgeGateMode, AgeGateSurface } from '$lib/age-gate';\n\n/** RAT-641: drives the one age-check sheet mounted in the root layout, the way\n *  authSheet drives the sign-in sheet. Any blurred tile or gated button opens\n *  it in place; nobody is sent to another page. */\n\n/** The frame's landing page tells the sheet the check has finished. */\nexport const AGE_GATE_DONE_MESSAGE = 'ratemyd:age-gate-done';\n/** sessionStorage: where to come back to when the check ran full screen, as\n *  JSON `{ back, surface, mode }`. */\nexport const AGE_GATE_RETURN_KEY = 'age_gate_return';\n/** sessionStorage: reopen the sheet once a signed-out visitor has signed in. */\nexport const RESUME_AGE_GATE = 'gate_age_check';\n/** sessionStorage: back on the page after a full-screen check, show how it\n *  went. JSON `{ surface, mode }`, set by /age/done, read once by the sheet. */\nexport const AGE_GATE_RESULT_KEY = 'age_gate_result';\n\n/** What the full-screen check leaves behind for the way back. */\nexport interface AgeGateReturn {\n\tback: string;\n\tsurface: AgeGateSurface;\n\tmode: AgeGateMode;\n\t/** Scroll position to put them back at. */\n\ty?: number;\n}\n\ninterface AgeGateState {\n\topen: boolean;\n\tsurface: AgeGateSurface;\n\tmode: AgeGateMode;\n\t/** Runs once the check passes: finishes what the tap was for. */\n\tonPass?: () => void;\n\t/** Back from a check that ran full screen: open straight on the result. */\n\tchecking?: boolean;\n}\n\nexport const ageGate = writable<AgeGateState>({ open: false, surface: 'feed', mode: 'view' });\n\nexport function openAgeGate(opts: {\n\tsurface: AgeGateSurface;\n\tmode?: AgeGateMode;\n\tonPass?: () => void;\n}): void {\n\tconst mode = opts.mode ?? 'view';\n\t// Signed out there's nothing to check yet: the pass belongs to an account.\n\t// The tap opens the plain sign-in sheet, since selfie talk before someone\n\t// has joined only scares them off, and the sheet reopens the check by\n\t// itself once they're in.\n\tif (!page.data.user) {\n\t\tsaveResume(RESUME_AGE_GATE, { surface: opts.surface, mode });\n\t\topenAuthSheet(page.url.pathname + page.url.search, 'gate_age_check');\n\t\ttrackAgeGate('signin', { surface: opts.surface, mode });\n\t\treturn;\n\t}\n\tageGate.set({ open: true, surface: opts.surface, mode, onPass: opts.onPass });\n\ttrackAgeGate('shown', { surface: opts.surface, mode });\n}\n\n/** Back on the page after a check that ran full screen (phones): the sheet\n *  reopens on \"checking…\" and shows how it went. */\nexport function resumeAgeCheck(opts: { surface: AgeGateSurface; mode: AgeGateMode }): void {\n\tageGate.set({ open: true, surface: opts.surface, mode: opts.mode, checking: true });\n}\n\nexport function closeAgeGate(): void {\n\tageGate.update((s) => ({ ...s, open: false, onPass: undefined, checking: false }));\n}\n\n/** For click handlers in front of something gated: true when the user may go\n *  ahead now; otherwise opens the sheet (which runs `onPass` once they pass)\n *  and answers false. `data` is the page data the root layout fills. */\nexport function requireAge(\n\tdata: { ageGate?: boolean; ageVerified?: boolean } | null | undefined,\n\topts: { surface: AgeGateSurface; mode?: AgeGateMode; onPass?: () => void }\n): boolean {\n\tif (!data?.ageGate || data.ageVerified) return true;\n\topenAgeGate(opts);\n\treturn false;\n}\n"],"version":3}