{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "spreadsheet",
  "title": "Spreadsheet",
  "description": "Google Sheetsâ€“style SaaS subscription gridâ€”Account, Plan, MRR, Statusâ€”with trial upgrade edit and Stripe webhook row sync.",
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/new-york/blocks/spreadsheet/page.tsx",
      "content": "import Spreadsheet from \"./components/spreadsheet\"\n\nexport default function Page() {\n  return (\n    <div className=\"px-4 py-4 md:px-6 md:py-6\">\n      <Spreadsheet />\n    </div>\n  )\n}\n",
      "type": "registry:page",
      "target": "app/spreadsheet/page.tsx"
    },
    {
      "path": "registry/new-york/blocks/spreadsheet/components/spreadsheet.tsx",
      "content": "\"use client\"\n\nimport { ChevronDown, Menu, Plus } from \"lucide-react\"\nimport { Instrument_Serif } from \"next/font/google\"\n\nimport { useIsMobile } from \"@/hooks/use-mobile\"\nimport { cn } from \"@/lib/utils\"\n\nconst instrumentSerif = Instrument_Serif({\n  subsets: [\"latin\"],\n  weight: [\"400\"],\n  style: [\"normal\", \"italic\"],\n})\n\nimport { Cursor } from \"./cursor\"\nimport {\n  COLUMN_HEADERS,\n  COMPACT_VISIBLE_COLS,\n  DATA_COLUMN_COUNT,\n  EDIT_CELL,\n  GRID_METRICS_COMPACT,\n  GRID_METRICS_DESKTOP,\n  VISIBLE_COLS,\n  VISIBLE_ROW_COUNT,\n  type RowData,\n} from \"../lib/config\"\nimport { useSpreadsheetAnimation } from \"../hooks/use-spreadsheet-animation\"\n\nimport \"../styles/spreadsheet.css\"\n\nfunction cellValue(\n  dataIdx: number,\n  colIdx: number,\n  rows: readonly RowData[],\n  editDisplay: string,\n  editingThisCell: boolean\n): string {\n  if (colIdx >= DATA_COLUMN_COUNT) return \"\"\n  const row = rows[dataIdx]\n  if (!row) return \"\"\n\n  const values = [\n    row.account,\n    row.price,\n    row.qty,\n    row.marketValue,\n    row.gainLoss,\n  ] as const\n  if (editingThisCell) return editDisplay\n  return values[colIdx] ?? \"\"\n}\n\nexport default function Spreadsheet({ className }: { className?: string }) {\n  const isMobile = useIsMobile()\n  const gridMetrics = isMobile ? GRID_METRICS_COMPACT : GRID_METRICS_DESKTOP\n  const visibleCols = isMobile ? COMPACT_VISIBLE_COLS : VISIBLE_COLS\n\n  const {\n    pressed,\n    isSelected,\n    isEditing,\n    isTsmTyping,\n    tsmShowsSelectionChrome,\n    tsmFocusCol,\n    commitFlash,\n    syncRowVisible,\n    rows,\n    cellRef,\n    formulaPrefix,\n    formulaValue,\n    showFormulaArea,\n    editDisplay,\n    cursorVisible,\n    cursor,\n    activeCol,\n    activeRow,\n  } = useSpreadsheetAnimation(true, isMobile)\n\n  const { rowNumRem, colLetterRowRem, dataRowRem } = gridMetrics\n  const colTemplate = `${rowNumRem}rem repeat(${visibleCols.length}, minmax(0, 1fr))`\n  const rowTemplate = `${colLetterRowRem}rem repeat(${VISIBLE_ROW_COUNT}, ${dataRowRem}rem)`\n  const emptyRowCount = Math.max(0, VISIBLE_ROW_COUNT - 1 - rows.length)\n\n  return (\n    <div\n      className={cn(\n        \"ss-root mx-auto w-full min-w-0 max-w-3xl overflow-hidden rounded-md border border-(--ss-border) bg-(--ss-shell-bg) font-[Arial,Roboto,'Helvetica_Neue',sans-serif] shadow-(--ss-shadow) md:max-w-4xl\",\n        isMobile && \"ss-root--compact\",\n        className\n      )}\n    >\n      <div className=\"flex h-7 shrink-0 items-stretch border-b border-(--ss-formula-border) bg-(--ss-formula-bg) md:h-9\">\n        <div className=\"ss-font-chrome flex w-12 shrink-0 items-center justify-center gap-0.5 border-r border-(--ss-formula-border) px-1 text-(--ss-name-box-fg) md:w-16 md:px-1.5\">\n          <span className=\"tabular-nums\">\n            {showFormulaArea ? cellRef : \" \\u00A0\"}\n          </span>\n          <ChevronDown\n            className=\"size-3.5 shrink-0 text-(--ss-cell-muted)\"\n            aria-hidden\n          />\n        </div>\n        <div\n          className=\"w-px shrink-0 bg-(--ss-formula-border)\"\n          aria-hidden\n        />\n        <span\n          className={cn(\n            instrumentSerif.className,\n            \"flex w-7 shrink-0 items-center justify-center text-xs text-(--ss-fx-fg) italic md:w-8 md:text-sm\"\n          )}\n          aria-hidden\n        >\n          fx\n        </span>\n        <div className=\"ss-font-chrome flex min-w-0 flex-1 items-center truncate px-2 text-(--ss-cell-fg) md:px-2.5\">\n          {showFormulaArea ? (\n            <>\n              {`${formulaPrefix}${formulaValue}`}\n              {isEditing || isTsmTyping ? (\n                <span\n                  className=\"ss-caret ml-px inline-block h-[0.9em] w-px translate-y-px bg-(--ss-caret) align-text-bottom\"\n                  aria-hidden\n                />\n              ) : null}\n            </>\n          ) : null}\n        </div>\n      </div>\n\n      <div className=\"bg-(--ss-grid-bg)\">\n        <div className=\"ss-grid-body relative overflow-hidden [&::-webkit-scrollbar]:hidden\">\n          <div\n            className=\"ss-grid grid w-full\"\n            style={{\n              gridTemplateColumns: colTemplate,\n              gridTemplateRows: rowTemplate,\n            }}\n          >\n            <div\n              className=\"border-r border-b border-(--ss-grid-line) bg-(--ss-header-bg)\"\n              aria-hidden\n            />\n\n            {visibleCols.map((letter, colIdx) => (\n              <div\n                key={letter}\n                className={cn(\n                  \"ss-font-chrome flex items-center justify-center border-r border-b border-(--ss-grid-line) bg-(--ss-header-bg) text-(--ss-header-fg) select-none\",\n                  activeCol === colIdx &&\n                    \"bg-(--ss-header-active) text-(--ss-name-box-fg)\"\n                )}\n              >\n                {letter}\n              </div>\n            ))}\n\n            <div className=\"contents\">\n              <div className=\"ss-font-chrome flex items-center justify-center border-r border-b border-(--ss-grid-line) bg-(--ss-header-bg) text-(--ss-header-fg) select-none\">\n                1\n              </div>\n              {visibleCols.map((letter, colIdx) => (\n                <div\n                  key={`hdr-${letter}`}\n                  className={cn(\n                    \"ss-cell-inner flex h-full items-center border-r border-b border-(--ss-grid-line) bg-(--ss-header-bg) px-1.5 font-semibold text-(--ss-name-box-fg)\",\n                    colIdx < DATA_COLUMN_COUNT\n                      ? \"ss-font-col-hdr whitespace-nowrap\"\n                      : \"ss-font-chrome overflow-hidden\",\n                    (colIdx === 1 ||\n                      colIdx === 2 ||\n                      colIdx === 3 ||\n                      colIdx === 4) &&\n                      \"justify-end tabular-nums\"\n                  )}\n                >\n                  {COLUMN_HEADERS[colIdx] ?? \"\"}\n                </div>\n              ))}\n            </div>\n\n            {rows.map((row, dataIdx) => {\n              const sheetRow = dataIdx + 2\n              const isSyncRow = syncRowVisible && row.id === \"r4\"\n\n              return (\n                <div key={row.id} className=\"contents\">\n                  <div\n                    className={cn(\n                      \"ss-font-chrome flex items-center justify-center border-r border-b border-(--ss-grid-line) bg-(--ss-header-bg) text-(--ss-header-fg) select-none\",\n                      activeRow === dataIdx &&\n                        \"bg-(--ss-header-active) text-(--ss-name-box-fg)\"\n                    )}\n                  >\n                    {sheetRow}\n                  </div>\n\n                  {visibleCols.map((letter, colIdx) => {\n                    const selected =\n                      isSelected &&\n                      dataIdx === EDIT_CELL.row &&\n                      colIdx === EDIT_CELL.col\n                    const editingThisCell = Boolean(isEditing && selected)\n                    const isTsmSelectedCell =\n                      tsmShowsSelectionChrome &&\n                      isSyncRow &&\n                      tsmFocusCol !== null &&\n                      colIdx === tsmFocusCol\n                    const raw = cellValue(\n                      dataIdx,\n                      colIdx,\n                      rows,\n                      editDisplay,\n                      editingThisCell\n                    )\n                    const display =\n                      raw && (colIdx === 1 || colIdx === 3) ? `$${raw}` : raw\n\n                    return (\n                      <div\n                        key={`${row.id}-${letter}`}\n                        className={cn(\n                          \"relative h-full min-h-0 min-w-0\",\n                          selected && commitFlash && \"ss-cell--commit-flash\"\n                        )}\n                      >\n                        <div\n                          className={cn(\n                            \"ss-cell-inner flex h-full items-center border-r border-b border-(--ss-grid-line) bg-(--ss-grid-bg) px-1.5 text-(--ss-cell-fg)\",\n                            colIdx < DATA_COLUMN_COUNT\n                              ? \"ss-font-data whitespace-nowrap\"\n                              : \"ss-font-chrome overflow-hidden\",\n                            (colIdx === 1 ||\n                              colIdx === 2 ||\n                              colIdx === 3 ||\n                              colIdx === 4) &&\n                              \"justify-end tabular-nums\",\n                            colIdx === 4 &&\n                              raw.startsWith(\"+\") &&\n                              \"text-green-600 dark:text-green-400\",\n                            colIdx === 4 &&\n                              raw.startsWith(\"-\") &&\n                              \"text-red-600 dark:text-red-400\"\n                          )}\n                        >\n                          {display}\n                        </div>\n                        {selected ? (\n                          <>\n                            <div\n                              className=\"pointer-events-none absolute inset-0 z-2 -m-px border-2 border-(--ss-selection)\"\n                              aria-hidden\n                            />\n                            <div\n                              className=\"pointer-events-none absolute -right-1.5 -bottom-1.5 z-3 size-2 border border-(--ss-selection-fill) bg-(--ss-selection)\"\n                              aria-hidden\n                            />\n                          </>\n                        ) : null}\n                        {isTsmSelectedCell ? (\n                          <>\n                            <div\n                              className=\"pointer-events-none absolute inset-0 z-2 -m-px border-2 border-(--ss-selection)\"\n                              aria-hidden\n                            />\n                            <div\n                              className=\"pointer-events-none absolute -right-1.5 -bottom-1.5 z-3 size-2 border border-(--ss-selection-fill) bg-(--ss-selection)\"\n                              aria-hidden\n                            />\n                          </>\n                        ) : null}\n                      </div>\n                    )\n                  })}\n                </div>\n              )\n            })}\n\n            {Array.from({ length: emptyRowCount }, (_, i) => {\n              const sheetRow = rows.length + 2 + i\n              return (\n                <div key={`empty-${sheetRow}`} className=\"contents\">\n                  <div className=\"ss-font-chrome flex items-center justify-center border-r border-b border-(--ss-grid-line) bg-(--ss-header-bg) text-(--ss-header-fg) select-none\">\n                    {sheetRow}\n                  </div>\n                  {visibleCols.map((letter, colIdx) => (\n                    <div\n                      key={`${sheetRow}-${letter}`}\n                      className={cn(\n                        \"ss-cell-inner flex h-full items-center border-r border-b border-(--ss-grid-line) bg-(--ss-grid-bg) px-1.5 text-(--ss-cell-fg)\",\n                        colIdx < DATA_COLUMN_COUNT\n                          ? \"ss-font-data\"\n                          : \"ss-font-chrome overflow-hidden\"\n                      )}\n                    />\n                  ))}\n                </div>\n              )\n            })}\n          </div>\n\n          {cursorVisible ? (\n            <Cursor\n              x={cursor.x}\n              y={cursor.y}\n              pressed={pressed}\n              yNudgeRem={cursor.yNudgeRem ?? 0}\n              rowHeightRem={dataRowRem}\n            />\n          ) : null}\n        </div>\n      </div>\n\n      <div\n        className=\"flex h-7 shrink-0 items-center gap-1 border-t border-(--ss-sheet-bar-border) bg-(--ss-sheet-bar-bg) px-1 md:h-9 md:px-1.5\"\n        role=\"toolbar\"\n        aria-label=\"Sheet tabs\"\n      >\n        <button\n          type=\"button\"\n          className=\"flex size-7 shrink-0 cursor-default items-center justify-center rounded-[2px] border-none bg-transparent text-(--ss-sheet-bar-icon)\"\n          aria-label=\"Add sheet\"\n        >\n          <Plus className=\"size-4\" strokeWidth={2} aria-hidden />\n        </button>\n        <button\n          type=\"button\"\n          className=\"flex size-7 shrink-0 cursor-default items-center justify-center rounded-[2px] border-none bg-transparent text-(--ss-sheet-bar-icon)\"\n          aria-label=\"All sheets\"\n        >\n          <Menu className=\"size-4\" strokeWidth={2} aria-hidden />\n        </button>\n        <button\n          type=\"button\"\n          className=\"ss-font-tab flex h-7 cursor-default items-center gap-1 rounded-t-[2px] rounded-b-none border-none bg-(--ss-sheet-tab-bg) py-0 pr-2.5 pl-3 font-semibold whitespace-nowrap text-(--ss-sheet-tab-fg)\"\n          aria-current=\"page\"\n        >\n          <span>Positions</span>\n          <ChevronDown\n            className=\"size-3.5 shrink-0 text-(--ss-sheet-tab-fg)\"\n            aria-hidden\n          />\n        </button>\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "app/spreadsheet/components/spreadsheet.tsx"
    },
    {
      "path": "registry/new-york/blocks/spreadsheet/components/cursor.tsx",
      "content": "\"use client\"\n\nimport { MousePointer2 } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport { GRID_DATA_ROW_REM } from \"../lib/config\"\n\ntype CursorProps = {\n  x: number\n  y: number\n  pressed?: boolean\n  /** Extra downward offset on top of half-row centering. */\n  yNudgeRem?: number\n  /** Data row track height — matches `gridTemplateRows` on compact layouts. */\n  rowHeightRem?: number\n  className?: string\n}\n\nexport function Cursor({\n  x,\n  y,\n  pressed,\n  yNudgeRem = 0,\n  rowHeightRem = GRID_DATA_ROW_REM,\n  className,\n}: CursorProps) {\n  const rowCenterRem = rowHeightRem / 2 + yNudgeRem\n\n  return (\n    <MousePointer2\n      aria-hidden\n      strokeWidth={2}\n      className={cn(\n        \"pointer-events-none absolute z-20 size-5\",\n        \"fill-foreground stroke-background text-foreground\",\n        \"[paint-order:stroke_fill]\",\n        \"motion-safe:transition-[left,top,transform] motion-safe:duration-500 motion-safe:ease-out\",\n        className\n      )}\n      style={{\n        left: `${x}%`,\n        /* y = row top %; rem offset lands tip on row midpoint (+ optional nudge) */\n        top: `calc(${y}% + ${rowCenterRem}rem)`,\n        transform: `translate(-2px, -2px)${pressed ? \" scale(0.92)\" : \"\"}`,\n      }}\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "app/spreadsheet/components/cursor.tsx"
    },
    {
      "path": "registry/new-york/blocks/spreadsheet/hooks/use-spreadsheet-animation.ts",
      "content": "\"use client\"\n\nimport { useEffect, useState } from \"react\"\n\nimport {\n  EDIT_CELL,\n  EDIT_FROM,\n  EDIT_TO,\n  EMPTY_TSM_ROW,\n  GRID_METRICS_COMPACT,\n  GRID_METRICS_DESKTOP,\n  INITIAL_ROWS,\n  PHASE_NEXT_MAP,\n  SYNC_ROW,\n  TIMING,\n  TSM_DATA_ROW_INDEX,\n  TSM_GL_FORMULA,\n  TSM_MKT_FORMULA,\n  VISIBLE_COLS,\n  getSpreadsheetCursors,\n  isTsmFormulaTypingPhase,\n  isTsmTypingPhase,\n  tsmPhaseColumn,\n  tsmShowsCellChrome,\n  tsmShowsFormula,\n  type RowData,\n  type SpreadsheetCursorPoint,\n  type SpreadsheetPhase,\n} from \"../lib/config\"\n\nconst TSM_VALUE_KEYS = [\"account\", \"price\", \"qty\"] as const\n\n/** Matches TIMING field cadence in config (`TSM_CHAR_MS`). */\nconst TSM_CHAR_MS = 132\n\nfunction parseUsd(s: string): number {\n  return Number.parseFloat(s.replace(/,/g, \"\"))\n}\n\nfunction parsePctSigned(s: string): number {\n  return Number.parseFloat(s.trim().replace(/%/g, \"\")) / 100\n}\n\nfunction formatUsdMv(priceStr: string, qtyStr: string): string {\n  const mv = Number.parseFloat(priceStr) * Number.parseInt(qtyStr, 10)\n  return mv.toLocaleString(\"en-US\", {\n    minimumFractionDigits: 2,\n    maximumFractionDigits: 2,\n  })\n}\n\nfunction formatGainLossPct(decimal: number): string {\n  const pct = decimal * 100\n  const sign = pct >= 0 ? \"+\" : \"\"\n  return `${sign}${pct.toFixed(1)}%`\n}\n\nexport function useSpreadsheetAnimation(active = true, compact = false) {\n  const gridMetrics = compact ? GRID_METRICS_COMPACT : GRID_METRICS_DESKTOP\n  const spreadsheetCursor = getSpreadsheetCursors(gridMetrics)\n  const [phase, setPhase] = useState<SpreadsheetPhase>(\"setup\")\n  const [typed, setTyped] = useState(0)\n  const [pressed, setPressed] = useState(false)\n  const [commitFlash, setCommitFlash] = useState(false)\n  const [tsmDraft, setTsmDraft] = useState<RowData>(() => ({\n    ...EMPTY_TSM_ROW,\n  }))\n  const [tsmFormulaTyping, setTsmFormulaTyping] = useState(\"\")\n\n  useEffect(() => {\n    if (!active) {\n      setPhase(\"setup\")\n      return\n    }\n    const t = setTimeout(() => setPhase(PHASE_NEXT_MAP[phase]), TIMING[phase])\n    return () => clearTimeout(t)\n  }, [active, phase])\n\n  useEffect(() => {\n    if (!active) return\n\n    if (phase === \"setup\" || phase === \"resetting\") {\n      setTyped(0)\n      setPressed(false)\n      setCommitFlash(false)\n      setTsmDraft({ ...EMPTY_TSM_ROW })\n      setTsmFormulaTyping(\"\")\n      return\n    }\n\n    if (phase === \"tsmPrep\") {\n      setTyped(EDIT_TO.length)\n      setTsmDraft({ ...EMPTY_TSM_ROW })\n      setTsmFormulaTyping(\"\")\n      return\n    }\n\n    if (phase === \"select\") {\n      setPressed(true)\n      const t = setTimeout(() => setPressed(false), 180)\n      return () => clearTimeout(t)\n    }\n\n    if (phase === \"typing\") {\n      setTyped(0)\n      const timers: ReturnType<typeof setTimeout>[] = []\n      for (let i = 1; i <= EDIT_TO.length; i++) {\n        timers.push(setTimeout(() => setTyped(i), 120 + i * 165))\n      }\n      return () => timers.forEach(clearTimeout)\n    }\n\n    if (phase === \"commit\") {\n      setTyped(EDIT_TO.length)\n      setCommitFlash(true)\n      const t = setTimeout(() => setCommitFlash(false), 480)\n      return () => clearTimeout(t)\n    }\n\n    if (phase === \"tsmType0\" || phase === \"tsmType1\" || phase === \"tsmType2\") {\n      setTyped(EDIT_TO.length)\n      setPressed(true)\n      const unpress = setTimeout(() => setPressed(false), 180)\n      setTsmFormulaTyping(\"\")\n\n      const colMap: Partial<Record<SpreadsheetPhase, number>> = {\n        tsmType0: 0,\n        tsmType1: 1,\n        tsmType2: 2,\n      }\n      const col = colMap[phase] ?? 0\n      const key = TSM_VALUE_KEYS[col]\n      const target = SYNC_ROW[key]\n      const timers: ReturnType<typeof setTimeout>[] = []\n      for (let i = 1; i <= target.length; i++) {\n        timers.push(\n          setTimeout(() => {\n            setTsmDraft((d) => ({\n              ...d,\n              [key]: target.slice(0, i),\n            }))\n          }, 155 + i * TSM_CHAR_MS),\n        )\n      }\n      return () => {\n        clearTimeout(unpress)\n        timers.forEach(clearTimeout)\n      }\n    }\n\n    if (phase === \"tsmType3\") {\n      setTyped(EDIT_TO.length)\n      setPressed(true)\n      const unpress = setTimeout(() => setPressed(false), 180)\n      setTsmFormulaTyping(\"\")\n      const target = TSM_MKT_FORMULA\n      const timers: ReturnType<typeof setTimeout>[] = []\n      for (let i = 1; i <= target.length; i++) {\n        timers.push(\n          setTimeout(() => {\n            setTsmFormulaTyping(target.slice(0, i))\n          }, 155 + i * TSM_CHAR_MS),\n        )\n      }\n      const finalize = setTimeout(() => {\n        setTsmDraft((d) => ({\n          ...d,\n          marketValue: SYNC_ROW.marketValue,\n        }))\n        setTsmFormulaTyping(target)\n      }, 155 + target.length * TSM_CHAR_MS + 40)\n      return () => {\n        clearTimeout(unpress)\n        timers.forEach(clearTimeout)\n        clearTimeout(finalize)\n      }\n    }\n\n    if (phase === \"tsmType4\") {\n      setTyped(EDIT_TO.length)\n      setPressed(true)\n      const unpress = setTimeout(() => setPressed(false), 180)\n      setTsmFormulaTyping(\"\")\n      const target = TSM_GL_FORMULA\n      const timers: ReturnType<typeof setTimeout>[] = []\n      for (let i = 1; i <= target.length; i++) {\n        timers.push(\n          setTimeout(() => {\n            setTsmFormulaTyping(target.slice(0, i))\n          }, 155 + i * TSM_CHAR_MS),\n        )\n      }\n      const finalize = setTimeout(() => {\n        setTsmDraft((d) => ({\n          ...d,\n          gainLoss: SYNC_ROW.gainLoss,\n        }))\n        setTsmFormulaTyping(target)\n      }, 155 + target.length * TSM_CHAR_MS + 40)\n      return () => {\n        clearTimeout(unpress)\n        timers.forEach(clearTimeout)\n        clearTimeout(finalize)\n      }\n    }\n\n    if (\n      phase === \"tsmMove0\" ||\n      phase === \"tsmMove1\" ||\n      phase === \"tsmMove2\" ||\n      phase === \"tsmMove3\" ||\n      phase === \"tsmMove4\"\n    ) {\n      setTyped(EDIT_TO.length)\n      if (phase === \"tsmMove4\") {\n        setTsmFormulaTyping(\"\")\n      }\n      return\n    }\n\n    if (phase === \"holding\") {\n      setTyped(EDIT_TO.length)\n      setTsmFormulaTyping(\"\")\n      setTsmDraft({ ...SYNC_ROW })\n    }\n  }, [active, phase])\n\n  const isEditing = phase === \"typing\" || phase === \"commit\"\n\n  const isSelected = phase === \"select\" || phase === \"typing\" || phase === \"commit\"\n\n  const isTsmTyping = isTsmTypingPhase(phase)\n\n  const editCommitted =\n    phase === \"commit\" ||\n    (phase.startsWith(\"tsm\") && phase !== \"resetting\") ||\n    phase === \"holding\"\n\n  const editDisplay = isEditing ? EDIT_TO.slice(0, typed) : EDIT_FROM\n\n  const baseRows = INITIAL_ROWS.map((row, i) => {\n    if (i !== EDIT_CELL.row) return row\n    if (!editCommitted) return row\n    const impliedCost =\n      parseUsd(row.marketValue) / (1 + parsePctSigned(row.gainLoss))\n    const newMvNum = Number.parseFloat(EDIT_TO) * Number.parseInt(row.qty, 10)\n    return {\n      ...row,\n      price: EDIT_TO,\n      marketValue: formatUsdMv(EDIT_TO, row.qty),\n      gainLoss: formatGainLossPct((newMvNum - impliedCost) / impliedCost),\n    }\n  })\n\n  const syncRowVisible =\n    phase === \"tsmPrep\" ||\n    phase.startsWith(\"tsmMove\") ||\n    phase.startsWith(\"tsmType\") ||\n    phase === \"holding\"\n\n  const rows = syncRowVisible ? [...baseRows, tsmDraft] : baseRows\n\n  const tsmCol = tsmPhaseColumn(phase)\n\n  let cellRef: string\n  let formulaPrefix: string\n  let formulaValue: string\n\n  if (tsmShowsFormula(phase)) {\n    const sheetRow = TSM_DATA_ROW_INDEX + 2\n    const col =\n      phase === \"tsmPrep\" ? 0 : tsmCol !== null ? tsmCol : 0\n    cellRef = `${VISIBLE_COLS[col]}${sheetRow}`\n    const movePhase =\n      phase === \"tsmMove0\" ||\n      phase === \"tsmMove1\" ||\n      phase === \"tsmMove2\" ||\n      phase === \"tsmMove3\" ||\n      phase === \"tsmMove4\"\n\n    if (isTsmFormulaTypingPhase(phase)) {\n      formulaPrefix = \"\"\n      formulaValue = tsmFormulaTyping\n    } else {\n      const draftVals = [\n        tsmDraft.account,\n        tsmDraft.price,\n        tsmDraft.qty,\n        tsmDraft.marketValue,\n        tsmDraft.gainLoss,\n      ] as const\n      formulaPrefix = col === 1 ? \"$\" : \"\"\n      formulaValue =\n        phase === \"tsmPrep\" || movePhase ? \"\" : draftVals[col] ?? \"\"\n    }\n  } else {\n    cellRef = `${VISIBLE_COLS[EDIT_CELL.col]}${EDIT_CELL.row + 2}`\n    formulaPrefix = \"$\"\n    formulaValue = isEditing ? editDisplay : EDIT_FROM\n  }\n\n  const showFormulaArea =\n    isSelected || isEditing || tsmShowsFormula(phase)\n\n  const cursorVisible =\n    phase === \"cursorMove\" ||\n    phase === \"select\" ||\n    phase === \"typing\" ||\n    phase === \"commit\" ||\n    phase === \"tsmPrep\" ||\n    phase.startsWith(\"tsmMove\") ||\n    phase.startsWith(\"tsmType\")\n\n  const cursor: SpreadsheetCursorPoint = (() => {\n    if (phase === \"cursorMove\") return spreadsheetCursor.approach\n    if (phase === \"tsmPrep\") return spreadsheetCursor.intelPrep\n    if (tsmCol !== null) return spreadsheetCursor.tsmByCol[tsmCol]\n    return spreadsheetCursor.cell\n  })()\n\n  let activeCol: number\n  let activeRow: number\n\n  if (tsmShowsCellChrome(phase) && tsmCol !== null) {\n    activeCol = tsmCol\n    activeRow = TSM_DATA_ROW_INDEX\n  } else if (isSelected) {\n    activeCol = EDIT_CELL.col\n    activeRow = EDIT_CELL.row\n  } else {\n    activeCol = -1\n    activeRow = -1\n  }\n\n  return {\n    phase,\n    pressed,\n    isSelected,\n    isEditing,\n    isTsmTyping,\n    commitFlash,\n    syncRowVisible,\n    tsmShowsSelectionChrome: tsmShowsCellChrome(phase),\n    rows,\n    cellRef,\n    formulaPrefix,\n    formulaValue,\n    showFormulaArea,\n    editDisplay,\n    cursorVisible,\n    cursor,\n    activeCol,\n    activeRow,\n    tsmFocusCol: tsmCol,\n  }\n}\n",
      "type": "registry:hook",
      "target": "app/spreadsheet/hooks/use-spreadsheet-animation.ts"
    },
    {
      "path": "registry/new-york/blocks/spreadsheet/lib/config.ts",
      "content": "/**\n * Spreadsheet animation — semiconductor positions:\n * revise Intel price target → add TSM row (typed inputs + Excel-style formulas for value & return).\n */\n\nexport type SpreadsheetPhase =\n  | \"setup\"\n  | \"cursorMove\"\n  | \"select\"\n  | \"typing\"\n  | \"commit\"\n  | \"tsmPrep\"\n  | \"tsmMove0\"\n  | \"tsmType0\"\n  | \"tsmMove1\"\n  | \"tsmType1\"\n  | \"tsmMove2\"\n  | \"tsmType2\"\n  | \"tsmMove3\"\n  | \"tsmType3\"\n  | \"tsmMove4\"\n  | \"tsmType4\"\n  | \"holding\"\n  | \"resetting\"\n\nconst PHASE_NEXT: Record<SpreadsheetPhase, SpreadsheetPhase> = {\n  setup: \"cursorMove\",\n  cursorMove: \"select\",\n  select: \"typing\",\n  typing: \"commit\",\n  commit: \"tsmPrep\",\n  tsmPrep: \"tsmMove0\",\n  tsmMove0: \"tsmType0\",\n  tsmType0: \"tsmMove1\",\n  tsmMove1: \"tsmType1\",\n  tsmType1: \"tsmMove2\",\n  tsmMove2: \"tsmType2\",\n  tsmType2: \"tsmMove3\",\n  tsmMove3: \"tsmType3\",\n  tsmType3: \"tsmMove4\",\n  tsmMove4: \"tsmType4\",\n  tsmType4: \"holding\",\n  holding: \"resetting\",\n  resetting: \"setup\",\n}\n\nexport const PHASE_NEXT_MAP = PHASE_NEXT\n\n/** Character cadence + padding so phase timers outlive typing timers. */\nconst TSM_CHAR_MS = 132\nconst TSM_TYPE_PAD = 360\n\n/** Visible data columns A–E; F–H stay blank in the mock. */\nexport const DATA_COLUMN_COUNT = 5 as const\n\n/** Row shape — TSM row uses Excel row 5 in formulas (`B5`, `C5`, `D5`). */\nexport type RowData = {\n  id: string\n  account: string\n  price: string\n  qty: string\n  marketValue: string\n  gainLoss: string\n}\n\n/** 0-based Intel row — price cell edited before TSM sync. */\nexport const EDIT_CELL = { row: 2, col: 1 }\n\n/** Prior print → today’s price (Illustrative — align with `INITIAL_ROWS` INTC row.) */\nexport const EDIT_FROM = \"107.95\"\nexport const EDIT_TO = \"108.77\"\n\n/**\n * Early/core: NVDA, INTC — larger % vs average cost.\n * Later tranches: AMD (underwater top-up), then TSM row (new starter line).\n */\nexport const INITIAL_ROWS: readonly RowData[] = [\n  {\n    id: \"r1\",\n    account: \"NVDA\",\n    price: \"225.32\",\n    qty: \"38\",\n    marketValue: \"8,562.16\",\n    gainLoss: \"+245.3%\",\n  },\n  {\n    id: \"r2\",\n    account: \"AMD\",\n    price: \"424.10\",\n    qty: \"12\",\n    marketValue: \"5,089.20\",\n    gainLoss: \"-7.8%\",\n  },\n  {\n    id: \"r3\",\n    account: \"INTC\",\n    price: EDIT_FROM,\n    qty: \"85\",\n    marketValue: \"9,175.75\",\n    gainLoss: \"+52.1%\",\n  },\n]\n\n/** Newer TSM line — shares typed; value & % from formulas vs cost. */\nexport const SYNC_ROW: RowData = {\n  id: \"r4\",\n  account: \"TSM\",\n  price: \"404.35\",\n  qty: \"9\",\n  marketValue: \"3,639.15\",\n  gainLoss: \"+6.4%\",\n}\n\nexport const TSM_MKT_FORMULA = \"=B5*C5\" as const\n/** Cost basis $3,420 — later buy; ~+6.4% vs `D5` at `404.35` × 9 shares. */\nexport const TSM_GL_FORMULA = \"=(D5-3420)/3420\" as const\n\nfunction tsmValueTypeMs(len: number): number {\n  return 170 + len * TSM_CHAR_MS + TSM_TYPE_PAD\n}\n\nfunction tsmFormulaTypeMs(formula: string): number {\n  return 170 + formula.length * TSM_CHAR_MS + TSM_TYPE_PAD\n}\n\nexport const TIMING: Record<SpreadsheetPhase, number> = {\n  setup: 700,\n  cursorMove: 900,\n  select: 400,\n  typing: 1400,\n  commit: 600,\n  tsmPrep: 400,\n  tsmMove0: 660,\n  tsmType0: tsmValueTypeMs(SYNC_ROW.account.length),\n  tsmMove1: 640,\n  tsmType1: tsmValueTypeMs(SYNC_ROW.price.length),\n  tsmMove2: 620,\n  tsmType2: tsmValueTypeMs(SYNC_ROW.qty.length),\n  tsmMove3: 620,\n  tsmType3: tsmFormulaTypeMs(TSM_MKT_FORMULA),\n  tsmMove4: 620,\n  tsmType4: tsmFormulaTypeMs(TSM_GL_FORMULA),\n  holding: 3000,\n  resetting: 400,\n}\n\nexport const VISIBLE_COLS = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\"] as const\n/** Data columns only — used on narrow viewports (F–H stay blank on desktop). */\nexport const COMPACT_VISIBLE_COLS = VISIBLE_COLS.slice(0, DATA_COLUMN_COUNT)\nexport const VISIBLE_ROW_COUNT = 8\n\nexport type SpreadsheetGridMetrics = {\n  dataColCount: number\n  rowNumRem: number\n  colLetterRowRem: number\n  sheetHeaderRowRem: number\n  dataRowRem: number\n}\n\nexport const GRID_METRICS_DESKTOP: SpreadsheetGridMetrics = {\n  dataColCount: VISIBLE_COLS.length,\n  rowNumRem: 2.5,\n  colLetterRowRem: 2.25,\n  sheetHeaderRowRem: 2,\n  dataRowRem: 2,\n}\n\nexport const GRID_METRICS_COMPACT: SpreadsheetGridMetrics = {\n  dataColCount: DATA_COLUMN_COUNT,\n  rowNumRem: 1.75,\n  colLetterRowRem: 1.5,\n  sheetHeaderRowRem: 1.5,\n  dataRowRem: 1.375,\n}\n\n/** Column labels rendered in sheet row 1 (A–E); F–H blank in UI. */\nexport const COLUMN_HEADERS = [\n  \"Symbol\",\n  \"Price\",\n  \"Quantity\",\n  \"Market value\",\n  \"Gain/Loss\",\n] as const\n\n/** Appended sync row index in `rows` when visible (sheet row = index + 2). */\nexport const TSM_DATA_ROW_INDEX = 3\n\n/** Empty placeholders until each cell is filled. */\nexport const EMPTY_TSM_ROW: RowData = {\n  id: \"r4\",\n  account: \"\",\n  price: \"\",\n  qty: \"\",\n  marketValue: \"\",\n  gainLoss: \"\",\n}\n\n/** `max-w-4xl` sheet width — keeps cursor anchors aligned at default block size. */\nconst GRID_REF_WIDTH_REM = 56\n\n/** Horizontal center of a 0-based data column as % of the grid overlay width. */\nexport function gridColumnCenterPercent(\n  colIdx: number,\n  metrics: SpreadsheetGridMetrics = GRID_METRICS_DESKTOP\n): number {\n  const { dataColCount, rowNumRem } = metrics\n  const flexCol = (GRID_REF_WIDTH_REM - rowNumRem) / dataColCount\n  const centerRem = rowNumRem + colIdx * flexCol + flexCol / 2\n  return Math.round((centerRem / GRID_REF_WIDTH_REM) * 100)\n}\n\n/** Matches default desktop `gridTemplateRows` data tracks in spreadsheet.tsx. */\nexport const GRID_DATA_ROW_REM = GRID_METRICS_DESKTOP.dataRowRem\n\n/** Extra downward tip nudge on the TSM row (reads high vs Intel row). */\nexport const TSM_CURSOR_Y_NUDGE_REM = 0.5\n\n/** Vertical top of a 0-based data row as % of the grid overlay height. */\nexport function gridDataRowTopPercent(\n  dataRowIdx: number,\n  metrics: SpreadsheetGridMetrics = GRID_METRICS_DESKTOP\n): number {\n  const { colLetterRowRem, sheetHeaderRowRem, dataRowRem } = metrics\n  const totalRem =\n    colLetterRowRem +\n    sheetHeaderRowRem +\n    VISIBLE_ROW_COUNT * dataRowRem\n  const topRem =\n    colLetterRowRem + sheetHeaderRowRem + dataRowIdx * dataRowRem\n  return Math.round((topRem / totalRem) * 100)\n}\n\nexport type SpreadsheetCursorPoint = {\n  x: number\n  y: number\n  /** Added to half-row centering in cursor.tsx (`rem`). */\n  yNudgeRem?: number\n}\n\n/** Cursor anchors for the animated pointer — recomputed when column layout changes. */\nexport function getSpreadsheetCursors(\n  metrics: SpreadsheetGridMetrics = GRID_METRICS_DESKTOP\n) {\n  const tsmRowY = gridDataRowTopPercent(TSM_DATA_ROW_INDEX, metrics)\n  const editRowY = gridDataRowTopPercent(EDIT_CELL.row, metrics)\n  const yNudge =\n    metrics === GRID_METRICS_COMPACT ? TSM_CURSOR_Y_NUDGE_REM * 0.6 : TSM_CURSOR_Y_NUDGE_REM\n\n  const tsmByCol: SpreadsheetCursorPoint[] = Array.from(\n    { length: DATA_COLUMN_COUNT },\n    (_, colIdx) => ({\n      x: gridColumnCenterPercent(colIdx, metrics),\n      y: tsmRowY,\n      yNudgeRem: yNudge,\n    })\n  )\n\n  return {\n    approach: { x: 26, y: Math.max(editRowY - 8, 10) },\n    cell: {\n      x: gridColumnCenterPercent(EDIT_CELL.col, metrics),\n      y: editRowY,\n    },\n    intelPrep: {\n      x: gridColumnCenterPercent(4, metrics),\n      y: editRowY,\n    },\n    tsmByCol,\n  }\n}\n\n/** 0-based column during TSM move/type phases (null during prep / non-TSM). */\nexport function tsmPhaseColumn(phase: SpreadsheetPhase): number | null {\n  const map: Partial<Record<SpreadsheetPhase, number>> = {\n    tsmMove0: 0,\n    tsmType0: 0,\n    tsmMove1: 1,\n    tsmType1: 1,\n    tsmMove2: 2,\n    tsmType2: 2,\n    tsmMove3: 3,\n    tsmType3: 3,\n    tsmMove4: 4,\n    tsmType4: 4,\n  }\n  return map[phase] ?? null\n}\n\nexport function isTsmTypingPhase(phase: SpreadsheetPhase): boolean {\n  return (\n    phase === \"tsmType0\" ||\n    phase === \"tsmType1\" ||\n    phase === \"tsmType2\" ||\n    phase === \"tsmType3\" ||\n    phase === \"tsmType4\"\n  )\n}\n\n/** True while a formula is being “typed” in the formula bar (mkt / G·L columns). */\nexport function isTsmFormulaTypingPhase(phase: SpreadsheetPhase): boolean {\n  return phase === \"tsmType3\" || phase === \"tsmType4\"\n}\n\n/** Selection chrome on the active TSM cell (move + type). */\nexport function tsmShowsCellChrome(phase: SpreadsheetPhase): boolean {\n  return tsmPhaseColumn(phase) !== null\n}\n\n/** Formula bar reflects TSM activity (prep shows destination A5 empty). */\nexport function tsmShowsFormula(phase: SpreadsheetPhase): boolean {\n  return (\n    phase === \"tsmPrep\" ||\n    phase === \"tsmMove0\" ||\n    phase === \"tsmType0\" ||\n    phase === \"tsmMove1\" ||\n    phase === \"tsmType1\" ||\n    phase === \"tsmMove2\" ||\n    phase === \"tsmType2\" ||\n    phase === \"tsmMove3\" ||\n    phase === \"tsmType3\" ||\n    phase === \"tsmMove4\" ||\n    phase === \"tsmType4\"\n  )\n}\n\n/** Desktop cursor layout (default export for static references). */\nexport const SPREADSHEET_CURSOR = getSpreadsheetCursors(GRID_METRICS_DESKTOP)\nexport const TSM_CURSOR_BY_COL = SPREADSHEET_CURSOR.tsmByCol\n",
      "type": "registry:lib",
      "target": "app/spreadsheet/lib/config.ts"
    },
    {
      "path": "registry/new-york/blocks/spreadsheet/styles/spreadsheet.css",
      "content": "/* spreadsheet — theme tokens, commit flash, caret blink */\n\n.ss-root {\n  --ss-shell-bg: #ffffff;\n  --ss-border: #dadce0;\n  --ss-shadow: 0 1px 2px rgb(60 64 67 / 0.3), 0 2px 6px 2px rgb(60 64 67 / 0.15);\n  --ss-formula-bg: #ffffff;\n  --ss-formula-border: #e0e0e0;\n  --ss-name-box-fg: #3c4043;\n  --ss-name-box-border: #dadce0;\n  --ss-fx-fg: #70757a;\n  --ss-grid-bg: #ffffff;\n  --ss-header-bg: #f8f9fa;\n  --ss-header-fg: #70757a;\n  --ss-header-active: #d2e3fc;\n  --ss-grid-line: #e0e0e0;\n  --ss-cell-fg: #3c4043;\n  --ss-cell-muted: #70757a;\n  --ss-selection: #1a73e8;\n  --ss-selection-fill: #ffffff;\n  --ss-commit-flash: rgb(26 115 232 / 0.1);\n  --ss-caret: #3c4043;\n  --ss-sheet-bar-bg: #f8f9fa;\n  --ss-sheet-bar-border: #dadce0;\n  --ss-sheet-bar-icon: #5f6368;\n  --ss-sheet-tab-bg: #e8f0fe;\n  --ss-sheet-tab-fg: #1a73e8;\n  /* Hero-scale type — readable inside max-w-4xl layouts */\n  --ss-font-chrome: 0.8125rem;\n  --ss-font-col-hdr: 0.6875rem;\n  --ss-font-data: 0.75rem;\n  --ss-font-tab: 0.75rem;\n  /* matches `gridTemplateRows` data tracks in spreadsheet.tsx */\n  --ss-grid-data-row-h: 2rem;\n}\n\n/* Narrow viewports: tighter chrome (grid columns A–E only — set in spreadsheet.tsx) */\n.ss-root--compact {\n  --ss-font-chrome: 0.6875rem;\n  --ss-font-col-hdr: 0.5625rem;\n  --ss-font-data: 0.625rem;\n  --ss-font-tab: 0.6875rem;\n  --ss-grid-data-row-h: 1.375rem;\n}\n\n.ss-root--compact .ss-cell-inner {\n  padding-inline: 0.375rem;\n}\n\n.ss-font-chrome {\n  font-size: var(--ss-font-chrome);\n  line-height: 1.2;\n}\n\n.ss-font-col-hdr {\n  font-size: var(--ss-font-col-hdr);\n  line-height: 1.2;\n}\n\n.ss-font-data {\n  font-size: var(--ss-font-data);\n  line-height: 1.2;\n}\n\n.ss-font-tab {\n  font-size: var(--ss-font-tab);\n  line-height: 1.2;\n}\n\n.dark .ss-root {\n  --ss-shell-bg: #202124;\n  --ss-border: #5f6368;\n  --ss-shadow: 0 1px 3px rgb(0 0 0 / 0.4), 0 4px 12px rgb(0 0 0 / 0.35);\n  --ss-formula-bg: #202124;\n  --ss-formula-border: #5f6368;\n  --ss-name-box-fg: #e8eaed;\n  --ss-name-box-border: #5f6368;\n  --ss-fx-fg: #9aa0a6;\n  --ss-grid-bg: #202124;\n  --ss-header-bg: #292a2d;\n  --ss-header-fg: #9aa0a6;\n  --ss-header-active: #394457;\n  --ss-grid-line: #3c4043;\n  --ss-cell-fg: #e8eaed;\n  --ss-cell-muted: #9aa0a6;\n  --ss-selection: #8ab4f8;\n  --ss-selection-fill: #202124;\n  --ss-commit-flash: rgb(138 180 248 / 0.14);\n  --ss-caret: #e8eaed;\n  --ss-sheet-bar-bg: #292a2d;\n  --ss-sheet-bar-border: #5f6368;\n  --ss-sheet-bar-icon: #9aa0a6;\n  --ss-sheet-tab-bg: #394457;\n  --ss-sheet-tab-fg: #8ab4f8;\n}\n\n.ss-cell--commit-flash .ss-cell-inner {\n  animation: ss-commit-flash 0.5s ease-out both;\n}\n\n@keyframes ss-commit-flash {\n  0% {\n    background-color: var(--ss-commit-flash);\n  }\n  100% {\n    background-color: var(--ss-grid-bg);\n  }\n}\n\n.ss-caret {\n  animation: ss-caret-blink 1.1s step-start infinite;\n}\n\n@keyframes ss-caret-blink {\n  0%,\n  49.9% {\n    opacity: 1;\n  }\n  50%,\n  100% {\n    opacity: 0;\n  }\n}\n",
      "type": "registry:file",
      "target": "app/spreadsheet/styles/spreadsheet.css"
    }
  ],
  "type": "registry:block"
}