{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pending-choices-tray",
  "title": "Pending Choices Tray",
  "description": "A stack of small decisions waiting on you: answer the top card with a click or a number key, skip it for later, and undo the last one if you change your mind.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/pending-choices-tray/pending-choices-tray.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PendingOption {\n  id: string;\n  label: string;\n  /** Shown as the main button. */\n  primary?: boolean;\n  /** Past tense for the footer, e.g. \"Merged\". */\n  done?: string;\n}\n\nexport interface PendingChoice {\n  id: string;\n  /** A short tag, e.g. \"Duplicate\". */\n  kind: string;\n  question: string;\n  context?: string;\n  /** Short deadline, e.g. \"Due today\". */\n  due?: string;\n  options: PendingOption[];\n}\n\nexport interface PendingChoicesTrayProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  items?: PendingChoice[];\n  emptyTitle?: string;\n  emptyText?: string;\n  onChoose?: (item: PendingChoice, option: PendingOption) => void;\n  onUndo?: (item: PendingChoice) => void;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst ACCENT = \"#5E6AD2\";\nconst GREEN = \"#27A644\";\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst PEEK = 10;\n\nconst PALETTES = {\n  dark: {\n    card: \"#0F1011\",\n    item: \"#161718\",\n    border: \"rgba(255,255,255,0.08)\",\n    edge: \"rgba(255,255,255,0.1)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.06)\",\n    key: \"rgba(255,255,255,0.1)\",\n    track: \"rgba(255,255,255,0.1)\",\n    btn: \"#E5E5E6\",\n    btnText: \"#08090A\",\n    keyOnBtn: \"rgba(8,9,10,0.1)\",\n  },\n  light: {\n    card: \"#FFFFFF\",\n    item: \"#F7F8F8\",\n    border: \"rgba(8,9,10,0.1)\",\n    edge: \"rgba(8,9,10,0.12)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.05)\",\n    key: \"rgba(8,9,10,0.08)\",\n    track: \"rgba(8,9,10,0.1)\",\n    btn: \"#08090A\",\n    btnText: \"#F7F8F8\",\n    keyOnBtn: \"rgba(255,255,255,0.16)\",\n  },\n};\n\nconst DEFAULT_ITEMS: PendingChoice[] = [\n  {\n    id: \"merge\",\n    kind: \"Duplicate\",\n    question: \"Merge these two contacts?\",\n    context: \"Same email and company, created a day apart.\",\n    due: \"Due today\",\n    options: [\n      { id: \"merge\", label: \"Merge\", primary: true, done: \"Merged contacts\" },\n      { id: \"keep\", label: \"Keep both\", done: \"Kept both contacts\" },\n    ],\n  },\n  {\n    id: \"renew\",\n    kind: \"Renewal\",\n    question: \"Renew the design tool for 12 seats?\",\n    context: \"Three seats haven't been used in 60 days.\",\n    due: \"Due Friday\",\n    options: [\n      { id: \"nine\", label: \"Renew 9\", primary: true, done: \"Renewed 9 seats\" },\n      { id: \"twelve\", label: \"Renew 12\", done: \"Renewed 12 seats\" },\n      { id: \"stop\", label: \"Cancel\", done: \"Cancelled the renewal\" },\n    ],\n  },\n  {\n    id: \"date\",\n    kind: \"Schedule\",\n    question: \"Move the launch to 12 March?\",\n    context: \"QA asked for three more days.\",\n    due: \"Due Monday\",\n    options: [\n      { id: \"move\", label: \"Move it\", primary: true, done: \"Moved the launch\" },\n      { id: \"hold\", label: \"Keep the date\", done: \"Kept the date\" },\n    ],\n  },\n  {\n    id: \"access\",\n    kind: \"Access\",\n    question: \"Give Sam billing access for a week?\",\n    context: \"Needed to close the quarter.\",\n    due: \"Due Tuesday\",\n    options: [\n      { id: \"yes\", label: \"Allow\", primary: true, done: \"Allowed billing access\" },\n      { id: \"no\", label: \"Decline\", done: \"Declined billing access\" },\n    ],\n  },\n];\n\n/** Drawn as SVG, because a tiny border-radius circle turns lumpy on 1x screens. */\nfunction Dot({ size, color }: { size: number; color: string }) {\n  const r = size / 2;\n  return (\n    <svg\n      aria-hidden=\"true\"\n      width={size}\n      height={size}\n      viewBox={`0 0 ${size} ${size}`}\n      className=\"block shrink-0\"\n    >\n      <circle cx={r} cy={r} r={r} style={{ fill: color }} />\n    </svg>\n  );\n}\n\ninterface Decision {\n  id: string;\n  done: string;\n}\n\nexport function PendingChoicesTray({\n  theme = \"dark\",\n  title = \"Waiting on you\",\n  items = DEFAULT_ITEMS,\n  emptyTitle = \"All clear\",\n  emptyText = \"Nothing needs a decision right now.\",\n  onChoose,\n  onUndo,\n  className,\n  style,\n  ...rest\n}: PendingChoicesTrayProps) {\n  const c = PALETTES[theme];\n  const [queue, setQueue] = React.useState(() => items.map((i) => i.id));\n  const [history, setHistory] = React.useState<Decision[]>([]);\n  const front = items.find((i) => i.id === queue[0]);\n  const lastDone = history[history.length - 1];\n\n  const choose = (item: PendingChoice, option: PendingOption) => {\n    setQueue((q) => q.filter((id) => id !== item.id));\n    setHistory((h) => [\n      ...h,\n      { id: item.id, done: option.done ?? option.label },\n    ]);\n    onChoose?.(item, option);\n  };\n\n  const skip = () => {\n    setQueue((q) => (q.length > 1 ? [...q.slice(1), q[0]] : q));\n  };\n\n  const undo = () => {\n    if (!lastDone) return;\n    setHistory((h) => h.slice(0, -1));\n    setQueue((q) => [lastDone.id, ...q]);\n    const item = items.find((i) => i.id === lastDone.id);\n    if (item) onUndo?.(item);\n  };\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    if (e.metaKey || e.ctrlKey || e.altKey) return;\n    const pick = front?.options[Number(e.key) - 1];\n    if (front && pick) {\n      e.preventDefault();\n      choose(front, pick);\n    } else if (e.key === \"s\") {\n      skip();\n    } else if (e.key === \"u\") {\n      undo();\n    }\n  };\n\n  return (\n    <section\n      aria-label={title}\n      onKeyDown={onKeyDown}\n      className={`w-full rounded-2xl border ${className ?? \"\"}`}\n      style={{\n        background: c.card,\n        borderColor: c.border,\n        color: c.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...rest}\n    >\n      <header className=\"p-5 pb-4\">\n        <div className=\"flex items-center justify-between gap-3\">\n          <h3 className=\"m-0 text-[16px] leading-[22px] font-[590] tracking-[-0.014em]\">\n            {title}\n          </h3>\n          <span\n            aria-live=\"polite\"\n            className=\"text-[12.5px] leading-[18px] tracking-[-0.008em] tabular-nums\"\n            style={{ color: c.sub }}\n          >\n            {queue.length} of {items.length} left\n          </span>\n        </div>\n        <div aria-hidden=\"true\" className=\"mt-3 flex gap-1\">\n          {items.map((item, i) => (\n            <span\n              key={item.id}\n              className=\"h-1 flex-1 rounded-full motion-safe:transition-colors motion-safe:duration-300\"\n              style={{ background: i < history.length ? ACCENT : c.track }}\n            />\n          ))}\n        </div>\n      </header>\n\n      {/* Every card shares one cell, so the tallest sets the height and nothing jumps. */}\n      <div className=\"grid px-5\" style={{ paddingBottom: PEEK * 2 }}>\n        {items.map((item) => {\n          const depth = queue.indexOf(item.id);\n          const gone = depth < 0;\n          const isFront = depth === 0;\n          return (\n            <article\n              key={item.id}\n              data-choice={item.id}\n              aria-hidden={!isFront}\n              inert={!isFront}\n              className=\"flex origin-bottom flex-col rounded-xl border p-4 [grid-area:1/1] motion-safe:transition-[transform,opacity,visibility] motion-safe:duration-300\"\n              style={{\n                background: c.item,\n                borderColor: c.edge,\n                zIndex: gone ? 20 : 10 - depth,\n                visibility: gone || depth > 2 ? \"hidden\" : \"visible\",\n                opacity: gone ? 0 : 1,\n                transform: gone\n                  ? \"translateY(-14px) scale(1.02)\"\n                  : `translateY(${depth * PEEK}px) scale(${1 - depth * 0.04})`,\n              }}\n            >\n              <div\n                className=\"flex items-center justify-between gap-3 text-[12px] leading-[16px] tracking-[-0.005em]\"\n                style={{ color: c.faint }}\n              >\n                <span>{item.kind}</span>\n                <span>{item.due}</span>\n              </div>\n              <p className=\"m-0 mt-2 text-[15px] leading-[22px] font-[510] tracking-[-0.012em]\">\n                {item.question}\n              </p>\n              <p\n                className=\"m-0 mt-1 text-[13px] leading-[20px] tracking-[-0.011em]\"\n                style={{ color: c.sub }}\n              >\n                {item.context}\n              </p>\n              <div className=\"mt-auto flex flex-wrap gap-2 pt-4\">\n                {item.options.map((option, i) => (\n                  <button\n                    key={option.id}\n                    type=\"button\"\n                    data-option={option.id}\n                    onClick={() => choose(item, option)}\n                    className={`flex h-8 cursor-pointer items-center gap-2 rounded-full border-0 pr-2 pl-3.5 [@media(hover:none)]:pr-3.5 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] ${RING}`}\n                    style={{\n                      background: option.primary ? c.btn : c.chip,\n                      color: option.primary ? c.btnText : c.soft,\n                    }}\n                  >\n                    {option.label}\n                    <kbd\n                      className=\"flex size-5 items-center justify-center rounded-full text-[11px] leading-[14px] font-[510] tabular-nums [@media(hover:none)]:hidden\"\n                      style={{\n                        fontFamily: \"inherit\",\n                        background: option.primary ? c.keyOnBtn : c.key,\n                      }}\n                    >\n                      {i + 1}\n                    </kbd>\n                  </button>\n                ))}\n              </div>\n            </article>\n          );\n        })}\n\n        <div\n          aria-live=\"polite\"\n          className={`flex flex-col items-center justify-center text-center [grid-area:1/1] motion-safe:transition-[opacity,visibility] motion-safe:duration-300 ${queue.length ? \"invisible opacity-0\" : \"visible opacity-100\"}`}\n        >\n          <Dot size={8} color={GREEN} />\n          <p className=\"m-0 mt-3 text-[15px] leading-[22px] font-[510] tracking-[-0.012em]\">\n            {emptyTitle}\n          </p>\n          <p\n            className=\"m-0 mt-0.5 text-[13px] leading-[20px] tracking-[-0.011em]\"\n            style={{ color: c.sub }}\n          >\n            {emptyText}\n          </p>\n        </div>\n      </div>\n\n      <footer\n        className=\"flex h-[52px] items-center justify-between gap-3 border-t px-5\"\n        style={{ borderColor: c.border }}\n      >\n        <p\n          aria-live=\"polite\"\n          className=\"m-0 min-w-0 truncate text-[12.5px] leading-[18px] tracking-[-0.008em]\"\n          style={{ color: c.sub }}\n        >\n          {lastDone ? (\n            lastDone.done\n          ) : (\n            <>\n              <span className=\"[@media(hover:none)]:hidden\">\n                Press a number to choose\n              </span>\n              <span className=\"hidden [@media(hover:none)]:inline\">\n                Pick one to continue\n              </span>\n            </>\n          )}\n        </p>\n        <div className=\"flex shrink-0 gap-1\">\n          <button\n            type=\"button\"\n            onClick={skip}\n            disabled={queue.length < 2}\n            className={`h-7 cursor-pointer rounded-full border-0 bg-transparent px-2.5 text-[12.5px] leading-[18px] font-[510] tracking-[-0.008em] disabled:cursor-default ${RING}`}\n            style={{ color: queue.length < 2 ? c.faint : c.soft }}\n          >\n            Skip\n          </button>\n          <button\n            type=\"button\"\n            data-undo=\"\"\n            onClick={undo}\n            disabled={!lastDone}\n            className={`h-7 cursor-pointer rounded-full border-0 bg-transparent px-2.5 text-[12.5px] leading-[18px] font-[510] tracking-[-0.008em] disabled:cursor-default ${RING}`}\n            style={{ color: lastDone ? c.soft : c.faint }}\n          >\n            Undo\n          </button>\n        </div>\n      </footer>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}