{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "remnant-cut",
  "title": "Remnant Cut",
  "description": "A plan-change proration panel drawn as a draper cutting cloth: the used billing period dims and stays, the unused remnant slides into the new plan's row re-measured against its rate, and the cents lost to rounding render as a labelled sliver at the cut instead of vanishing into a footnote.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/core/remnant-cut/component.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\n\n// ---------------------------------------------------------------------------\n// RemnantCut — a plan-change proration panel drawn as a draper cutting cloth.\n// The current billing period is a horizontal bolt: a woven-hatch SVG strip,\n// selvage rules at both ends, cut at today's date. ONE governing scalar,\n// `cutFrac = elapsedDays / periodDays`, drives everything on the old strip —\n// the shear x-position, the dimmed \"offcut\" (used) width, the bright\n// \"remnant\" (unused) width, and `creditRaw = (1 - cutFrac) * oldPrice` — the\n// same expression that sizes the remnant rect also prints as the credit,\n// never a second computation. A strip's bar HEIGHT maps to its plan's daily\n// rate, so rect area (width-in-days * height-in-rate) literally IS money;\n// that identity is the same on every row, so it survives the reflow.\n//\n// Choosing a candidate plan re-measures that credit against the new plan's\n// daily rate: creditedDays = creditedAmount / newDailyRate, and the remnant\n// animates from its old-strip position/size to that new width and the new\n// plan's own bar height, across one 600ms ease-out-expo progress value `t`.\n// Both endpoints already satisfy width*height === creditedAmount * K (K =\n// px-per-day * px-per-rate, one constant shared by both rows), so deriving\n// width(t) by lerp and height(t) = creditedAmount*K / width(t) keeps the\n// rectangle's area exactly constant on every intermediate frame too — area\n// preservation isn't checked after the fact, it's structurally impossible\n// for the rect to have any other area at any t.\n//\n// Whatever the raw credit loses to the provider's rounding unit (floored to\n// the nearest cent by default) is never silently absorbed: it renders as its\n// own thin labelled sliver — the kerf — sitting right at the cut, between\n// the offcut and the remnant. offcut + kerf + remnant always reconstruct the\n// full old strip exactly; credit + charge, rounded to the cent a bill shows,\n// never quite sum back to the strip's full price, and the kerf sliver is\n// where the missing fraction visibly lives instead of vanishing.\n//\n// The cut itself is a fixed hash-seeded (mulberry32) 2px polyline, same seed\n// every render regardless of props — a perfectly straight line reads as a\n// CSS border, a wavered one reads as a blade having actually passed through.\n//\n// A11Y: the cloth (both SVG strips) is aria-hidden — decoration only, never\n// the source of truth. The real controls are native <input type=radio> per\n// candidate plan (grouped in a <fieldset>/<legend>, so the group's\n// accessible name and per-option checked-state announcements come free from\n// the browser) and a real <button> whose visible text states the derived\n// numbers outright (\"$8.41 credit, 6.5 days applied, ...\"). A single\n// role=status/aria-live=polite paragraph carries the same sentence and is\n// always on screen (not sr-only), so sighted and assistive-tech readers see\n// the identical figures at the identical moment. Nothing on the cloth is\n// interactive; Tab only ever reaches the radios and the button.\n//\n// Distinct from wizard-canal-lock on purpose: that component stages a\n// multi-step commitment through sequential gates and conserves nothing\n// numeric — advancing a lock chamber doesn't compute or carry a quantity.\n// RemnantCut is a single-step proration readout where a strict conservation\n// law (area = money, unused days = used days' complement) is the entire\n// mechanism; there is no sequence of steps, no validation gate, and the\n// \"physical\" motion exists only to make one arithmetic identity legible.\n//\n// Pure DOM + SVG + CSS, no canvas. Every stroke/fill token is one of\n// --background/--foreground/--ns-muted/--border/--ns-accent; --ns-accent is\n// used only for the keyboard focus ring. prefers-reduced-motion skips the\n// rAF tween entirely and renders the remnant at its final reflowed position,\n// size and figures instantly.\n// ---------------------------------------------------------------------------\n\nexport interface RemnantCutPlan {\n  /** stable identifier, used as the native radio's value */\n  id: string;\n  /** display name, e.g. \"Team\" */\n  name: string;\n  /** full-period price in dollars, e.g. a monthly price */\n  price: number;\n  /** length of one billing period for this plan, in days */\n  periodDays: number;\n}\n\nexport interface RemnantCutSummary {\n  planId: string;\n  creditRaw: number;\n  creditedAmount: number;\n  kerf: number;\n  creditedDays: number;\n  newPeriodStart: string;\n}\n\nexport interface RemnantCutProps {\n  /** the plan currently being paid for */\n  currentPlan: RemnantCutPlan;\n  /** candidate plans offered as the radio choices */\n  plans: RemnantCutPlan[];\n  /** days elapsed in the current billing period as of today */\n  elapsedDays: number;\n  /** ISO date string for \"today\" — only used to print the new period's start date. @default now */\n  today?: string;\n  /** the provider's credit-rounding unit in dollars, e.g. 0.01 for whole cents. @default 0.01 */\n  roundingUnit?: number;\n  /** controlled selected candidate-plan id */\n  value?: string;\n  /** initial selected candidate-plan id when uncontrolled */\n  defaultValue?: string;\n  /** called with the newly selected candidate-plan id */\n  onValueChange?: (id: string) => void;\n  /** called with the derived confirmation figures when Confirm is pressed */\n  onConfirm?: (summary: RemnantCutSummary) => void;\n  /** fieldset legend text. @default \"Change to\" */\n  label?: string;\n  /** shared name for the native radios. @default a generated id */\n  name?: string;\n  /** extra classes merged onto the rendered root element */\n  className?: string;\n}\n\n// -- geometry ----------------------------------------------------------------\n\nconst PAD = 14;\nconst BAR_MAX = 46;\nconst OLD_BASELINE = 56;\nconst NEW_BASELINE = 172;\nconst VH = 192;\nconst CUT_SEED = 733; // fixed — never derived from props, so the waver never re-randomizes on data change\n\nfunction clamp(n: number, lo: number, hi: number) {\n  return Math.max(lo, Math.min(hi, n));\n}\n\nfunction fmtMoney(n: number) {\n  const sign = n < 0 ? \"-\" : \"\";\n  return `${sign}$${Math.abs(n).toFixed(2)}`;\n}\n\nfunction fmtKerf(n: number) {\n  // the kerf is deliberately the sub-cent remainder — shown at 4dp so the\n  // \"odd cents\" a 2dp bill can't represent still have a printed home.\n  const sign = n < 0 ? \"-\" : \"\";\n  return `${sign}$${Math.abs(n).toFixed(4)}`;\n}\n\nfunction fmtDays(n: number) {\n  return `${n.toFixed(1)} days`;\n}\n\nfunction fmtDate(iso: string) {\n  const d = new Date(iso);\n  if (Number.isNaN(d.getTime())) return iso;\n  return d.toLocaleDateString(\"en-US\", { month: \"short\", day: \"numeric\" });\n}\n\n/** mulberry32 — small, fast, deterministic given a seed */\nfunction mulberry32(seed: number) {\n  let s = seed | 0;\n  return () => {\n    s = (s + 0x6d2b79f5) | 0;\n    let t = Math.imul(s ^ (s >>> 15), 1 | s);\n    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n  };\n}\n\n/** a fixed, constant-across-renders jittered polyline for the cut blade */\nfunction cutWaver(topY: number, bottomY: number, cx: number) {\n  const rng = mulberry32(CUT_SEED);\n  const steps = 7;\n  const pts: string[] = [];\n  for (let i = 0; i <= steps; i++) {\n    const y = topY + ((bottomY - topY) * i) / steps;\n    const jitter = (rng() - 0.5) * 2; // +-1px\n    pts.push(`${(cx + jitter).toFixed(2)},${y.toFixed(2)}`);\n  }\n  return pts.join(\" \");\n}\n\nfunction easeOutExpo(t: number) {\n  return t >= 1 ? 1 : 1 - Math.pow(2, -10 * t);\n}\n\nfunction useReducedMotion() {\n  const [reduced, setReduced] = useState(false);\n  useEffect(() => {\n    const mq = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    setReduced(mq.matches);\n    const onChange = () => setReduced(mq.matches);\n    mq.addEventListener(\"change\", onChange);\n    return () => mq.removeEventListener(\"change\", onChange);\n  }, []);\n  return reduced;\n}\n\ninterface Rect {\n  x: number;\n  y: number;\n  w: number;\n  h: number;\n}\n\nexport function RemnantCut({\n  currentPlan,\n  plans,\n  elapsedDays,\n  today,\n  roundingUnit = 0.01,\n  value,\n  defaultValue,\n  onValueChange,\n  onConfirm,\n  label = \"Change to\",\n  name,\n  className = \"\",\n}: RemnantCutProps) {\n  const uid = useId();\n  const reduced = useReducedMotion();\n  const groupName = name ?? uid;\n  const hatchId = `${uid}-hatch`;\n\n  const [uncontrolled, setUncontrolled] = useState<string | undefined>(defaultValue);\n  const selectedId = value !== undefined ? value : uncontrolled;\n  const setSelectedId = (id: string) => {\n    if (value === undefined) setUncontrolled(id);\n    onValueChange?.(id);\n  };\n\n  const todayIso = today ?? new Date().toISOString();\n  const selectedPlan = plans.find((p) => p.id === selectedId) ?? null;\n\n  // -- geometry scales, derived from every plan in play so any prop set stays legible --\n  const { pxPerDay, pxPerRate } = useMemo(() => {\n    const maxDays = Math.max(currentPlan.periodDays, ...plans.map((p) => p.periodDays), 1);\n    const maxRate = Math.max(\n      currentPlan.price / currentPlan.periodDays,\n      ...plans.map((p) => p.price / Math.max(1, p.periodDays)),\n      1e-6\n    );\n    return {\n      pxPerDay: clamp(400 / maxDays, 4, 22),\n      pxPerRate: clamp(BAR_MAX / maxRate, 0.5, 400),\n    };\n  }, [currentPlan, plans]);\n\n  const K = pxPerDay * pxPerRate; // px^2 per dollar — the one constant that makes area = money everywhere\n  const amountToWidth = (amount: number, dailyRate: number) =>\n    dailyRate > 0 ? (amount / dailyRate) * pxPerDay : 0;\n  const rateToHeight = (rate: number) => rate * pxPerRate;\n\n  const maxDays = Math.max(currentPlan.periodDays, ...plans.map((p) => p.periodDays), 1);\n  const VW = PAD * 2 + maxDays * pxPerDay;\n\n  // -- old strip: the single governing scalar and everything it drives --\n  const oldDailyRate = currentPlan.price / currentPlan.periodDays;\n  const oldBarH = rateToHeight(oldDailyRate);\n  const oldStripW = currentPlan.periodDays * pxPerDay;\n  const cutFrac = clamp(elapsedDays / currentPlan.periodDays, 0, 1);\n  const cutX = PAD + cutFrac * oldStripW;\n  const offcutW = cutX - PAD;\n  const remnantW0 = oldStripW - offcutW; // pre-move remnant width, at oldBarH height\n  const creditRaw = (1 - cutFrac) * currentPlan.price; // prints from the SAME cutFrac that sized remnantW0 above\n  const unit = Math.max(0.0001, roundingUnit);\n  const creditedAmount = Math.floor(creditRaw / unit + 1e-9) * unit;\n  const kerf = Math.max(0, creditRaw - creditedAmount);\n  const kerfWRaw = amountToWidth(kerf, oldDailyRate);\n  const kerfW = kerf > 0 ? Math.max(kerfWRaw, 1.5) : 0;\n  const remnantVisibleW = Math.max(0, remnantW0 - kerfWRaw);\n  const remainingDays = (1 - cutFrac) * currentPlan.periodDays;\n\n  const start: Rect = {\n    x: cutX + kerfWRaw,\n    y: OLD_BASELINE - oldBarH,\n    w: remnantVisibleW,\n    h: oldBarH,\n  };\n\n  // -- new strip target, once a candidate plan is selected --\n  const newDailyRate = selectedPlan ? selectedPlan.price / Math.max(1, selectedPlan.periodDays) : 0;\n  const newBarH = selectedPlan ? rateToHeight(newDailyRate) : 0;\n  const newStripW = selectedPlan ? selectedPlan.periodDays * pxPerDay : 0;\n  const creditedDays = newDailyRate > 0 ? creditedAmount / newDailyRate : 0;\n  const remnantWEnd = selectedPlan ? amountToWidth(creditedAmount, newDailyRate) : 0;\n  const end: Rect = { x: PAD, y: NEW_BASELINE - newBarH, w: remnantWEnd, h: newBarH };\n  const newPeriodStart = todayIso;\n  const newPeriodStartLabel = fmtDate(newPeriodStart);\n\n  // -- one 600ms ease-out-expo progress value; width lerps, height is DERIVED\n  // (creditedAmount*K / width) so area is exactly conserved at every frame,\n  // not just at the two ends. --\n  const [anim, setAnim] = useState<Rect | null>(null);\n  const rafRef = useRef<number | null>(null);\n  const startRef = useRef(start);\n  startRef.current = start;\n\n  useEffect(() => {\n    if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n    if (!selectedPlan) {\n      setAnim(null);\n      return;\n    }\n    const from = startRef.current;\n    const to = end;\n    const creditPx = creditedAmount * K;\n    if (reduced || creditPx <= 0) {\n      setAnim(to);\n      return;\n    }\n    const duration = 600;\n    const t0 = performance.now();\n    const tick = (now: number) => {\n      const raw = clamp((now - t0) / duration, 0, 1);\n      const eased = easeOutExpo(raw);\n      const w = from.w + (to.w - from.w) * eased;\n      const h = w > 0 ? creditPx / w : to.h;\n      const baseline = OLD_BASELINE + (NEW_BASELINE - OLD_BASELINE) * eased;\n      const x = from.x + (to.x - from.x) * eased;\n      const y = baseline - h;\n      setAnim({ x, y, w, h });\n      if (raw < 1) {\n        rafRef.current = requestAnimationFrame(tick);\n      } else {\n        rafRef.current = null;\n      }\n    };\n    rafRef.current = requestAnimationFrame(tick);\n    return () => {\n      if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n    };\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [selectedId, reduced, creditedAmount, K]);\n\n  const cutWaverPoints = useMemo(\n    () => cutWaver(OLD_BASELINE - BAR_MAX - 4, OLD_BASELINE + 6, cutX),\n    [cutX]\n  );\n\n  function ticks(x0: number, days: number, baseline: number) {\n    const step = pxPerDay >= 9 ? 1 : 5;\n    const marks: { x: number }[] = [];\n    for (let d = 0; d <= days; d += step) {\n      marks.push({ x: x0 + d * pxPerDay });\n    }\n    return marks.map((m, i) => (\n      <line\n        key={i}\n        x1={m.x}\n        x2={m.x}\n        y1={baseline + 2}\n        y2={baseline + 6}\n        className=\"stroke-current text-border\"\n        strokeWidth={1}\n      />\n    ));\n  }\n\n  function selvage(xEdge: number, baseline: number, barH: number) {\n    const top = baseline - barH - 6;\n    const bottom = baseline + 8;\n    return [0, 3, 6].map((dx) => (\n      <line\n        key={dx}\n        x1={xEdge + dx}\n        x2={xEdge + dx}\n        y1={top}\n        y2={bottom}\n        className=\"stroke-current text-border\"\n        strokeWidth={dx === 0 ? 1.5 : 1}\n        opacity={dx === 0 ? 0.9 : 0.5}\n      />\n    ));\n  }\n\n  const summaryText = selectedPlan\n    ? `${fmtMoney(creditRaw)} raw credit for ${fmtDays(remainingDays)} unused, rounded to ${fmtMoney(\n        creditedAmount\n      )} (${fmtKerf(kerf)} lost to rounding). Re-measured against ${selectedPlan.name}'s ${fmtMoney(\n        newDailyRate\n      )}/day rate: ${fmtDays(creditedDays)} applied. New period starts ${newPeriodStartLabel}.`\n    : `${fmtMoney(creditRaw)} raw credit for ${fmtDays(remainingDays)} unused, rounded to ${fmtMoney(\n        creditedAmount\n      )} (${fmtKerf(kerf)} lost to rounding). Choose a plan below to apply it.`;\n\n  const confirmText = selectedPlan\n    ? `Confirm: ${fmtMoney(creditedAmount)} credit, ${fmtDays(creditedDays)} applied, ${fmtKerf(\n        kerf\n      )} rounding, new period starts ${newPeriodStartLabel}`\n    : \"Select a plan to continue\";\n\n  function handleConfirm() {\n    if (!selectedPlan) return;\n    onConfirm?.({\n      planId: selectedPlan.id,\n      creditRaw,\n      creditedAmount,\n      kerf,\n      creditedDays,\n      newPeriodStart,\n    });\n  }\n\n  // fall back to the pre-tween start rect on the very first paint after a\n  // selection (before the first rAF frame lands), so the piece is never\n  // absent for a frame — it's always somewhere, just not yet where it's going.\n  const displayRect = anim ?? (selectedPlan ? start : null);\n  const showStaticRemnant = !selectedPlan;\n\n  return (\n    <div className={`w-full ${className}`}>\n      <style>{`\n        .ns-remnant-input {\n          position: absolute;\n          width: 1px;\n          height: 1px;\n          padding: 0;\n          margin: -1px;\n          overflow: hidden;\n          clip: rect(0, 0, 0, 0);\n          white-space: nowrap;\n          border: 0;\n        }\n        .ns-remnant-input:focus-visible + .ns-remnant-visual {\n          outline: 2px solid var(--ns-accent);\n          outline-offset: 2px;\n        }\n        .ns-remnant-row {\n          transition: background-color 150ms ease;\n        }\n        .ns-remnant-row:hover {\n          background-color: color-mix(in oklab, var(--foreground) 4%, transparent);\n        }\n        @media (prefers-reduced-motion: reduce) {\n          .ns-remnant-row {\n            transition: none;\n          }\n        }\n      `}</style>\n\n      <div className=\"flex items-baseline justify-between gap-3\">\n        <div>\n          <p className=\"font-mono text-[11px] uppercase tracking-wide text-ns-muted\">Current plan</p>\n          <p className=\"text-sm font-semibold text-foreground\">\n            {currentPlan.name} &middot; {fmtMoney(currentPlan.price)}/period\n          </p>\n        </div>\n        <p className=\"font-mono text-[11px] text-ns-muted\">\n          {elapsedDays} of {currentPlan.periodDays} days used\n        </p>\n      </div>\n\n      <svg\n        viewBox={`0 0 ${VW} ${VH}`}\n        className=\"mt-3 w-full\"\n        aria-hidden=\"true\"\n        focusable=\"false\"\n      >\n        <defs>\n          <pattern id={hatchId} width={6} height={6} patternUnits=\"userSpaceOnUse\">\n            <line x1={0} y1={0} x2={6} y2={6} className=\"stroke-current text-border\" strokeWidth={0.6} opacity={0.5} />\n            <line x1={6} y1={0} x2={0} y2={6} className=\"stroke-current text-border\" strokeWidth={0.6} opacity={0.5} />\n          </pattern>\n        </defs>\n\n        {/* OLD STRIP */}\n        <g>\n          {selvage(PAD, OLD_BASELINE, oldBarH)}\n          {selvage(PAD + oldStripW, OLD_BASELINE, oldBarH)}\n          <rect\n            x={PAD}\n            y={OLD_BASELINE - oldBarH}\n            width={oldStripW}\n            height={oldBarH}\n            fill={`url(#${hatchId})`}\n          />\n          <rect\n            x={PAD}\n            y={OLD_BASELINE - oldBarH}\n            width={offcutW}\n            height={oldBarH}\n            className=\"fill-current text-ns-muted\"\n            opacity={0.22}\n          />\n          {kerfW > 0 && (\n            <rect\n              x={cutX}\n              y={OLD_BASELINE - oldBarH}\n              width={kerfW}\n              height={oldBarH}\n              className=\"fill-current text-foreground\"\n              opacity={0.35}\n            />\n          )}\n          {showStaticRemnant && remnantVisibleW > 0 && (\n            <rect\n              x={cutX + kerfWRaw}\n              y={OLD_BASELINE - oldBarH}\n              width={remnantVisibleW}\n              height={oldBarH}\n              className=\"fill-current text-foreground\"\n              opacity={0.6}\n            />\n          )}\n          <polyline\n            points={cutWaverPoints}\n            className=\"stroke-current text-foreground\"\n            strokeWidth={2}\n            fill=\"none\"\n            strokeLinejoin=\"round\"\n          />\n          {ticks(PAD, currentPlan.periodDays, OLD_BASELINE)}\n          {kerfW > 0 && (\n            <text\n              x={cutX + kerfW / 2}\n              y={OLD_BASELINE - oldBarH - 8}\n              textAnchor=\"middle\"\n              className=\"fill-current text-ns-muted\"\n              fontSize={7}\n              fontFamily=\"var(--font-mono, monospace)\"\n            >\n              kerf\n            </text>\n          )}\n        </g>\n\n        {/* NEW STRIP */}\n        <g>\n          {selectedPlan ? (\n            <>\n              {selvage(PAD, NEW_BASELINE, newBarH)}\n              {selvage(PAD + newStripW, NEW_BASELINE, newBarH)}\n              <rect\n                x={PAD}\n                y={NEW_BASELINE - newBarH}\n                width={newStripW}\n                height={newBarH}\n                fill={`url(#${hatchId})`}\n              />\n              <rect\n                x={PAD}\n                y={NEW_BASELINE - newBarH}\n                width={newStripW}\n                height={newBarH}\n                fill=\"none\"\n                className=\"stroke-current text-border\"\n                strokeWidth={1}\n                strokeDasharray=\"2 2\"\n              />\n              {displayRect && (\n                <rect\n                  data-remnant-piece\n                  x={displayRect.x}\n                  y={Math.min(displayRect.y, NEW_BASELINE)}\n                  width={displayRect.w}\n                  height={displayRect.h}\n                  className=\"fill-current text-foreground\"\n                  opacity={0.68}\n                />\n              )}\n              {ticks(PAD, selectedPlan.periodDays, NEW_BASELINE)}\n            </>\n          ) : (\n            <rect\n              x={PAD}\n              y={NEW_BASELINE - 22}\n              width={180}\n              height={22}\n              fill=\"none\"\n              className=\"stroke-current text-border\"\n              strokeWidth={1}\n              strokeDasharray=\"4 3\"\n              rx={3}\n            />\n          )}\n        </g>\n      </svg>\n\n      <fieldset className=\"mt-4 border-0 p-0\">\n        <legend className=\"font-mono text-[11px] uppercase tracking-wide text-ns-muted\">{label}</legend>\n        <div className=\"mt-2 flex flex-col gap-1.5\">\n          {plans.map((p) => {\n            const rate = p.price / Math.max(1, p.periodDays);\n            const checked = selectedId === p.id;\n            return (\n              <label\n                key={p.id}\n                className=\"ns-remnant-row relative flex cursor-pointer items-center gap-2.5 rounded-lg px-1.5 py-1.5\"\n              >\n                <input\n                  type=\"radio\"\n                  className=\"ns-remnant-input\"\n                  name={groupName}\n                  value={p.id}\n                  checked={checked}\n                  onChange={() => setSelectedId(p.id)}\n                />\n                <span\n                  aria-hidden=\"true\"\n                  className=\"ns-remnant-visual flex h-4 w-4 flex-none items-center justify-center rounded-full border border-border\"\n                >\n                  {checked && <span className=\"h-2 w-2 rounded-full bg-foreground\" />}\n                </span>\n                <span className=\"flex flex-1 items-baseline justify-between gap-3 text-sm\">\n                  <span className={checked ? \"font-medium text-foreground\" : \"text-ns-muted\"}>{p.name}</span>\n                  <span className=\"font-mono text-[11px] text-ns-muted\">\n                    {fmtMoney(p.price)}/period &middot; {fmtMoney(rate)}/day\n                  </span>\n                </span>\n              </label>\n            );\n          })}\n        </div>\n      </fieldset>\n\n      <p\n        data-remnant-figures\n        role=\"status\"\n        aria-live=\"polite\"\n        className=\"mt-3 font-mono text-[11px] leading-relaxed text-ns-muted\"\n      >\n        {summaryText}\n      </p>\n\n      <button\n        type=\"button\"\n        data-remnant-confirm\n        disabled={!selectedPlan}\n        onClick={handleConfirm}\n        className=\"mt-3 w-full rounded-md border border-border px-3 py-2 text-left font-mono text-[11px] text-foreground transition-colors duration-150 enabled:hover:border-foreground/30 disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ns-accent\"\n      >\n        {confirmText}\n      </button>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/ui/remnant-cut.tsx"
    }
  ],
  "cssVars": {
    "theme": {
      "color-ns-muted": "var(--ns-muted)",
      "color-ns-accent": "var(--ns-accent)"
    },
    "light": {
      "ns-muted": "#4d4d4d",
      "ns-accent": "#006bff"
    },
    "dark": {
      "ns-muted": "#8f8f8f"
    }
  },
  "meta": {
    "collection": "core",
    "tags": [
      "billing",
      "proration",
      "svg",
      "pricing",
      "confirm",
      "radio",
      "physics",
      "accessibility"
    ],
    "instruction": "Renders a plan-change proration readout (RemnantCut) as two horizontal SVG cloth bolts, one governing scalar driving every number and every shape on the first: `cutFrac = elapsedDays / currentPlan.periodDays`. The OLD STRIP is a woven-hatch rect (a small crosshatch `<pattern>`, `text-border` at low opacity) framed by denser 3-line 'selvage' rules at both ends; a dimmed `text-ns-muted` 'offcut' rect covers `[0, cutFrac]` of it (the used days) and a brighter `text-foreground` 'remnant' rect covers the rest (the unused days) until a plan is picked, at which point the remnant is replaced by the animated piece described below. The cut itself is drawn as a 2px `<polyline>` through 8 points with a small perpendicular jitter from a mulberry32 PRNG seeded by a FIXED constant (never derived from props) — so the waver is identical on every render of every input, deliberately: a dead-straight line reads as a CSS border, a wavered one reads as a blade that actually passed through. `creditRaw = (1 - cutFrac) * currentPlan.price` is computed from the exact same `cutFrac` that sized the remnant rect — never a second, independent computation — and is floored to the nearest `roundingUnit` (dollars, default 0.01) to get `creditedAmount`; the difference, `kerf`, is never absorbed silently — it renders as its own thin `text-foreground` sliver rect sitting between the offcut and the remnant at the cut, labelled 'kerf' in small SVG text, sized (with a legibility-only minimum width) from the same amount-to-pixels conversion used everywhere else. offcut + kerf + remnant reconstruct the old strip's full width exactly; credit (2dp) and charge, once rounded to what a bill actually shows, do not sum back to a clean total on purpose — the kerf sliver and its 4-decimal-place `$0.00XX` label are where the missing sub-cent fraction visibly lives. Bar HEIGHT on every strip maps to that plan's daily rate (`price / periodDays`) through one shared `pxPerRate` scale, and width maps to days through one shared `pxPerDay` scale (both computed from every plan in play, so any prop set stays legible) — the product of the two, `K`, is a fixed px-per-dollar constant, meaning a rect's pixel area IS its dollar value everywhere on the panel, not just conceptually but by literal arithmetic identity. Picking a candidate plan (real native `<input type=radio>` rows in a `<fieldset>`/`<legend>`, each a full label with a custom `text-foreground` dot indicator and a sr-only-clipped native input carrying real checked-state semantics) re-measures the SAME `creditedAmount` against that plan's daily rate: `creditedDays = creditedAmount / newDailyRate`, and the remnant animates from its old-strip position/size to a new rect at `x=0` on the new strip and `width = creditedDays * pxPerDay`, `height = newDailyRate * pxPerRate` — reading that final width off the new strip's day ticks gives the exact same day figure the confirm button states. The animation is a single 600ms ease-out-expo (`1 - 2^(-10t)`) progress value driving a `requestAnimationFrame` loop (no CSS transition, since height must be DERIVED not independently tweened): width is linearly interpolated between the start and end widths using the eased t, and height is computed every frame as `creditedAmount * K / width(t)` — since both the start and end rects already satisfy that identity, the rectangle's on-screen area is exactly `creditedAmount * K` at every intermediate frame by construction, not merely at the two endpoints; the vertical baseline and horizontal position are eased the same way so the piece visibly travels from the old row to the new one while it re-shapes. Re-selecting a different plan (or the same one again) always restarts the tween from the old strip's pristine cut position, never chains from wherever the previous tween ended, so every choice re-runs the same shear-and-slide. A permanently-visible (not sr-only) `role=status`/`aria-live=polite` paragraph states the full sentence in plain text on every change — raw credit, days unused, rounded credit, the kerf amount, and once a plan is picked, the day count applied against that plan's rate and the new period's start date — so sighted and assistive-tech readers get identical figures at the identical moment; nothing on the cloth (both SVGs are `aria-hidden`) is interactive or is the source of truth for any number. The Confirm button is a real `<button>` whose visible text states the derived figures outright (e.g. 'Confirm: $8.41 credit, 6.5 days applied, $0.0094 rounding, new period starts Aug 17'), stays disabled with its own accessible 'Select a plan to continue' label until a plan is chosen, and calls `onConfirm` with the full numeric summary. `prefers-reduced-motion: reduce` (via `matchMedia` with a live listener) skips the rAF loop entirely and renders the remnant at its final reflowed rect immediately on selection — fully legible, no motion. Every ink is a token class — `text-foreground`/`text-ns-muted`/`text-border`, `--ns-accent` used solely for the sibling-selector keyboard focus ring on the hidden native radio inputs — no hex, no canvas; pure DOM + SVG + CSS."
  },
  "type": "registry:ui"
}