{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "waitlist-thanks",
  "title": "Waitlist: Referral page",
  "description": "Your place set huge in the serif over the week, with your link and the motion switch beside it, ready messages that copy rather than open other sites, and this week's leaderboard with your row under it.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://eased.dev/r/eased-tokens.json",
    "https://eased.dev/r/eased-motion.json",
    "https://eased.dev/r/waitlist-core.json",
    "https://eased.dev/r/number-roll.json",
    "https://eased.dev/r/button.json",
    "https://eased.dev/r/eased-copy.json"
  ],
  "files": [
    {
      "path": "src/registry/eased/templates/waitlist/thanks.tsx",
      "content": "\"use client\";\n\nimport { useState, useSyncExternalStore } from \"react\";\nimport { useCopy } from \"../../_primitives/copy/copy\";\nimport { Button } from \"../../button/button\";\nimport { NumberRoll } from \"../../number-roll/number-roll\";\nimport { queue, thanks } from \"./content\";\nimport { FieldArt, MotionToggle } from \"./field\";\nimport { BaseLink } from \"../_shared/base\";\nimport { COLUMN, formatPlace, LABEL, Reveal, TITLE } from \"./kit\";\nimport { creditFrom, useLine } from \"./line\";\nimport { Referral } from \"./referral\";\n\n/**\n * The referral page: your place set as large as the field allows, your link beside it, ready\n * messages to copy, and who moved furthest this week. It opens on `?place=` when the welcome\n * email links here with one, on the place you took on the home page when there is none, and on\n * the sample place otherwise, so it works reached directly.\n */\nexport function Thanks() {\n  const line = useLine();\n  const asked = useAskedPlace();\n  // A place from the link or the sample keeps its credit here; the one you took keeps it in the line.\n  const [localCredited, setLocalCredited] = useState(false);\n  const mine = asked === null && line.place !== null;\n  const start = asked ?? line.place ?? queue.samplePlace;\n  const credited = mine ? line.credited : localCredited;\n  const place = mine ? start : credited ? creditFrom(start) : start;\n  const after = creditFrom(place);\n  const sample = asked === null && line.place === null;\n\n  return (\n    <>\n      <section aria-labelledby=\"page-title\" data-wl-field=\"\" className=\"relative isolate overflow-hidden text-text\">\n        <FieldArt step={credited ? 2 : 1} blur={false} />\n        <div className={`${COLUMN} relative grid gap-pad-xl pt-[calc(var(--wl-header)+3rem)] pb-group lg:grid-cols-[minmax(0,7fr)_minmax(0,5fr)] lg:items-end lg:pt-[calc(var(--wl-header)+5rem)]`}>\n          <div className=\"flex min-w-0 flex-col gap-pad-base\">\n            <p className={`wl-rise ${LABEL}`}>{thanks.label}</p>\n            <h1 data-wl-restore=\"\" id=\"page-title\" className=\"wl-rise font-display text-display-4xl font-semibold tracking-display [--i:1] sm:text-display-5xl\">\n              {sample ? thanks.sampleTitle : thanks.title}\n            </h1>\n            <p data-wl-restore=\"\" className=\"wl-rise [--i:2]\">\n              {/* A tall line for the digits' feathered mask, pulled back to the display's 0.95. */}\n              <NumberRoll\n                value={place}\n                formatter={formatPlace}\n                animated={line.live}\n                aria-hidden\n                className=\"-my-[0.175em] font-serif text-[clamp(5rem,17vw,13rem)] leading-[1.3] font-normal tracking-[-0.03em] tabular-nums\"\n              />\n              <span className=\"sr-only\">\n                {thanks.placeLabel}: {formatPlace(place)}\n              </span>\n            </p>\n            <p data-wl-restore=\"\" className=\"wl-rise max-w-lg text-ui-md text-pretty text-text-secondary [--i:3] sm:text-ui-lg\">\n              {sample ? (\n                <>\n                  {thanks.sampleLead}{\" \"}\n                  <BaseLink href={thanks.sampleAction.href} className=\"focus-ring inline-flex min-h-11 items-center rounded-control-xs font-medium text-text underline underline-offset-4 sm:min-h-0\">\n                    {thanks.sampleAction.label}\n                  </BaseLink>\n                </>\n              ) : (\n                thanks.lead\n              )}\n            </p>\n          </div>\n          <div data-wl-restore=\"\" className=\"wl-rise flex w-full max-w-md min-w-0 flex-col gap-pad-md [--i:4] lg:justify-self-end\">\n            <Referral\n              credited={credited}\n              onCredit={mine ? line.credit : () => setLocalCredited(true)}\n              moved={place - after}\n              creditedPlace={formatPlace(after)}\n            />\n            <MotionToggle className=\"-ms-3 self-start lg:ms-0 lg:-me-3 lg:self-end\" />\n          </div>\n        </div>\n      </section>\n      <div className={`${COLUMN} grid gap-group py-section lg:grid-cols-[minmax(0,5fr)_minmax(0,7fr)] lg:gap-group-lg`}>\n        <Share />\n        <Board credited={credited} moved={credited ? (mine ? queue.credit : start - creditFrom(start)) : 0} />\n      </div>\n    </>\n  );\n}\n\nconst subscribeNever = () => () => {};\n\n/** `?place=2483` once hydrated: one to seven digits, above zero; anything else is no place. */\nfunction useAskedPlace() {\n  const search = useSyncExternalStore(subscribeNever, () => window.location.search, () => \"\");\n  const raw = new URLSearchParams(search).get(\"place\") ?? \"\";\n  const n = /^\\d{1,7}$/.test(raw) ? Number(raw) : 0;\n  return n > 0 ? n : null;\n}\n\n/** Ready messages, each a button that copies it. Nothing opens another site. */\nfunction Share() {\n  const [said, setSaid] = useState(\"\");\n  return (\n    <Reveal className=\"flex flex-col gap-pad-md\">\n      <h2 className={`${TITLE} lg:text-display-4xl`}>{thanks.shareLabel}</h2>\n      <ul className=\"flex flex-col divide-y divide-line-subtle border-y border-line-subtle\">\n        {thanks.shares.map((s) => (\n          <ShareRow key={s.id} title={s.title} message={s.message} onCopied={() => setSaid(thanks.sharedNote(s.title))} />\n        ))}\n      </ul>\n      <p role=\"status\" className=\"sr-only\">\n        {said}\n      </p>\n    </Reveal>\n  );\n}\n\nfunction ShareRow({ title, message, onCopied }: { title: string; message: string; onCopied: () => void }) {\n  const { copied, copy } = useCopy(message, { onCopy: onCopied });\n  return (\n    <li className=\"grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-pad-md gap-y-1 py-pad-base\">\n      <h3 className=\"text-ui-md font-medium text-text\">{title}</h3>\n      <Button size=\"sm\" hitArea aria-label={thanks.copy(title)} onClick={() => void copy()} className=\"row-span-2 min-w-[4.75rem]\">\n        {copied ? thanks.copied : thanks.copyShort}\n      </Button>\n      <p className=\"line-clamp-2 text-ui text-pretty whitespace-pre-line text-text-muted\">{message}</p>\n    </li>\n  );\n}\n\n/** This week's leaderboard as a table, with your row under it: one friend once the credit applies, and the places it gave. */\nfunction Board({ credited, moved }: { credited: boolean; moved: number }) {\n  const { board } = thanks;\n  const cell = \"py-in pe-pad-sm text-ui-md tabular-nums\";\n  return (\n    <Reveal index={1} className=\"flex flex-col gap-pad-md\">\n      <h2 className={`${TITLE} lg:text-display-4xl`}>{board.title}</h2>\n      <table className=\"w-full border-collapse text-left\">\n        <caption className=\"sr-only\">{board.caption}</caption>\n        <thead>\n          <tr className=\"border-b border-line text-ui-sm text-text-muted\">\n            <th scope=\"col\" className=\"w-10 py-in font-normal\">\n              <span className=\"sr-only\">{board.columns.rank}</span>\n            </th>\n            <th scope=\"col\" className=\"py-in font-normal\">\n              {board.columns.name}\n            </th>\n            <th scope=\"col\" className=\"py-in text-right font-normal\">\n              {board.columns.friends}\n            </th>\n            <th scope=\"col\" className=\"py-in text-right font-normal\">\n              {board.columns.moved}\n            </th>\n          </tr>\n        </thead>\n        <tbody>\n          {board.rows.map((r, i) => (\n            <tr key={r.name} className=\"border-b border-line-subtle\">\n              <td className={`${cell} font-mono text-ui-sm text-text-muted`}>{i + 1}</td>\n              <th scope=\"row\" className={`${cell} font-normal text-text`}>\n                {r.name}\n              </th>\n              <td className={`${cell} text-right text-text-secondary`}>{r.friends}</td>\n              <td className={`${cell} pe-0 text-right text-text`}>+{r.moved}</td>\n            </tr>\n          ))}\n        </tbody>\n        <tfoot>\n          <tr className=\"bg-brand-subtle\">\n            <td className={cell} />\n            <th scope=\"row\" className={`${cell} font-medium text-text`}>\n              {board.you}\n            </th>\n            <td className={`${cell} text-right text-text`}>\n              <NumberRoll value={credited ? 1 : 0} />\n            </td>\n            <td className={`${cell} pe-2 text-right text-text`}>\n              <NumberRoll value={moved} formatter={(v) => `+${v}`} />\n            </td>\n          </tr>\n        </tfoot>\n      </table>\n    </Reveal>\n  );\n}\n",
      "type": "registry:component",
      "target": "@components/eased/templates/waitlist/thanks.tsx"
    }
  ],
  "meta": {
    "template": "waitlist",
    "kind": "template-section",
    "industries": [
      "saas"
    ]
  },
  "type": "registry:block"
}