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PLAY_FACE","BODY_FACE","DISPLAY","BODY","lineFont","size","brandFont","LOOK","wrapLines","text","maxWidth","measure","out","para","line","word","next","ch","fitText","sizes","maxLines","lines","cropPhoto","w","h","ratio","cw","layoutCard","photoW","photoH","style","brandW","crop","height","margin","padX","fit","step","brandBaseline","first","t","i","inner","photoHeight","top","roundRect","ctx","x","y","r","drawCard","canvas","photo","L","look","box","baseline","bottom","MAX_BYTES","WORKING_EDGE","PhotoError","isHeic","file","decode","url","img","openPhoto","source","scale","fonts","loadCardFonts","face","f","releaseCanvas","QUALITY","canvasJpeg","resolve","canvasJpegNow","bin","bytes","canShareImage","shareImage","blob","filename","isTouchDevice","err","href","a","BLOCKED","blockedLine","inputId","$.props_id","$.prop","$$props","$.proxy","$.state","opening","problem","shareLabel","jpeg","jpegKey","drawnKey","serial","madeFor","picker","$.derived","blocked","$.get","cardText","theme","l","paint","key","trackCaptionPhotoMade","timer","b","load","$.set","tick","e","pick","shuffle","others","commit","card","how","trackCaptionShared","trackCaptionDownloaded","onMount","early","div","root","input","$.child","node","$.sibling","div_1","$.first_child","fragment","canvas_1","$.attach","div_2","textarea","$.remove_textarea_child","node_1","p","root_2","$$render","consequent","div_3","button","div_4","s","$$anchor","button_1","root_3","span","$.reset","$.set_attribute","$.set_class","$.delegated","$.append","button_2","text_1","button_3","$.bind_value","label","root_4","span_1","span_2","text_2","span_3","text_3","span_4","consequent_1","alternate","p_1","root_5","consequent_2"],"sources":["../../../../../../src/lib/captions/card.ts","../../../../../../src/lib/captions/photo.ts","../../../../../../src/lib/components/captions/PhotoCaptioner.svelte"],"sourcesContent":["/**\n * A caption card from the viewer's own photo (RAT-649): the photo with one\n * line set under it or on it, drawn on a canvas in the browser. Nothing here\n * uploads anything; the layout is plain arithmetic so it can be tested\n * without a canvas.\n */\n\nexport type CardStyle = 'ink' | 'paper' | 'bare';\n\n/** Named for screen readers; the control shows each one as a small card. */\nexport const CARD_STYLES: { id: CardStyle; label: string }[] = [\n\t{ id: 'ink', label: 'dark frame' },\n\t{ id: 'paper', label: 'light frame' },\n\t{ id: 'bare', label: 'text on the photo' }\n];\n\nexport const CARD_WIDTH = 1080;\n/** What the card says about where it was made, small, under the line. */\nexport const CARD_BRAND = 'ratemyd.app';\n\n/** The frame around the photo on the framed styles. */\nconst FRAME = 48;\n/** A photo taller or wider than this (height / width) is cropped to it, from the middle. */\nconst MAX_RATIO = 1.5;\nconst MIN_RATIO = 0.6;\n\n/** Share of the type size above the baseline that capitals reach, and below it for descenders. */\nconst ASC = 0.74;\nconst DESC = 0.22;\n\nconst FRAMED_SIZES = [78, 70, 62, 56, 50, 44];\nconst BARE_SIZES = [64, 58, 52, 46, 41, 36];\nconst BRAND_SIZE = 26;\n\n/** The site's two faces, registered for the canvas under their own names\n *  (loadCardFonts in ./photo): the page's own copies are `font-display:\n *  optional`, which a canvas can't count on. */\nexport const DISPLAY_FACE = 'Caption Display';\nexport const BODY_FACE = 'Caption Body';\nconst DISPLAY = `\"${DISPLAY_FACE}\", \"Space Grotesk\", system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif`;\nconst BODY = `\"${BODY_FACE}\", \"DM Sans\", system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif`;\nexport const lineFont = (size: number) => `700 ${size}px ${DISPLAY}`;\nexport const brandFont = (size: number) => `600 ${size}px ${BODY}`;\n\nconst LOOK = {\n\tink: { bg: '#0c0c0c', text: '#f0f0f0', brand: '#8a8a8a' },\n\tpaper: { bg: '#f3f1ec', text: '#121212', brand: '#6f6c66' },\n\tbare: { bg: '#0c0c0c', text: '#ffffff', brand: 'rgba(255,255,255,0.86)', box: 'rgba(12,12,12,0.8)' }\n} as const;\n\n/** Width of `text` set at `size` px. */\nexport type Measure = (text: string, size: number) => number;\n\nexport type Rect = { x: number; y: number; w: number; h: number };\n\nexport type CardLayout = {\n\twidth: number;\n\theight: number;\n\t/** the part of the photo that is used, in its own pixels */\n\tcrop: Rect;\n\t/** where that part goes on the card */\n\tphoto: Rect;\n\tsize: number;\n\t/** `y` is the baseline */\n\tlines: { text: string; x: number; y: number; w: number }[];\n\tbrand: { x: number; y: number; w: number };\n};\n\n/** Greedy word wrap. Each line of the text is a paragraph of its own, and a\n *  word wider than a whole line is broken where it runs out of room. */\nexport function wrapLines(text: string, maxWidth: number, size: number, measure: Measure): string[] {\n\tconst out: string[] = [];\n\tfor (const para of text.split('\\n')) {\n\t\tlet line = '';\n\t\tfor (const word of para.split(/\\s+/).filter(Boolean)) {\n\t\t\tconst next = line ? `${line} ${word}` : word;\n\t\t\tif (measure(next, size) <= maxWidth) {\n\t\t\t\tline = next;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (line) out.push(line);\n\t\t\tline = '';\n\t\t\tfor (const ch of word) {\n\t\t\t\tif (line && measure(line + ch, size) > maxWidth) {\n\t\t\t\t\tout.push(line);\n\t\t\t\t\tline = ch;\n\t\t\t\t} else line += ch;\n\t\t\t}\n\t\t}\n\t\tif (line) out.push(line);\n\t}\n\treturn out;\n}\n\n/** The biggest size that sets the text in `maxLines` lines or fewer; the\n *  smallest size, on as many lines as it takes, when none does. */\nexport function fitText(\n\ttext: string,\n\tmaxWidth: number,\n\tsizes: readonly number[],\n\tmaxLines: number,\n\tmeasure: Measure\n): { size: number; lines: string[] } {\n\tfor (const size of sizes) {\n\t\tconst lines = wrapLines(text, maxWidth, size, measure);\n\t\tif (lines.length <= maxLines) return { size, lines };\n\t}\n\tconst size = sizes[sizes.length - 1];\n\treturn { size, lines: wrapLines(text, maxWidth, size, measure) };\n}\n\n/** The middle of the photo, at a height-to-width ratio the card can hold. */\nexport function cropPhoto(w: number, h: number): Rect {\n\tconst ratio = h / w;\n\tif (ratio > MAX_RATIO) {\n\t\tconst ch = Math.round(w * MAX_RATIO);\n\t\treturn { x: 0, y: Math.round((h - ch) / 2), w, h: ch };\n\t}\n\tif (ratio < MIN_RATIO) {\n\t\tconst cw = Math.round(h / MIN_RATIO);\n\t\treturn { x: Math.round((w - cw) / 2), y: 0, w: cw, h };\n\t}\n\treturn { x: 0, y: 0, w, h };\n}\n\n/** `measure` sets the line's face; `brandW` is how wide CARD_BRAND comes out in its own. */\nexport function layoutCard(\n\tphotoW: number,\n\tphotoH: number,\n\ttext: string,\n\tstyle: CardStyle,\n\tmeasure: Measure,\n\tbrandW: number\n): CardLayout {\n\tconst crop = cropPhoto(photoW, photoH);\n\n\tif (style === 'bare') {\n\t\t// The photo edge to edge, the line in dark boxes over its lower left.\n\t\tconst height = Math.round(CARD_WIDTH * (crop.h / crop.w));\n\t\tconst margin = 56;\n\t\tconst padX = 22;\n\t\tconst fit = fitText(text, CARD_WIDTH - margin * 2 - padX * 2, BARE_SIZES, 4, measure);\n\t\tconst step = Math.round(fit.size * 1.3);\n\t\t// from the bottom up: the brand's box, then the lines' boxes\n\t\tconst brandBaseline = height - margin - Math.round(BRAND_SIZE * (DESC + 0.3));\n\t\tconst lastBaseline = brandBaseline - Math.round(BRAND_SIZE * ASC) - 28 - Math.round(fit.size * DESC);\n\t\tconst first = lastBaseline - (fit.lines.length - 1) * step;\n\t\treturn {\n\t\t\twidth: CARD_WIDTH,\n\t\t\theight,\n\t\t\tcrop,\n\t\t\tphoto: { x: 0, y: 0, w: CARD_WIDTH, h: height },\n\t\t\tsize: fit.size,\n\t\t\tlines: fit.lines.map((t, i) => ({\n\t\t\t\ttext: t,\n\t\t\t\tx: margin + padX,\n\t\t\t\ty: first + i * step,\n\t\t\t\tw: measure(t, fit.size)\n\t\t\t})),\n\t\t\tbrand: { x: margin + padX, y: brandBaseline, w: brandW }\n\t\t};\n\t}\n\n\t// Framed: the photo inside an even border, the line below it.\n\tconst inner = CARD_WIDTH - FRAME * 2;\n\tconst photoHeight = Math.round(inner * (crop.h / crop.w));\n\tconst fit = fitText(text, inner, FRAMED_SIZES, 3, measure);\n\tconst step = Math.round(fit.size * 1.14);\n\tconst top = FRAME + photoHeight + 56;\n\tconst first = top + Math.round(fit.size * ASC);\n\tconst lines = fit.lines.map((t, i) => ({ text: t, x: FRAME, y: first + i * step, w: measure(t, fit.size) }));\n\tconst textBottom = lines.length ? lines[lines.length - 1].y + Math.round(fit.size * DESC) : top;\n\tconst brandBaseline = textBottom + (lines.length ? 36 : 0) + Math.round(BRAND_SIZE * ASC);\n\treturn {\n\t\twidth: CARD_WIDTH,\n\t\theight: brandBaseline + Math.round(BRAND_SIZE * DESC) + 46,\n\t\tcrop,\n\t\tphoto: { x: FRAME, y: FRAME, w: inner, h: photoHeight },\n\t\tsize: fit.size,\n\t\tlines,\n\t\tbrand: { x: FRAME, y: brandBaseline, w: brandW }\n\t};\n}\n\nfunction roundRect(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number) {\n\tctx.beginPath();\n\tctx.moveTo(x + r, y);\n\tctx.arcTo(x + w, y, x + w, y + h, r);\n\tctx.arcTo(x + w, y + h, x, y + h, r);\n\tctx.arcTo(x, y + h, x, y, r);\n\tctx.arcTo(x, y, x + w, y, r);\n\tctx.closePath();\n}\n\n/** Draws the card onto `canvas`, sizing it to the layout. */\nexport function drawCard(\n\tcanvas: HTMLCanvasElement,\n\tphoto: HTMLCanvasElement,\n\ttext: string,\n\tstyle: CardStyle\n): void {\n\tconst ctx = canvas.getContext('2d');\n\tif (!ctx) return;\n\tconst measure: Measure = (t, size) => {\n\t\tctx.font = lineFont(size);\n\t\treturn ctx.measureText(t).width;\n\t};\n\tctx.font = brandFont(BRAND_SIZE);\n\tconst L = layoutCard(photo.width, photo.height, text, style, measure, ctx.measureText(CARD_BRAND).width);\n\t// setting a dimension clears the canvas, so only when it changes\n\tif (canvas.width !== L.width) canvas.width = L.width;\n\tif (canvas.height !== L.height) canvas.height = L.height;\n\n\tconst look = LOOK[style];\n\tctx.fillStyle = look.bg;\n\tctx.fillRect(0, 0, L.width, L.height);\n\tctx.imageSmoothingEnabled = true;\n\tctx.imageSmoothingQuality = 'high';\n\tctx.drawImage(photo, L.crop.x, L.crop.y, L.crop.w, L.crop.h, L.photo.x, L.photo.y, L.photo.w, L.photo.h);\n\n\tctx.textBaseline = 'alphabetic';\n\tctx.textAlign = 'left';\n\n\tif (style === 'bare') {\n\t\tconst padX = 22;\n\t\tconst box = (x: number, baseline: number, w: number, size: number) => {\n\t\t\tconst top = baseline - Math.round(size * (ASC + 0.17));\n\t\t\tconst bottom = baseline + Math.round(size * (DESC + 0.11));\n\t\t\troundRect(ctx, x - padX, top, w + padX * 2, bottom - top, Math.round(size * 0.18));\n\t\t\tctx.fillStyle = LOOK.bare.box;\n\t\t\tctx.fill();\n\t\t};\n\t\tfor (const line of L.lines) box(line.x, line.y, line.w, L.size);\n\t\tbox(L.brand.x, L.brand.y, L.brand.w, BRAND_SIZE);\n\t}\n\n\tctx.font = lineFont(L.size);\n\tctx.fillStyle = look.text;\n\tfor (const line of L.lines) ctx.fillText(line.text, line.x, line.y);\n\n\tctx.font = brandFont(BRAND_SIZE);\n\tctx.fillStyle = look.brand;\n\tctx.fillText(CARD_BRAND, L.brand.x, L.brand.y);\n}\n","/**\n * The browser side of the caption maker (RAT-649): opening the viewer's photo,\n * and handing the finished card to the share sheet or the downloads. The photo\n * is read and redrawn on this device only; nothing is sent anywhere, and the\n * saved file carries no camera or location data because it is a new image.\n */\nimport { isTouchDevice } from '$lib/tools/share-image';\nimport { BODY_FACE, DISPLAY_FACE } from './card';\n\n/** Big enough for any phone photo; past it a browser tab is the likelier thing to break. */\nconst MAX_BYTES = 60 * 1024 * 1024;\n/** The photo is kept at this long edge at most: double the card's width, and\n *  a fraction of the memory a 48-megapixel original takes. */\nconst WORKING_EDGE = 2160;\n\n/** A message for the viewer, written to be shown as is. */\nexport class PhotoError extends Error {}\n\nconst isHeic = (file: File) => /\\.hei[cf]$/i.test(file.name) || /hei[cf]/i.test(file.type);\n\n/**\n * Decodes the photo the right way up. createImageBitmap with\n * `imageOrientation: 'from-image'` turns it by its EXIF orientation where that\n * option exists; where it doesn't (older Safari, Firefox), the call rejects and\n * an <img> does the same job, since browsers draw an <img> by its orientation.\n */\nasync function decode(file: File): Promise<ImageBitmap | HTMLImageElement> {\n\tif (typeof createImageBitmap === 'function') {\n\t\ttry {\n\t\t\treturn await createImageBitmap(file, { imageOrientation: 'from-image' });\n\t\t} catch {\n\t\t\t// unsupported option, or a format this path can't read: try the <img>\n\t\t}\n\t}\n\tconst url = URL.createObjectURL(file);\n\ttry {\n\t\tconst img = new Image();\n\t\timg.decoding = 'async';\n\t\timg.src = url;\n\t\tawait img.decode();\n\t\treturn img;\n\t} finally {\n\t\t// a decoded <img> keeps its pixels after its address goes\n\t\tURL.revokeObjectURL(url);\n\t}\n}\n\n/** The photo as a canvas no bigger than the card needs, ready to draw from. */\nexport async function openPhoto(file: File): Promise<HTMLCanvasElement> {\n\tif (file.size > MAX_BYTES) throw new PhotoError('That photo is too big to open here. Try a smaller one.');\n\tlet source: ImageBitmap | HTMLImageElement;\n\ttry {\n\t\tsource = await decode(file);\n\t} catch {\n\t\tthrow new PhotoError(\n\t\t\tisHeic(file)\n\t\t\t\t? 'This browser can’t open HEIC photos. Try a JPG or PNG, or open the page in Safari.'\n\t\t\t\t: 'That photo couldn’t be opened. Try a JPG or PNG.'\n\t\t);\n\t}\n\tconst w = 'naturalWidth' in source ? source.naturalWidth : source.width;\n\tconst h = 'naturalHeight' in source ? source.naturalHeight : source.height;\n\tif (!w || !h) throw new PhotoError('That photo couldn’t be opened. Try a JPG or PNG.');\n\tconst scale = Math.min(1, WORKING_EDGE / Math.max(w, h));\n\tconst canvas = document.createElement('canvas');\n\tcanvas.width = Math.max(1, Math.round(w * scale));\n\tcanvas.height = Math.max(1, Math.round(h * scale));\n\tconst ctx = canvas.getContext('2d');\n\tif (!ctx) throw new PhotoError('That photo couldn’t be opened. Try a JPG or PNG.');\n\tctx.imageSmoothingEnabled = true;\n\tctx.imageSmoothingQuality = 'high';\n\tctx.drawImage(source, 0, 0, canvas.width, canvas.height);\n\tif ('close' in source) source.close();\n\treturn canvas;\n}\n\nlet fonts: Promise<void> | null = null;\n\n/** The card's faces, from the same files the page uses (the browser has them\n *  cached by then). Resolves either way: without them the card is set in the\n *  system face. */\nexport function loadCardFonts(): Promise<void> {\n\tif (typeof FontFace === 'undefined' || !document.fonts) return Promise.resolve();\n\tfonts ??= Promise.all(\n\t\t[\n\t\t\tnew FontFace(DISPLAY_FACE, 'url(/fonts/space-grotesk-latin.woff2) format(\"woff2\")', { weight: '500 700' }),\n\t\t\tnew FontFace(BODY_FACE, 'url(/fonts/dm-sans-latin.woff2) format(\"woff2\")', { weight: '400 600' })\n\t\t].map((face) => face.load().then((f) => void document.fonts.add(f)))\n\t).then(\n\t\t() => undefined,\n\t\t() => undefined\n\t);\n\treturn fonts;\n}\n\n/** Lets Safari have a canvas's memory back now rather than at some later collection. */\nexport function releaseCanvas(canvas: HTMLCanvasElement | null | undefined): void {\n\tif (!canvas) return;\n\tcanvas.width = 0;\n\tcanvas.height = 0;\n}\n\nconst QUALITY = 0.92;\n\nexport function canvasJpeg(canvas: HTMLCanvasElement): Promise<Blob | null> {\n\treturn new Promise((resolve) => canvas.toBlob(resolve, 'image/jpeg', QUALITY));\n}\n\n/** The same JPEG, made synchronously, for a tap that lands before the\n *  prepared one has caught up: no await, so the tap still counts as one. */\nexport function canvasJpegNow(canvas: HTMLCanvasElement): Blob {\n\tconst url = canvas.toDataURL('image/jpeg', QUALITY);\n\tconst bin = atob(url.slice(url.indexOf(',') + 1));\n\tconst bytes = new Uint8Array(bin.length);\n\tfor (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);\n\treturn new Blob([bytes], { type: 'image/jpeg' });\n}\n\n/** Whether this browser takes an image file in its share sheet. */\nexport function canShareImage(): boolean {\n\ttry {\n\t\tconst file = new File([new Blob()], 'caption.jpg', { type: 'image/jpeg' });\n\t\treturn !!navigator.canShare?.({ files: [file] });\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** The share sheet on a touch device (on iOS the only way into Photos), a\n *  download everywhere else: the rule of the foil card and the size tools\n *  (FoilCardHero, $lib/tools/share-image). Call it straight from the tap with a\n *  file that already exists. Resolves to how it went out, or null if dismissed. */\nexport async function shareImage(blob: Blob, filename: string): Promise<'share' | 'download' | null> {\n\tif (isTouchDevice()) {\n\t\tconst file = new File([blob], filename, { type: blob.type || 'image/jpeg' });\n\t\tif (navigator.canShare?.({ files: [file] })) {\n\t\t\ttry {\n\t\t\t\tawait navigator.share({ files: [file] });\n\t\t\t\treturn 'share';\n\t\t\t} catch (err) {\n\t\t\t\tif ((err as Error)?.name === 'AbortError') return null;\n\t\t\t\t// anything else: fall through to a download\n\t\t\t}\n\t\t}\n\t}\n\tconst href = URL.createObjectURL(blob);\n\tconst a = document.createElement('a');\n\ta.href = href;\n\ta.download = filename;\n\tdocument.body.appendChild(a);\n\ta.click();\n\ta.remove();\n\tsetTimeout(() => URL.revokeObjectURL(href), 10_000);\n\treturn 'download';\n}\n\n/**\n * A line typed in that the card won't carry: anything that reads as a minor or\n * as family, or as sex without consent. The same ground as the listing filter\n * ($lib/server/listing-risk), plus the non-consent words, with word edges so\n * a number like \"fifteen days\" still goes through.\n */\nconst BLOCKED =\n\t/\\b(teens?|teenage\\w*|minors?|underage\\w*|school\\w*|kids?|child\\w*|young\\w*|mom|mum|mommy|mother|sis|sister|daughter|son|family|incest\\w*|step-?(mom|mum|dad|sis|sister|bro|brother|son|daughter|mother|father|family)|(little|baby) ?(girl|boy)s?|loli\\w*|shota\\w*|rape\\w*|drunk\\w*|hypno\\w*|blackmail\\w*|forced|asleep|sleeping|1[0-7] ?(yo|y\\/o|yrs?|years?( old)?))\\b/i;\n\nexport const blockedLine = (text: string) => BLOCKED.test(text);\n","<script lang=\"ts\">\n\timport { onMount, tick } from 'svelte';\n\timport { trackCaptionDownloaded, trackCaptionPhotoMade, trackCaptionShared } from '$lib/analytics';\n\timport { CARD_BRAND, CARD_STYLES, drawCard, type CardStyle } from '$lib/captions/card';\n\timport {\n\t\tblockedLine,\n\t\tcanShareImage,\n\t\tcanvasJpeg,\n\t\tcanvasJpegNow,\n\t\tloadCardFonts,\n\t\topenPhoto,\n\t\tPhotoError,\n\t\treleaseCanvas,\n\t\tshareImage\n\t} from '$lib/captions/photo';\n\timport { isTouchDevice } from '$lib/tools/share-image';\n\n\t/**\n\t * \"Caption your photo\" (RAT-649): the viewer's own photo with one of the\n\t * page's lines on it, drawn in the browser and handed to the share sheet or\n\t * the downloads. The photo is never uploaded. A page that lists its lines\n\t * binds `text` to put one of them here.\n\t */\n\ttype Line = { text: string; theme: string };\n\n\tlet {\n\t\tlines,\n\t\tpage,\n\t\ttext = $bindable(lines[0]?.text ?? ''),\n\t\tfilename = 'caption'\n\t}: { lines: Line[]; page: string; text?: string; filename?: string } = $props();\n\n\tconst inputId = $props.id();\n\n\tlet photo = $state.raw<HTMLCanvasElement | null>(null);\n\tlet style = $state<CardStyle>('ink');\n\tlet opening = $state(false);\n\tlet problem = $state('');\n\tlet shareLabel = $state('save image');\n\n\t// The JPEG of the card on screen, made ahead of the tap: iOS Safari shares\n\t// only a file that already exists when the tap lands (see FoilCardHero).\n\tlet jpeg: Blob | null = null;\n\tlet jpegKey = '';\n\tlet drawnKey = '';\n\tlet serial = 0;\n\tlet madeFor = 0;\n\tlet canvas: HTMLCanvasElement | null = null;\n\n\tconst picker = () => document.getElementById(inputId) as HTMLInputElement | null;\n\n\tconst line = $derived(text.trim());\n\tconst blocked = $derived(blockedLine(line));\n\tconst cardText = $derived(blocked ? '' : line);\n\tconst theme = $derived(lines.find((l) => l.text === line)?.theme ?? 'own');\n\n\t// Redraws the card whenever the photo, the line or the style changes, and\n\t// makes its JPEG once the changes have settled.\n\tfunction paint(c: HTMLCanvasElement) {\n\t\tcanvas = c;\n\t\tif (!photo) return;\n\t\tconst key = `${serial}\\n${style}\\n${cardText}`;\n\t\tdrawCard(c, photo, cardText, style);\n\t\tdrawnKey = key;\n\t\tif (madeFor !== serial) {\n\t\t\tmadeFor = serial;\n\t\t\ttrackCaptionPhotoMade(page);\n\t\t}\n\t\tconst timer = setTimeout(() => {\n\t\t\tcanvasJpeg(c).then((b) => {\n\t\t\t\tif (b && drawnKey === key) {\n\t\t\t\t\tjpeg = b;\n\t\t\t\t\tjpegKey = key;\n\t\t\t\t}\n\t\t\t});\n\t\t}, 150);\n\t\treturn () => clearTimeout(timer);\n\t}\n\n\tasync function load(file: File) {\n\t\tproblem = '';\n\t\topening = true;\n\t\ttry {\n\t\t\t// the card's faces load alongside, so its first drawing is already in them\n\t\t\tconst [next] = await Promise.all([openPhoto(file), loadCardFonts()]);\n\t\t\treleaseCanvas(photo);\n\t\t\tserial += 1;\n\t\t\tjpeg = null;\n\t\t\tphoto = next;\n\t\t\t// on a phone the card pushes the next step below the fold: bring\n\t\t\t// the button that sends it into view, clear of the bottom nav\n\t\t\tawait tick();\n\t\t\ttry {\n\t\t\t\tdocument.getElementById(`${inputId}-go`)?.scrollIntoView({ block: 'nearest', behavior: 'smooth' });\n\t\t\t} catch {\n\t\t\t\t// an engine that can't take the options: the button is a scroll away\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tproblem = e instanceof PhotoError ? e.message : 'That photo couldn’t be opened. Try a JPG or PNG.';\n\t\t} finally {\n\t\t\topening = false;\n\t\t}\n\t}\n\n\tfunction pick(e: Event & { currentTarget: HTMLInputElement }) {\n\t\tconst file = e.currentTarget.files?.[0];\n\t\t// cleared, so choosing the same photo again still counts as a change\n\t\te.currentTarget.value = '';\n\t\tif (file) void load(file);\n\t}\n\n\tfunction shuffle() {\n\t\tconst others = lines.filter((l) => l.text !== line);\n\t\tif (others.length) text = others[Math.floor(Math.random() * others.length)].text;\n\t}\n\n\t// Straight from the tap, with no await before the share sheet opens.\n\tasync function commit() {\n\t\tif (!canvas || !photo || !cardText) return;\n\t\tconst blob = jpeg && jpegKey === drawnKey ? jpeg : canvasJpegNow(canvas);\n\t\tconst card = { page, theme, style };\n\t\tconst how = await shareImage(blob, `${filename}.jpg`);\n\t\tif (how === 'share') trackCaptionShared(card);\n\t\telse if (how === 'download') trackCaptionDownloaded(card);\n\t}\n\n\tonMount(() => {\n\t\tshareLabel = isTouchDevice() && canShareImage() ? 'share' : 'save image';\n\t\t// a photo chosen before the page finished loading is already in the input\n\t\tconst early = picker()?.files?.[0];\n\t\tif (early) void load(early);\n\t\treturn () => {\n\t\t\treleaseCanvas(photo);\n\t\t\treleaseCanvas(canvas);\n\t\t};\n\t});\n</script>\n\n<div>\n\t<!-- with a photo in, \"change photo\" opens it; the hidden input leaves the tab order -->\n\t<input\n\t\tid={inputId}\n\t\ttype=\"file\"\n\t\taccept=\"image/*\"\n\t\tclass=\"peer sr-only\"\n\t\ttabindex={photo ? -1 : undefined}\n\t\tonchange={pick}\n\t/>\n\n\t{#if photo}\n\t\t<div role=\"img\" aria-label={cardText ? `your photo, captioned: ${cardText}` : 'your photo'}>\n\t\t\t<canvas {@attach paint} width=\"1080\" height=\"1350\" class=\"card mx-auto block rounded-2xl\"></canvas>\n\t\t</div>\n\t\t<div class=\"mt-5\">\n\t\t\t<!-- 16px: iOS Safari zooms the page into any smaller field it focuses -->\n\t\t\t<textarea\n\t\t\t\tbind:value={text}\n\t\t\t\trows=\"2\"\n\t\t\t\tmaxlength=\"140\"\n\t\t\t\taria-label=\"caption\"\n\t\t\t\taria-invalid={blocked}\n\t\t\t\tclass=\"block w-full resize-none rounded-xl border border-border bg-transparent px-4 py-3 font-display text-base leading-snug font-bold tracking-tight text-text focus:border-text/40 focus:ring-0\"\n\t\t\t></textarea>\n\t\t\t{#if blocked}\n\t\t\t\t<p class=\"mt-2 text-[13px] text-text/80\">That line can’t go on a card here.</p>\n\t\t\t{/if}\n\t\t\t<div class=\"mt-2 flex items-center justify-between gap-3\">\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonclick={shuffle}\n\t\t\t\t\tclass=\"min-h-11 pr-3 text-sm font-semibold text-muted-2 transition-colors hover:text-text\"\n\t\t\t\t\t>shuffle</button\n\t\t\t\t>\n\t\t\t\t<div role=\"group\" aria-label=\"card style\" class=\"flex gap-1\">\n\t\t\t\t\t{#each CARD_STYLES as s (s.id)}\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\taria-pressed={style === s.id}\n\t\t\t\t\t\t\taria-label={s.label}\n\t\t\t\t\t\t\ttitle={s.label}\n\t\t\t\t\t\t\tonclick={() => (style = s.id)}\n\t\t\t\t\t\t\tclass=\"grid h-11 w-11 place-items-center rounded-xl transition-colors {style === s.id\n\t\t\t\t\t\t\t\t? 'bg-[#3a3a3c]'\n\t\t\t\t\t\t\t\t: 'hover:bg-surface-2'}\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span class=\"swatch {s.id}\" aria-hidden=\"true\"></span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t{/each}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<button\n\t\t\t\tid=\"{inputId}-go\"\n\t\t\t\ttype=\"button\"\n\t\t\t\tonclick={commit}\n\t\t\t\tdisabled={!cardText}\n\t\t\t\tclass=\"mt-3 w-full scroll-mb-28 rounded-xl bg-coral px-7 py-4 text-center font-display text-base font-semibold text-white transition-colors hover:bg-coral-dark disabled:opacity-50\"\n\t\t\t\t>{shareLabel}</button\n\t\t\t>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonclick={() => picker()?.click()}\n\t\t\t\tclass=\"mt-1 min-h-11 w-full text-sm font-semibold text-muted-2 transition-colors hover:text-text\"\n\t\t\t\t>change photo</button\n\t\t\t>\n\t\t</div>\n\t{:else}\n\t\t<label\n\t\t\tfor={inputId}\n\t\t\taria-busy={opening}\n\t\t\tclass=\"block cursor-pointer rounded-2xl border border-border bg-bg p-[4.5%] transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-text/60 hover:border-text/25\"\n\t\t>\n\t\t\t<span class=\"stripes grid aspect-square place-items-center rounded-md\">\n\t\t\t\t<span\n\t\t\t\t\tclass=\"rounded-full border border-text/20 bg-bg/90 px-5 py-2.5 font-display text-sm font-semibold text-text\"\n\t\t\t\t\t>{opening ? 'opening…' : 'add your photo'}</span\n\t\t\t\t>\n\t\t\t</span>\n\t\t\t<span\n\t\t\t\tclass=\"mt-[6%] block font-display text-[clamp(1.15rem,5.4vw,1.55rem)] leading-[1.12] font-bold tracking-tight text-text\"\n\t\t\t\t>{line}</span\n\t\t\t>\n\t\t\t<span class=\"mt-2 block text-[11px] font-semibold text-muted\">{CARD_BRAND}</span>\n\t\t</label>\n\t{/if}\n\n\t{#if problem}\n\t\t<p role=\"alert\" class=\"mt-3 text-sm text-text/85\">{problem}</p>\n\t{/if}\n\t<p class=\"mt-3 text-[13px] text-muted-2\">Your photo stays on your device.</p>\n</div>\n\n<style>\n\t/* small enough on a phone that the card and the button that sends it fit\n\t   on one screen */\n\t.card {\n\t\twidth: auto;\n\t\theight: auto;\n\t\tmax-width: 100%;\n\t\tmax-height: 50vh;\n\t\tmax-height: 50svh;\n\t}\n\t@media (min-width: 768px) {\n\t\t.card {\n\t\t\tmax-height: 64vh;\n\t\t\tmax-height: 64svh;\n\t\t}\n\t}\n\t.stripes {\n\t\tbackground: repeating-linear-gradient(\n\t\t\t135deg,\n\t\t\tvar(--color-surface-2) 0 14px,\n\t\t\tvar(--color-surface) 14px 28px\n\t\t);\n\t}\n\t/* each style as a small card: the photo, and the line on or under it */\n\t.swatch {\n\t\tposition: relative;\n\t\tdisplay: block;\n\t\twidth: 20px;\n\t\theight: 26px;\n\t\tborder-radius: 3px;\n\t\toverflow: hidden;\n\t}\n\t.swatch::before,\n\t.swatch::after {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tborder-radius: 1px;\n\t}\n\t.swatch.ink {\n\t\tbackground: #0c0c0c;\n\t\tbox-shadow: inset 0 0 0 1px #4a4a4c;\n\t}\n\t.swatch.paper {\n\t\tbackground: #f3f1ec;\n\t}\n\t.swatch.ink::before,\n\t.swatch.paper::before {\n\t\tleft: 3px;\n\t\tright: 3px;\n\t\ttop: 3px;\n\t\theight: 13px;\n\t\tbackground: #7a7a7a;\n\t}\n\t.swatch.ink::after,\n\t.swatch.paper::after {\n\t\tleft: 3px;\n\t\tbottom: 5px;\n\t\twidth: 10px;\n\t\theight: 2px;\n\t}\n\t.swatch.ink::after {\n\t\tbackground: #f0f0f0;\n\t}\n\t.swatch.paper::after {\n\t\tbackground: #121212;\n\t}\n\t.swatch.bare {\n\t\tbackground: #7a7a7a;\n\t}\n\t.swatch.bare::after {\n\t\tleft: 3px;\n\t\tbottom: 4px;\n\t\twidth: 11px;\n\t\theight: 5px;\n\t\tbackground: #0c0c0c;\n\t}\n</style>\n"],"version":3}