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AC,EAAApC,EAAAb,CAAK,EAAC,IAAI,KAChB+C,EAAC,OAAAG,CAAA,GAAO,CAAA,IAAAC,GAAQ,aAAY,CAAI,GAAEtC,EAAEb,CAAK,EAAC,OAAM,CAAA,aAAhD+C,EAAC,IAAA5C,EAAoEH,EAAQ,IAAI,CAAA,MAHnF2C,CAAG,aADA3C,CAAK,GAAAkC,EAAAkB,CAAA,uBA5CF","names":["postSculptToFeed","target","caption","j","uploadClashFeedImage","code","image","fd","r","isOpen","$.state","busy","error","toast","toastTimer","open","$.set","close","showToast","text","postId","submit","requireAge","page","failed","$$props","$.get","AGE_REQUIRED","openAgeGate","onKey","e","portal","node","div","root_1","div_1","button","div_2","div_3","button_1","p","textarea","$.sibling","$.remove_textarea_child","node_2","p_1","root_2","$$render","consequent","div_4","button_2","button_3","$.attach","$.delegated","$$value","consequent_1","div_5","root_3","div_6","span","a","$.set_text","text_4","$0","resolve","consequent_2"],"sources":["../../../../../../src/lib/sculpt/feed-client.ts","../../../../../../src/lib/components/sculpt/SculptFeedSheet.svelte"],"sourcesContent":["// Browser side of POST /api/sculpt/feed and POST /api/sculpt/clash/[code]/feed-image.\n\nexport type FeedPostTarget = { kind: 'sculpt' } | { kind: 'sculpt_clash'; code: string };\nexport type FeedPostResult =\n\t| { ok: true; id: string }\n\t| { ok: false; status: number; error: string; message: string; postId: string | null };\n\nexport async function postSculptToFeed(\n\ttarget: FeedPostTarget,\n\tcaption: string\n): Promise<FeedPostResult> {\n\ttry {\n\t\tconst r = await fetch('/api/sculpt/feed', {\n\t\t\tmethod: 'POST',\n\t\t\theaders: { 'content-type': 'application/json' },\n\t\t\tbody: JSON.stringify({ ...target, caption: caption.trim() || null })\n\t\t});\n\t\tconst j = await r.json().catch(() => ({}));\n\t\tif (r.ok && typeof j.id === 'string') return { ok: true, id: j.id };\n\t\treturn {\n\t\t\tok: false,\n\t\t\tstatus: r.status,\n\t\t\terror: j.error ?? 'error',\n\t\t\tmessage: j.message ?? 'Could not post. Try again.',\n\t\t\tpostId: typeof j.postId === 'string' ? j.postId : null\n\t\t};\n\t} catch {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tstatus: 0,\n\t\t\terror: 'network',\n\t\t\tmessage: 'No connection. Try again.',\n\t\t\tpostId: null\n\t\t};\n\t}\n}\n\n/** Upload the clash's measured frame (ClashShow.feedFrame). Null = stored, else the message to show. */\nexport async function uploadClashFeedImage(code: string, image: Blob): Promise<string | null> {\n\tconst fd = new FormData();\n\tfd.set('image', image, image.type === 'image/png' ? 'frame.png' : 'frame.webp');\n\ttry {\n\t\tconst r = await fetch(`/api/sculpt/clash/${encodeURIComponent(code)}/feed-image`, {\n\t\t\tmethod: 'POST',\n\t\t\tbody: fd\n\t\t});\n\t\tif (r.ok) return null;\n\t\tconst j = await r.json().catch(() => ({}));\n\t\treturn j.message ?? 'Could not upload the image. Try again.';\n\t} catch {\n\t\treturn 'No connection. Try again.';\n\t}\n}\n","<script lang=\"ts\">\n\t// \"Share to feed\" from /sculpt and the clash page: an optional caption, then POST\n\t// /api/sculpt/feed. The page opens it (`open()`) from its own button; `prepare` runs first (save\n\t// the sculpt / upload the clash frame) and returns an error to show, or null to go on. Shell from\n\t// InkUnlockSheet (bottom-right card → bottom sheet on phones). The toast links to the post.\n\timport { resolve } from '$app/paths';\n\timport { page } from '$app/state';\n\timport { AGE_REQUIRED } from '$lib/age-gate';\n\timport { openAgeGate, requireAge } from '$lib/stores/ageGate';\n\timport { postSculptToFeed, type FeedPostTarget } from '$lib/sculpt/feed-client';\n\n\tinterface Props {\n\t\ttarget: FeedPostTarget;\n\t\t/** One line under the title: what lands in the feed. */\n\t\tdetail: string;\n\t\tprepare?: () => Promise<string | null>;\n\t}\n\n\tlet { target, detail, prepare }: Props = $props();\n\n\tlet isOpen = $state(false);\n\tlet caption = $state('');\n\tlet busy = $state(false);\n\tlet error = $state('');\n\tlet toast = $state<{ text: string; postId: string } | null>(null);\n\tlet toastTimer: ReturnType<typeof setTimeout> | undefined;\n\n\texport function open() {\n\t\terror = '';\n\t\tisOpen = true;\n\t}\n\n\tfunction close() {\n\t\tif (!busy) isOpen = false;\n\t}\n\n\tfunction showToast(text: string, postId: string) {\n\t\ttoast = { text, postId };\n\t\tclearTimeout(toastTimer);\n\t\ttoastTimer = setTimeout(() => (toast = null), 5000);\n\t}\n\n\tasync function submit() {\n\t\tif (busy) return;\n\t\t// a feed post is in front of others: the age check first; a pass runs this again\n\t\tif (\n\t\t\t!requireAge(page.data, {\n\t\t\t\tsurface: 'publish_post',\n\t\t\t\tmode: 'publish',\n\t\t\t\tonPass: () => void submit()\n\t\t\t})\n\t\t)\n\t\t\treturn;\n\t\tbusy = true;\n\t\terror = '';\n\t\ttry {\n\t\t\tconst failed = await prepare?.();\n\t\t\tif (failed) {\n\t\t\t\terror = failed;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst r = await postSculptToFeed(target, caption);\n\t\t\tif (r.ok) {\n\t\t\t\tisOpen = false;\n\t\t\t\tcaption = '';\n\t\t\t\tshowToast('Posted to the feed', r.id);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (r.status === 403 && r.error === AGE_REQUIRED) {\n\t\t\t\topenAgeGate({ surface: 'publish_post', mode: 'publish', onPass: () => void submit() });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (r.postId) {\n\t\t\t\t// already there (this clash, or today's sculpt card): point at it instead of an error\n\t\t\t\tisOpen = false;\n\t\t\t\tshowToast(\n\t\t\t\t\tr.error === 'daily_limit' ? 'You shared it today already' : 'Already in the feed',\n\t\t\t\t\tr.postId\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\terror = r.message;\n\t\t} finally {\n\t\t\tbusy = false;\n\t\t}\n\t}\n\n\tfunction onKey(e: KeyboardEvent) {\n\t\tif (isOpen && e.key === 'Escape') close();\n\t}\n\n\t/** On <body>, out of the page's fixed / clipped layers. Portalled from inside a wrapper that\n\t *  stays put, so Svelte's teardown never looks for a moved node (MessageChooser). */\n\tfunction portal(node: HTMLElement) {\n\t\tdocument.body.appendChild(node);\n\t\treturn () => node.remove();\n\t}\n</script>\n\n<svelte:window onkeydown={onKey} />\n\n{#if isOpen}\n\t<div class=\"anchor\">\n\t\t<div class=\"layer\" {@attach portal}>\n\t\t\t<button class=\"scrim\" tabindex=\"-1\" aria-label=\"Close\" onclick={close}></button>\n\t\t\t<div class=\"sheet\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"sculpt-feed-title\">\n\t\t\t\t<div class=\"sh-hd\">\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"eyebrow accent\">Feed</div>\n\t\t\t\t\t\t<h2 id=\"sculpt-feed-title\">Share to feed</h2>\n\t\t\t\t\t</div>\n\t\t\t\t\t<button class=\"x\" onclick={close} disabled={busy} aria-label=\"Close\">\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\tstroke-width=\"2.4\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\"><path d=\"M6 6l12 12M18 6 6 18\" /></svg\n\t\t\t\t\t\t>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<p class=\"detail\">{detail}</p>\n\t\t\t\t<textarea\n\t\t\t\t\tbind:value={caption}\n\t\t\t\t\tplaceholder=\"Add a caption (optional)\"\n\t\t\t\t\trows=\"3\"\n\t\t\t\t\tmaxlength=\"2000\"\n\t\t\t\t\taria-label=\"Caption\"\n\t\t\t\t></textarea>\n\t\t\t\t{#if error}<p class=\"err\" role=\"alert\">{error}</p>{/if}\n\t\t\t\t<div class=\"row\">\n\t\t\t\t\t<button class=\"btn\" onclick={close} disabled={busy}>Not now</button>\n\t\t\t\t\t<button class=\"btn p\" onclick={submit} disabled={busy}\n\t\t\t\t\t\t>{busy ? 'Posting…' : 'Post'}</button\n\t\t\t\t\t>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n{/if}\n\n{#if toast}\n\t<div class=\"anchor\">\n\t\t<div class=\"toast\" role=\"status\" aria-live=\"polite\" {@attach portal}>\n\t\t\t<span>{toast.text}</span>\n\t\t\t<a href={resolve('/post/[id]', { id: toast.postId })} onclick={() => (toast = null)}>View</a>\n\t\t</div>\n\t</div>\n{/if}\n\n<style>\n\t/* Shell from InkUnlockSheet; the primary button is the sculpt CTA purple. */\n\t.anchor {\n\t\tdisplay: contents;\n\t}\n\t.scrim {\n\t\tposition: fixed;\n\t\tinset: 0;\n\t\tborder: 0;\n\t\tpadding: 0;\n\t\tcursor: default;\n\t\tz-index: 60;\n\t\tbackground: rgba(0, 0, 0, 0.45);\n\t}\n\t.sheet {\n\t\tposition: fixed;\n\t\tz-index: 61;\n\t\tright: max(24px, env(safe-area-inset-right, 0px));\n\t\tbottom: max(24px, env(safe-area-inset-bottom, 0px));\n\t\twidth: min(380px, calc(100vw - 32px));\n\t\tmax-height: min(640px, calc(100dvh - 48px));\n\t\toverflow-y: auto;\n\t\toverscroll-behavior: contain;\n\t\tbackground: var(--color-surface);\n\t\tcolor: var(--color-text);\n\t\tborder-radius: 22px;\n\t\tpadding: 18px;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tgap: 12px;\n\t\tbox-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);\n\t\tfont: 15px/1.45 var(--font-body);\n\t}\n\t.sh-hd {\n\t\tdisplay: flex;\n\t\tjustify-content: space-between;\n\t\talign-items: flex-start;\n\t\tgap: 12px;\n\t}\n\t.eyebrow {\n\t\tfont-size: 12px;\n\t\tfont-weight: 700;\n\t\tletter-spacing: 0.1em;\n\t\ttext-transform: uppercase;\n\t\tcolor: #9a9a9a;\n\t}\n\t.eyebrow.accent {\n\t\tcolor: #c4a6ff;\n\t}\n\th2 {\n\t\tmargin: 4px 0 0;\n\t\tfont: 700 26px/1.05 var(--font-display);\n\t\tletter-spacing: -0.03em;\n\t}\n\t.x {\n\t\tflex: none;\n\t\twidth: 38px;\n\t\theight: 38px;\n\t\tborder-radius: 50%;\n\t\tborder: 0;\n\t\tbackground: var(--color-border);\n\t\tcolor: var(--color-text);\n\t\tdisplay: grid;\n\t\tplace-items: center;\n\t\tcursor: pointer;\n\t}\n\t.x svg {\n\t\twidth: 17px;\n\t\theight: 17px;\n\t}\n\t.detail {\n\t\tmargin: -4px 2px 0;\n\t\tfont-size: 14px;\n\t\tcolor: #a3a3a3;\n\t}\n\t/* 16px: iOS Safari zooms into smaller inputs */\n\ttextarea {\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t\tresize: none;\n\t\tborder: 1px solid var(--color-border);\n\t\tbackground: var(--color-surface-2);\n\t\tcolor: var(--color-text);\n\t\tborder-radius: 13px;\n\t\tpadding: 11px 12px;\n\t\tfont: 16px/1.4 var(--font-body);\n\t\toutline: none;\n\t}\n\ttextarea:focus {\n\t\tborder-color: #7c3aed;\n\t}\n\ttextarea::placeholder {\n\t\tcolor: #737373;\n\t}\n\t.err {\n\t\tmargin: 0 2px;\n\t\tfont-size: 13.5px;\n\t\tcolor: #ff6b85;\n\t}\n\t.row {\n\t\tdisplay: flex;\n\t\tgap: 8px;\n\t}\n\t.btn {\n\t\tflex: 1;\n\t\tmin-height: 48px;\n\t\tpadding: 0 16px;\n\t\tborder-radius: 14px;\n\t\tborder: 0;\n\t\tbackground: #262626;\n\t\tcolor: #f5f5f5;\n\t\tfont: 700 15px/1 var(--font-body);\n\t\tcursor: pointer;\n\t}\n\t.btn.p {\n\t\tflex: 1.6;\n\t\tbackground: #7c3aed;\n\t\tcolor: #fff;\n\t}\n\t.btn:active {\n\t\ttransform: scale(0.98);\n\t}\n\tbutton[disabled] {\n\t\topacity: 0.5;\n\t\tcursor: default;\n\t}\n\tbutton:focus-visible,\n\ta:focus-visible {\n\t\toutline: 2px solid #fff;\n\t\toutline-offset: 2px;\n\t}\n\t.toast {\n\t\tposition: fixed;\n\t\tleft: 50%;\n\t\tbottom: calc(max(24px, env(safe-area-inset-bottom, 0px)) + 72px);\n\t\ttransform: translateX(-50%);\n\t\tz-index: 62;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tgap: 14px;\n\t\twhite-space: nowrap;\n\t\tbackground: #fff;\n\t\tcolor: #0c0c0c;\n\t\tfont: 700 14px var(--font-body);\n\t\tpadding: 6px 6px 6px 16px;\n\t\tborder-radius: 999px;\n\t\tbox-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);\n\t\tanimation: toast-in 0.2s ease-out;\n\t}\n\t.toast a {\n\t\tmin-height: 36px;\n\t\tpadding: 0 14px;\n\t\tborder-radius: 999px;\n\t\tbackground: #0c0c0c;\n\t\tcolor: #fff;\n\t\tdisplay: grid;\n\t\tplace-items: center;\n\t\ttext-decoration: none;\n\t}\n\t.toast a:focus-visible {\n\t\toutline-color: #7c3aed;\n\t}\n\t@keyframes toast-in {\n\t\tfrom {\n\t\t\topacity: 0;\n\t\t\ttransform: translate(-50%, 10px);\n\t\t}\n\t}\n\t@media (prefers-reduced-motion: reduce) {\n\t\t.toast {\n\t\t\tanimation: none;\n\t\t}\n\t}\n\t@media (max-width: 860px) {\n\t\t.sheet {\n\t\t\tleft: 0;\n\t\t\tright: 0;\n\t\t\tbottom: 0;\n\t\t\twidth: 100%;\n\t\t\tmax-height: 86dvh;\n\t\t\tborder-radius: 22px 22px 0 0;\n\t\t\tpadding-bottom: max(18px, env(safe-area-inset-bottom, 0px));\n\t\t}\n\t}\n</style>\n"],"version":3}