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BoB,EAAIC,EAAAC,EAAAC,CAAA,EAAA,CAAA,MAAJH,EAAI,EAAA,IAAJA,CAAI,EAAqBI,EAAAC,GAAAC,EAAAC,EAAAF,CAAA,EAAA,CAAA,IAAAG,EAAE,QAAQ,CAAA,CAAA,yCAMnCJ,EAAAC,GAAAC,EAAAG,EAAAJ,CAAA,EAAA,CAAA,IAAAG,EAAE,WAAW,CAAA,CAAA,oCAVL5B,CAAM,EAAA8B,EAAAC,EAAA,CAAA,EAAAD,EAAAE,EAAA,EAAA,IAVhBC,EAAAjB,CAAA,QAAAA,EAAA,SAAAF,EAGUZ,CAAI,EAHdgC,EAAAlB,EAAA,aAAAS,CAAA,EAAAU,EAAAnB,EAAA,EAAAoB,EAAA9B,EAAA,OAMC,6NAA6N,CAAA,GAFlN,CAAA,IAAAsB,EAAE,mBAAmB,CAAA,GAJjCS,EAAA,QAAArB,EAESJ,CAAQ,EAFjB0B,EAAAC,EAAAvB,CAAA,KAFO","names":["copied","$.state","busy","copyTimer","url","$.derived","$$props","u","writeToClipboard","text","ta","ok","copyLink","$.set","$.get","trackProfileShareClick","button","root","node","$.child","span","$.sibling","$.first_child","fragment_1","$.template_effect","$0","$.set_text","text_1","t","text_2","$$render","consequent_1","alternate","$.reset","$.set_attribute","$.set_class","$.clsx","$.delegated","$.append","$$anchor"],"sources":["../../../../../../src/lib/components/profile/ShareButton.svelte"],"sourcesContent":["<script lang=\"ts\">\n\timport type { Snippet } from 'svelte';\n\timport { t } from '$lib/i18n';\n\timport { trackProfileShareClick } from '$lib/analytics';\n\n\tinterface Props {\n\t\tnickname: string;\n\t\tisOwnProfile: boolean;\n\t\t/** Replaces the default button classes (the /p hub uses its .btn). */\n\t\tclass?: string;\n\t\t/** Custom content; gets `copied` so it can swap its label. */\n\t\tchildren?: Snippet<[boolean]>;\n\t}\n\n\tlet { nickname, isOwnProfile, class: className, children }: Props = $props();\n\n\tlet copied = $state(false);\n\tlet busy = $state(false);\n\tlet copyTimer: ReturnType<typeof setTimeout> | null = null;\n\n\tconst url = $derived.by(() => {\n\t\tif (typeof window === 'undefined') return `/u/${encodeURIComponent(nickname)}`;\n\t\tconst u = new URL(`/u/${encodeURIComponent(nickname)}`, window.location.origin);\n\t\tu.searchParams.set('utm_source', 'profile_share');\n\t\treturn u.toString();\n\t});\n\n\t// RAT-301: clipboard-only. The previous shareOrCopy() path opened the\n\t// native share sheet via navigator.share({url, title, text}); when the\n\t// user picked \"Copy\" from the sheet on iOS several targets pasted the\n\t// `text` field (\"rate them on ratemyd ↗\") instead of the URL — the\n\t// labeled intent (\"copy link\") was broken. Going straight to\n\t// clipboard.writeText guarantees the URL lands on paste. Other share\n\t// entry points (duel, arena, niche, post) keep shareOrCopy because\n\t// their UX explicitly wants the share sheet's app picker.\n\tasync function writeToClipboard(text: string): Promise<boolean> {\n\t\t// Modern path. Requires HTTPS or localhost — both prod + dev qualify.\n\t\tif (navigator.clipboard?.writeText) {\n\t\t\ttry {\n\t\t\t\tawait navigator.clipboard.writeText(text);\n\t\t\t\treturn true;\n\t\t\t} catch {\n\t\t\t\t// Permission denied / transient — fall through to legacy.\n\t\t\t}\n\t\t}\n\t\t// Legacy fallback for very old Safari / lockdown contexts. A hidden\n\t\t// textarea + execCommand('copy') still works where Clipboard API\n\t\t// doesn't. Cheap to keep, helps the tail.\n\t\ttry {\n\t\t\tconst ta = document.createElement('textarea');\n\t\t\tta.value = text;\n\t\t\tta.style.position = 'fixed';\n\t\t\tta.style.opacity = '0';\n\t\t\tdocument.body.appendChild(ta);\n\t\t\tta.focus();\n\t\t\tta.select();\n\t\t\tconst ok = document.execCommand('copy');\n\t\t\tdocument.body.removeChild(ta);\n\t\t\treturn ok;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tasync function copyLink() {\n\t\tif (busy) return;\n\t\tbusy = true;\n\t\ttry {\n\t\t\tconst ok = await writeToClipboard(url);\n\t\t\tif (ok) {\n\t\t\t\tcopied = true;\n\t\t\t\ttrackProfileShareClick({ isOwnProfile, method: 'clipboard' });\n\t\t\t\tif (copyTimer) clearTimeout(copyTimer);\n\t\t\t\tcopyTimer = setTimeout(() => (copied = false), 2000);\n\t\t\t}\n\t\t} finally {\n\t\t\tbusy = false;\n\t\t}\n\t}\n</script>\n\n<button\n\ttype=\"button\"\n\tonclick={copyLink}\n\tdisabled={busy}\n\taria-label={t('copy profile link')}\n\tclass={className ??\n\t\t'inline-flex shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-2 text-sm font-semibold text-text transition-colors hover:border-muted disabled:cursor-wait disabled:opacity-70'}\n>\n\t{#if children}\n\t\t{@render children(copied)}\n\t{:else if copied}\n\t\t<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"text-green\">\n\t\t\t<path d=\"M20 6L9 17l-5-5\"/>\n\t\t</svg>\n\t\t<span class=\"text-green\">{t('copied')}</span>\n\t{:else}\n\t\t<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t<rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"/>\n\t\t\t<path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"/>\n\t\t</svg>\n\t\t{t('copy link')}\n\t{/if}\n</button>\n"],"version":3}