{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "register",
  "title": "Register",
  "description": "Paper sheet of drawn writing whose shape says who reads it: steps, lists, tables, sourced prose, or a mixed page.",
  "registryDependencies": [
    "@jbm/tokens",
    "@jbm/scene-geometry",
    "@jbm/paper"
  ],
  "files": [
    {
      "path": "registry/jbm/ui/register.tsx",
      "content": "import { useId, type CSSProperties, type ReactNode } from \"react\"\nimport { Paper, frayReach, paperFill, type PaperTone } from \"./paper\"\nimport { color, font, outlineIn } from \"../lib/tokens\"\nimport { unit, type Box, type Pt } from \"../lib/geometry\"\n\n/**\n * Drawn writing registers: what kind of reader a page is for, shown by the shape of its writing and\n * never by legible prose. `mono` is a prompt and a result box per step, `plain` short numbered\n * lists, `grid` ruled tables, `prose` a justified block with source ticks, and `mixed` stacks\n * several registers on one sheet. Geometry is a pure function of the props (registerLayout), so\n * threads, tears, and slips can attach to the same points the sheet draws. Pure React.\n */\nexport type RegisterKind = \"mono\" | \"plain\" | \"grid\" | \"prose\" | \"mixed\"\nexport type RegisterBand = {\n  kind: Exclude<RegisterKind, \"mixed\">\n  /** Steps, list groups, tables, or (prose) source ticks in this band. */\n  n?: number\n  /** Share of the page's writing height; defaults to the height its writing naturally runs. */\n  weight?: number\n}\nexport type RegisterSpec = {\n  kind: RegisterKind\n  /** Steps (mono), list groups (plain), tables (grid), source ticks (prose), or bands (mixed, 1–4). */\n  n?: number\n  /** Sheet width in stage px. */\n  w: number\n  /** Sheet height in stage px. */\n  h: number\n  /** Prose only: source ticks; overrides n. In mixed, the prose band's ticks. */\n  sources?: number\n  /** Mixed only: the stacked registers, top to bottom. */\n  bands?: readonly RegisterBand[]\n  /** Row index where a gap opens (bands for mixed). Rows from here down move to make room. */\n  gapAt?: number\n  /** Gap height in px when fully open; defaults to a quarter of the writing height. */\n  gap?: number\n  /** How open the gap is, 0–1: 1 on a source before its slip lifts, 0 after it closes. */\n  reflow?: number\n  /** Mark scale; defaults to w / 360, so a 360 px sheet draws 6 px prompt bars. */\n  scale?: number\n  /** Inset from the sheet edge to the writing, in px (default 20 × scale). */\n  pad?: number\n}\nexport type RegisterTone = \"ink\" | \"dim\" | \"accent\"\nexport type RegisterMark =\n  /** Filled bar; r is the corner radius (default: fully rounded ends). */\n  | { type: \"bar\"; x: number; y: number; w: number; h: number; tone: RegisterTone; r?: number }\n  | { type: \"box\"; x: number; y: number; w: number; h: number; r: number; stroke: number }\n  | { type: \"rule\"; x1: number; y1: number; x2: number; y2: number; stroke: number }\n  | { type: \"chevron\"; x: number; y: number; size: number; stroke: number }\n  | { type: \"num\"; x: number; y: number; size: number; text: string }\nexport type RegisterCell = {\n  /** Reading order across the whole sheet; reveal and accent use it. */\n  index: number\n  band: number\n  row: number\n  kind: Exclude<RegisterKind, \"mixed\"> | \"source\"\n  /** Everything the cell draws sits inside this box. */\n  box: Box\n  /** Right end of the cell's lead mark (prompt, heading, header, line): where a thread can start. */\n  lead: Pt\n  /** Source ticks only: the tick's centre. */\n  anchor?: Pt\n  marks: RegisterMark[]\n}\nexport type RegisterLayout = {\n  w: number\n  h: number\n  scale: number\n  cells: RegisterCell[]\n  /** Slot of every row (bands for mixed), in stacking order. */\n  rows: Box[]\n  /** Each band's writing box (one band unless mixed). */\n  bands: Box[]\n  /** Mixed only: y of each seam between bands, top to bottom. */\n  seams: number[]\n  /** Prose source tick centres, top to bottom. */\n  anchors: Pt[]\n  /** Where the gap is (height = gap × reflow), or null without gapAt. */\n  gap: Box | null\n}\n\nconst defaults = { mono: 7, plain: 10, grid: 7, prose: 8 } as const\nconst mixedBands: readonly RegisterBand[] = [\n  { kind: \"mono\", n: 3 },\n  { kind: \"plain\", n: 4 },\n  { kind: \"grid\", n: 2 },\n  { kind: \"prose\", n: 3 },\n]\n/** Natural row pitch in scale units: rows never grow past it. */\nconst rowMax = { mono: 56, plain: 72, grid: 96 } as const\n/**\n * A band's default share of a mixed page, from how tall its writing naturally runs (one mono step =\n * 1): rows weigh their natural pitch, so on a page long enough every band gets its full row pitch\n * and no list or table is squeezed beside roomier steps.\n */\nconst natural = (kind: Exclude<RegisterKind, \"mixed\">, n: number) =>\n  kind === \"mono\"\n    ? n\n    : kind === \"plain\"\n      ? (Math.ceil(n / 2) * rowMax.plain) / rowMax.mono\n      : kind === \"grid\"\n        ? (Math.ceil(n / Math.min(3, Math.max(1, Math.ceil(n / 4)))) * rowMax.grid) / rowMax.mono\n        : 2.6 + n * 0.3\nconst endWidths = [0.45, 0.62, 0.38, 0.54]\n/**\n * Source tick pitch in scale units: roomy enough that a ring drawn around each tick (a thread's\n * anchor) clears the next one.\n */\nconst SOURCE_PITCH = 14\n/** Extra separator height on a mixed page, so Paper's starting notch at a seam clears the writing. */\nconst NOTCH_ROOM = 8\nconst count = (n: number | undefined, fallback: number, min: number, max: number) =>\n  Math.max(min, Math.min(max, Math.round(Number.isFinite(n) ? (n as number) : fallback)))\n\ntype Slot = { y: number; h: number; size: number }\n/**\n * Stacks weighted slots from `top` within `height`; a gap before `gapAt` compresses the pitch, never\n * the marks. The pitch never exceeds `maxK` px per weight unit: a few rows keep their natural size and\n * leave the rest of the sheet blank instead of ballooning.\n */\nfunction stack(weights: number[], top: number, height: number, gapAt: number | undefined, gapPx: number, reflow: number, maxK = Infinity) {\n  const total = weights.reduce((a, b) => a + b, 0) || 1\n  const open = gapAt === undefined ? 0 : gapPx * reflow\n  const k = Math.min(maxK, (height - open) / total)\n  const kSize = Math.min(maxK, (height - (gapAt === undefined ? 0 : gapPx)) / total)\n  let cum = 0\n  const slots: Slot[] = weights.map((wt, i) => {\n    const y = top + cum * k + (gapAt !== undefined && i >= gapAt ? open : 0)\n    cum += wt\n    return { y, h: wt * k, size: wt * kSize }\n  })\n  let before = 0\n  for (let i = 0; i < Math.min(gapAt ?? 0, weights.length); i++) before += weights[i]\n  const gap = gapAt === undefined ? null : { y: top + before * k, h: open }\n  return { slots, gap }\n}\n\ntype Draft = Omit<RegisterCell, \"index\" | \"band\">\n/** One band of a single kind, laid out in `box`; rows stack with the optional gap. */\nfunction band(kind: Exclude<RegisterKind, \"mixed\">, n: number, box: Box, u: number, gapAt?: number, gapPx = 0, reflow = 0, mixed = false) {\n  const cells: Draft[] = []\n  const x = box.x,\n    w = box.w\n  if (kind === \"prose\") {\n    const src = n\n    const srcH = src * SOURCE_PITCH * u\n    const spacer = src > 0 ? 10 * u : 0\n    const lines = Math.max(2, Math.floor((box.h - (gapAt === undefined ? 0 : gapPx) - srcH - spacer) / (12 * u)))\n    const weights = [\n      ...Array(lines).fill(12),\n      ...(src > 0 ? [10] : []),\n      ...Array(src).fill(SOURCE_PITCH),\n    ]\n    const { slots, gap } = stack(weights, box.y, box.h, gapAt, gapPx, reflow, 1.25 * u)\n    let paragraph = 0\n    for (let i = 0; i < lines; i++) {\n      const s = slots[i]\n      const bh = Math.min(5 * u, s.size * 0.45)\n      const y = s.y + (s.h - bh) / 2\n      // Paragraphs end every fifth line and on the last, but never twice in a row (the line before\n      // the last) and never on the first line after a gap, where a short line reads as a heading.\n      const end =\n        i === lines - 1 || (i % 5 === 4 && i !== lines - 2 && i !== gapAt)\n      const bw = end ? w * endWidths[paragraph++ % endWidths.length] : w\n      cells.push({\n        row: i,\n        kind: \"prose\",\n        box: { x, y, w: bw, h: bh },\n        lead: { x: x + bw, y: y + bh / 2 },\n        marks: [{ type: \"bar\", x, y, w: bw, h: bh, tone: \"ink\" }],\n      })\n    }\n    for (let j = 0; j < src; j++) {\n      const s = slots[lines + 1 + j]\n      const th = Math.min(4 * u, s.size * 0.5)\n      const y = s.y + (s.h - th) / 2\n      const tw = Math.min(7 * u, w * 0.05)\n      const bw = w * 0.5\n      cells.push({\n        row: lines + 1 + j,\n        kind: \"source\",\n        box: { x, y, w: tw + 5 * u + bw, h: th },\n        lead: { x: x + tw + 5 * u + bw, y: y + th / 2 },\n        anchor: { x: x + tw / 2, y: y + th / 2 },\n        marks: [\n          { type: \"bar\", x, y, w: tw, h: th, tone: \"ink\", r: 0 },\n          { type: \"bar\", x: x + tw + 5 * u, y, w: bw, h: th, tone: \"dim\" },\n        ],\n      })\n    }\n    return { cells, rows: slots.map((s) => ({ x, y: s.y, w, h: s.h })), gap }\n  }\n  if (n <= 0) return { cells, rows: [] as Box[], gap: gapAt === undefined ? null : { y: box.y, h: gapPx * reflow } }\n  const cols = kind === \"mono\" ? 1 : kind === \"plain\" ? 2 : Math.min(3, Math.ceil(n / 4))\n  const rowCount = Math.ceil(n / cols)\n  const gutter = 16 * u\n  const cw = (w - gutter * (cols - 1)) / cols\n  const { slots, gap } = stack(Array(rowCount).fill(1), box.y, box.h, gapAt, gapPx, reflow, rowMax[kind] * u)\n  for (let i = 0; i < n; i++) {\n    const r = Math.floor(i / cols)\n    const s = slots[r]\n    const cx = x + (i % cols) * (cw + gutter)\n    const ch = s.size\n    const cy = s.y + (s.h - ch) / 2\n    if (kind === \"mono\") {\n      const indent = 14 * u\n      const bh = Math.max(1, Math.min(6 * u, ch * 0.13))\n      const by = cy + ch * 0.14\n      const bw = (cw - indent) * 0.55\n      const rh = ch * 0.4\n      const stroke = Math.min(1.5 * u, rh / 4)\n      const cv = Math.min(3 * u, ch * 0.12)\n      cells.push({\n        row: r,\n        kind,\n        box: { x: cx, y: cy, w: cw * 0.72 + indent * 0.28 + stroke, h: ch * 0.82 },\n        lead: { x: cx + indent + bw, y: by + bh / 2 },\n        marks: [\n          { type: \"chevron\", x: cx + stroke, y: by + bh / 2, size: cv, stroke },\n          { type: \"bar\", x: cx + indent, y: by, w: bw, h: bh, tone: \"ink\" },\n          { type: \"box\", x: cx + indent, y: cy + ch * 0.4, w: (cw - indent) * 0.72, h: rh, r: Math.min(3 * u, rh / 2), stroke },\n        ],\n      })\n    } else if (kind === \"plain\") {\n      const bh = Math.max(1, Math.min(6 * u, ch * 0.11))\n      // Numerals set at 12 × scale (15 px on the board's 460 px page), so they read as numbers.\n      const fs = Math.min(12 * u, ch * 0.18)\n      const ih = Math.max(0.75, Math.min(3 * u, ch * 0.07))\n      const marks: RegisterMark[] = [\n        { type: \"bar\", x: cx, y: cy + ch * 0.06, w: cw * 0.8, h: bh, tone: \"ink\" },\n      ]\n      // On a mixed page (a long sheet shown small) or below 8 px a numeral is a speck, not a\n      // number: the list marks its items with small ink squares instead, like the prose bullets.\n      const numerals = !mixed && fs >= 8\n      const dot = Math.max(2, Math.min(fs * 0.7, ih * 2))\n      for (let j = 0; j < 3; j++) {\n        const my = cy + ch * (0.36 + 0.2 * j)\n        marks.push(\n          numerals\n            ? { type: \"num\", x: cx, y: my + fs * 0.36, size: fs, text: `${j + 1}.` }\n            : { type: \"bar\", x: cx, y: my - dot / 2, w: dot, h: dot, tone: \"ink\", r: 0 },\n          {\n            type: \"bar\",\n            x: cx + (numerals ? fs * 1.35 : dot * 2.2),\n            y: my - ih / 2,\n            w: cw * 0.5,\n            h: ih,\n            tone: \"dim\",\n          }\n        )\n      }\n      cells.push({\n        row: r,\n        kind,\n        box: { x: cx, y: cy, w: cw * 0.8, h: ch * 0.78 + ih },\n        lead: { x: cx + cw * 0.8, y: cy + ch * 0.06 + bh / 2 },\n        marks,\n      })\n    } else {\n      const th = ch * 0.86\n      const stroke = Math.min(1.5 * u, th / 12)\n      const head = th * 0.22\n      const marks: RegisterMark[] = [\n        { type: \"bar\", x: cx, y: cy, w: cw, h: head, tone: \"ink\", r: 0 },\n      ]\n      for (let k = 1; k < 4; k++) {\n        const ry = cy + head + ((th - head) * k) / 4\n        marks.push({ type: \"rule\", x1: cx, y1: ry, x2: cx + cw, y2: ry, stroke: stroke * 0.66 })\n      }\n      marks.push(\n        { type: \"rule\", x1: cx + cw * 0.4, y1: cy + head, x2: cx + cw * 0.4, y2: cy + th, stroke: stroke * 0.66 },\n        { type: \"box\", x: cx, y: cy, w: cw, h: th, r: 0, stroke }\n      )\n      cells.push({\n        row: r,\n        kind,\n        box: { x: cx, y: cy, w: cw, h: th },\n        lead: { x: cx + cw, y: cy + head / 2 },\n        marks,\n      })\n    }\n  }\n  return { cells, rows: slots.map((s) => ({ x, y: s.y, w, h: s.h })), gap }\n}\n\n/** Every cell, row, seam, anchor, and the gap for a register, in sheet px (origin at the sheet's outer corner). */\nexport function registerLayout(spec: RegisterSpec): RegisterLayout {\n  const w = Math.max(1, spec.w),\n    h = Math.max(1, spec.h)\n  const u = spec.scale ?? Math.max(0.4, Math.min(4, w / 360))\n  const pad = spec.pad ?? 20 * u\n  const inner: Box = { x: pad, y: pad, w: Math.max(1, w - 2 * pad), h: Math.max(1, h - 2 * pad) }\n  const gapPx = Math.max(0, Math.min(inner.h * 0.6, spec.gap ?? inner.h * 0.25))\n  const reflow = unit(spec.reflow ?? 1)\n  const kind = spec.kind\n  const out: RegisterLayout = { w, h, scale: u, cells: [], rows: [], bands: [], seams: [], anchors: [], gap: null }\n  const push = (drafts: Draft[], b: number) => {\n    for (const d of drafts) out.cells.push({ ...d, index: out.cells.length, band: b })\n  }\n  if (kind !== \"mixed\") {\n    const n =\n      kind === \"prose\"\n        ? count(spec.sources ?? spec.n, defaults.prose, 0, 16)\n        : count(spec.n, defaults[kind], 0, kind === \"grid\" ? 12 : 24)\n    const gapAt = spec.gapAt === undefined ? undefined : Math.max(0, Math.round(spec.gapAt))\n    const l = band(kind, n, inner, u, gapAt, gapPx, reflow)\n    push(l.cells, 0)\n    out.rows = l.rows\n    out.bands = [inner]\n    if (l.gap) out.gap = { x: inner.x, y: l.gap.y, w: inner.w, h: l.gap.h }\n  } else {\n    const list = (spec.bands ?? mixedBands.slice(0, count(spec.n, 4, 0, 4))).slice(0, 8)\n    const counts = list.map((b) =>\n      b.kind === \"prose\"\n        ? count(spec.sources ?? b.n, 3, 0, 16)\n        : count(b.n, mixedBands.find((m) => m.kind === b.kind)?.n ?? 3, 1, 24)\n    )\n    const weights: number[] = []\n    list.forEach((b, i) => {\n      if (i) weights.push(0.14)\n      weights.push(Math.max(0.1, b.weight ?? natural(b.kind, counts[i])))\n    })\n    const bandGap = spec.gapAt === undefined ? undefined : Math.max(0, Math.min(list.length, Math.round(spec.gapAt)))\n    const gapAt = bandGap === undefined ? undefined : bandGap * 2\n    const { slots } = stack(weights, inner.y, inner.h, gapAt, gapPx, reflow)\n    // First pass: each band in its weighted slot. Row pitches are capped, so a band may use less\n    // than its slot; measure what it uses.\n    const first = list.map((b, i) => {\n      const s = slots[i * 2]\n      const box = { x: inner.x, y: s.y + (s.h - s.size) / 2, w: inner.w, h: s.size }\n      const l = band(b.kind, counts[i], box, u, undefined, 0, 0, true)\n      const bottom = Math.max(box.y, ...l.rows.map((r) => r.y + r.h))\n      return { box, used: Math.min(box.h, bottom - box.y) }\n    })\n    // Second pass: stack the bands at the heights they use, with even separators wide enough that\n    // a Tear's fray at a seam, or Paper's starting notch, stays clear of the writing on both sides\n    // (NOTCH_ROOM); leftover height collects at\n    // the foot of the page. When the bands need more than the page, they share what is left.\n    const sep = Math.max(2 * (frayReach() + 2) + NOTCH_ROOM, slots.length > 1 ? slots[1].h : 0)\n    const open = bandGap === undefined ? 0 : gapPx * reflow\n    const used = first.reduce((a, f) => a + f.used, 0)\n    // Sized for the fully open gap, so reflowing moves the writing and never resizes a mark.\n    const room = Math.max(1, inner.h - sep * (list.length - 1) - (bandGap === undefined ? 0 : gapPx))\n    const fit = used > room ? room / used : 1\n    let y = inner.y\n    let prevBottom = inner.y\n    let gapBox: { y: number; h: number } | null = null\n    list.forEach((b, i) => {\n      if (bandGap === i) {\n        gapBox = { y, h: open }\n        y += open\n      }\n      const box = { x: inner.x, y, w: inner.w, h: first[i].used * fit }\n      push(band(b.kind, counts[i], box, u, undefined, 0, 0, true).cells, i)\n      out.bands.push(box)\n      out.rows.push({ ...box })\n      if (i) out.seams.push(prevBottom + sep / 2)\n      prevBottom = box.y + box.h\n      y = prevBottom + sep\n    })\n    if (bandGap === list.length) gapBox = { y: prevBottom, h: open }\n    const gapOut = gapBox as { y: number; h: number } | null\n    if (gapOut) out.gap = { x: inner.x, y: gapOut.y, w: inner.w, h: gapOut.h }\n  }\n  out.anchors = out.cells.flatMap((c) => (c.anchor ? [c.anchor] : []))\n  return out\n}\n\n/** Prose source tick centres, in sheet px: where threads leave the sheet. */\nexport const registerAnchors = (spec: RegisterSpec): Pt[] => registerLayout(spec).anchors\n/** Mixed only: y of each seam between bands, in sheet px (tear lines). Empty for other kinds. */\nexport const registerSeams = (spec: RegisterSpec): number[] => registerLayout(spec).seams\n/** The open gap's box in sheet px (where a slip lands or lifted from), or null without gapAt. */\nexport const registerGap = (spec: RegisterSpec): Box | null => registerLayout(spec).gap\n\n/** Writing colours on a stock: ink, dim, and the vermilion accent, plus the stock's own fill. */\ntype Inks = { ink: string; dim: string; accent: string; stock: string }\nconst inksFor = (stock: PaperTone): Inks =>\n  stock === \"paper\"\n    ? { ink: color.ink, dim: color.dim, accent: color.accent, stock: paperFill(stock) }\n    : // On ink or vermilion stock the writing is card-coloured, its muted marks cream at 62%.\n      { ink: color.card, dim: color.dimOnDark, accent: stock === \"ink\" ? color.accent : color.ink, stock: paperFill(stock) }\n\nfunction Mark({ m, accent, inks }: { m: RegisterMark; accent: boolean; inks: Inks }) {\n  switch (m.type) {\n    case \"bar\":\n      return <rect x={m.x} y={m.y} width={Math.max(0, m.w)} height={m.h} rx={m.r ?? m.h / 2} fill={inks[accent && m.tone === \"ink\" ? \"accent\" : m.tone]} />\n    case \"box\":\n      return (\n        <rect\n          x={m.x + m.stroke / 2}\n          y={m.y + m.stroke / 2}\n          width={Math.max(0, m.w - m.stroke)}\n          height={Math.max(0, m.h - m.stroke)}\n          rx={m.r}\n          fill=\"none\"\n          stroke={inks.ink}\n          strokeWidth={m.stroke}\n        />\n      )\n    case \"rule\":\n      return <line x1={m.x1} y1={m.y1} x2={m.x2} y2={m.y2} stroke={inks.ink} strokeWidth={m.stroke} />\n    case \"chevron\":\n      return (\n        <path\n          d={`M${m.x} ${m.y - m.size}L${m.x + m.size * 1.4} ${m.y}L${m.x} ${m.y + m.size}`}\n          fill=\"none\"\n          stroke={inks.ink}\n          strokeWidth={m.stroke}\n          strokeLinecap=\"round\"\n          strokeLinejoin=\"round\"\n        />\n      )\n    case \"num\":\n      return (\n        <text x={m.x} y={m.y} fontFamily={font.mono} fontSize={m.size} fontWeight={700} fill={inks.ink}>\n          {m.text}\n        </text>\n      )\n  }\n}\n\nexport type RegisterInkProps = RegisterSpec & {\n  /** Writing drawn so far, 0–1, cell by cell in reading order; each cell inks left to right. */\n  reveal?: number\n  /** The stock the writing sits on (Paper's tone): ink writing on paper, card-coloured on ink or vermilion. Result boxes and tables are filled with the stock. */\n  tone?: PaperTone\n  /** Cell indices (reading order) whose lead mark is vermilion. */\n  accent?: readonly number[]\n}\n/** The writing alone, as an SVG <g> in sheet px. Render inside an <svg>; the sheet is the caller's. */\nexport function RegisterInk({ reveal = 1, accent = [], tone = \"paper\", ...spec }: RegisterInkProps) {\n  const clip = `jbm-register-${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`\n  const layout = registerLayout(spec)\n  const inks = inksFor(tone)\n  const total = layout.cells.length\n  const shown = unit(reveal) * total\n  return (\n    <g aria-hidden>\n      {layout.cells.map((cell) => {\n        const f = Math.max(0, Math.min(1, shown - cell.index))\n        if (f <= 0) return null\n        const hot = accent.includes(cell.index)\n        // Boxes (result boxes, tables) are filled with the stock first, so what lies under the\n        // writing, such as Paper's creases, never shows inside them.\n        const marks = [\n          ...cell.marks.flatMap((m, i) =>\n            m.type === \"box\" ? [<rect key={`f${i}`} x={m.x} y={m.y} width={Math.max(0, m.w)} height={Math.max(0, m.h)} rx={m.r} fill={inks.stock} />] : []\n          ),\n          ...cell.marks.map((m, i) => <Mark key={i} m={m} inks={inks} accent={hot && i === (cell.kind === \"mono\" ? 1 : 0)} />),\n        ]\n        if (f >= 1) return <g key={cell.index}>{marks}</g>\n        const pad = layout.scale * 2\n        return (\n          <g key={cell.index}>\n            <clipPath id={clip}>\n              <rect x={cell.box.x - pad} y={cell.box.y - pad} width={(cell.box.w + pad * 2) * f} height={cell.box.h + pad * 2} />\n            </clipPath>\n            <g clipPath={`url(#${clip})`}>{marks}</g>\n          </g>\n        )\n      })}\n    </g>\n  )\n}\n\nexport type RegisterProps = RegisterInkProps & {\n  /** Sheet rotation in degrees. */\n  rotate?: number\n  /** Accessible name; defaults to the register kind. */\n  label?: string\n  /** Laid over the sheet in sheet px (slips, tabs, pins). */\n  children?: ReactNode\n  style?: CSSProperties\n}\n/** A writing sheet's corner radius per unit of mark scale: 6 px on a 360 px sheet. */\nexport const SHEET_RADIUS = 6\n/**\n * The corner radius of a writing sheet `w` px wide, shared by Register and Tear (and any Paper that\n * stands in for a page): SHEET_RADIUS × the sheet's mark scale (`scale`, or w / 360 clamped to\n * 0.4–4), never under 4 px.\n */\nexport function sheetRadius(w: number, scale?: number) {\n  const u = scale ?? Math.max(0.4, Math.min(4, (Number.isFinite(w) ? w : 360) / 360))\n  return Math.max(4, SHEET_RADIUS * u)\n}\n/** Paper's edge: the shared outline. */\nconst EDGE = outlineIn()\n/** A Paper sheet carrying one register of drawn writing. Anchors and gaps are in the sheet's px. */\nexport function Register({ rotate = 0, label, children, style, ...ink }: RegisterProps) {\n  return (\n    <Paper w={ink.w} h={ink.h} tone={ink.tone} radius={sheetRadius(ink.w, ink.scale)} rotate={rotate} style={{ flexShrink: 0, ...style }}>\n      <svg\n        width={ink.w}\n        height={ink.h}\n        viewBox={`0 0 ${ink.w} ${ink.h}`}\n        role=\"img\"\n        aria-label={label ?? `Page of ${ink.kind} writing`}\n        style={{ position: \"absolute\", left: -EDGE, top: -EDGE, overflow: \"visible\", display: \"block\" }}\n      >\n        <RegisterInk {...ink} />\n      </svg>\n      {children && <div style={{ position: \"absolute\", left: -EDGE, top: -EDGE, width: ink.w, height: ink.h }}>{children}</div>}\n    </Paper>\n  )\n}\n",
      "type": "registry:ui",
      "target": "src/jbm/ui/register.tsx"
    }
  ],
  "categories": [
    "UI Bits"
  ],
  "type": "registry:ui"
}