{"release_id":"01a2309f-d47d-0000-29bc-a17a97e31fa5","chunk_id":"01a2309f-d5cb-75c3-9655-784bab3edfec","file":"DQHEXean.mjs","mappings":"+VAQO,MAAMA,EAAmB,eAGnBC,EAAkB,kBAIxB,SAASC,GAAiC,CAChD,GAAI,CACH,MAAMC,EAAM,eAAe,QAAQH,CAAgB,EAC7CI,EAAID,EAAME,EAAkB,KAAK,MAAMF,CAAG,CAAC,EAAI,KACrD,OAAOC,GAAK,CAACE,EAAQF,CAAC,EAAIA,EAAI,IAC/B,MAAQ,CACP,OAAO,IACR,CACD,CAkBO,SAASG,EAAcC,EAAwB,CACrD,GAAI,CACH,eAAe,QAAQP,EAAiBO,EAAS,YAAA,CAAa,CAC/D,MAAQ,CAER,CACD,CAGO,SAASC,EAAeD,EAA2B,CACzD,GAAI,CACH,MAAME,EAAI,eAAe,QAAQT,CAAe,EAChD,sBAAe,WAAWA,CAAe,EAClCS,IAAMF,EAAS,YAAA,CACvB,MAAQ,CACP,MAAO,EACR,CACD,CAIA,MAAMG,EAAe,kBAId,SAASC,GAAyB,CACxC,GAAI,CACH,IAAIC,EAAK,eAAe,QAAQF,CAAY,EAC5C,OAAKE,IACJA,EAAK,OAAO,WAAA,EACZ,eAAe,QAAQF,EAAcE,CAAE,GAEjCA,CACR,MAAQ,CACP,OAAO,IACR,CACD,CAGO,SAASC,GAA6B,CAC5C,GAAI,CACH,MAAMD,EAAK,eAAe,QAAQF,CAAY,EAC9C,sBAAe,WAAWA,CAAY,EAC/BE,CACR,MAAQ,CACP,OAAO,IACR,CACD","names":["SCULPT_DRAFT_KEY","GUEST_CLASH_KEY","readDraft","raw","p","sanitizeAnySculpt","isVulva","setGuestClash","nickname","takeGuestClash","v","GUEST_ID_KEY","guestId","id","takeGuestId"],"sources":["../../../../../../src/lib/sculpt/draft.ts"],"sourcesContent":["// The editor's unsaved sculpt (either body), carried in sessionStorage across a sign-in round trip\n// (the gate) and to the signed-out clash (/sculpt/vs/[nickname], RAT-653). Browser only; every read\n// and write is guarded, because private mode or blocked storage throws, and a page must still work\n// without it.\n\nimport type { SculptParams } from './params';\nimport { isVulva, sanitizeAnySculpt } from './vulva-params';\n\nexport const SCULPT_DRAFT_KEY = 'sculpt:draft';\n/** Set by the signed-out clash's \"Save it\": the nickname whose clash the editor starts on its own\n *  once signed in. Only this tab's own tap sets it, so a crafted ?go=1 link never clashes anyone. */\nexport const GUEST_CLASH_KEY = 'sculpt:guest-vs';\n\n/** The draft the signed-out clash plays: a penis. A vulva is never clashed, so her draft reads as\n *  none (the page sends the visitor back to the editor, where it still opens). */\nexport function readDraft(): SculptParams | null {\n\ttry {\n\t\tconst raw = sessionStorage.getItem(SCULPT_DRAFT_KEY);\n\t\tconst p = raw ? sanitizeAnySculpt(JSON.parse(raw)) : null;\n\t\treturn p && !isVulva(p) ? p : null;\n\t} catch {\n\t\treturn null; // a broken draft is just dropped\n\t}\n}\n\nexport function writeDraft(params: SculptParams): void {\n\ttry {\n\t\tsessionStorage.setItem(SCULPT_DRAFT_KEY, JSON.stringify(params));\n\t} catch {\n\t\t/* private mode: the in-place sign-in sheet keeps the page (and the sculpt) anyway */\n\t}\n}\n\nexport function dropDraft(): void {\n\ttry {\n\t\tsessionStorage.removeItem(SCULPT_DRAFT_KEY);\n\t} catch {\n\t\t/* nothing stored */\n\t}\n}\n\nexport function setGuestClash(nickname: string): void {\n\ttry {\n\t\tsessionStorage.setItem(GUEST_CLASH_KEY, nickname.toLowerCase());\n\t} catch {\n\t\t/* without it the editor just waits for the Clash tap */\n\t}\n}\n\n/** True (once) when this tab's signed-out clash against `nickname` asked for the real one. */\nexport function takeGuestClash(nickname: string): boolean {\n\ttry {\n\t\tconst v = sessionStorage.getItem(GUEST_CLASH_KEY);\n\t\tsessionStorage.removeItem(GUEST_CLASH_KEY);\n\t\treturn v === nickname.toLowerCase();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** RAT-653: a random id for this tab's signed-out clashes, so a re-run updates its one line in the\n *  owner's \"Who clashed you\" list and signing up replaces it with the real clash. Not tied to a person. */\nconst GUEST_ID_KEY = 'sculpt:guest-id';\n\n/** This tab's guest id, made on first use. Null where storage or crypto.randomUUID is unavailable\n *  (the attempt is then simply not listed). */\nexport function guestId(): string | null {\n\ttry {\n\t\tlet id = sessionStorage.getItem(GUEST_ID_KEY);\n\t\tif (!id) {\n\t\t\tid = crypto.randomUUID();\n\t\t\tsessionStorage.setItem(GUEST_ID_KEY, id);\n\t\t}\n\t\treturn id;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** The guest id this tab used, once (after sign-up: the real clash takes over its line). */\nexport function takeGuestId(): string | null {\n\ttry {\n\t\tconst id = sessionStorage.getItem(GUEST_ID_KEY);\n\t\tsessionStorage.removeItem(GUEST_ID_KEY);\n\t\treturn id;\n\t} catch {\n\t\treturn null;\n\t}\n}\n"],"version":3}