{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "zipper-stall",
  "title": "Zipper Stall",
  "description": "Merge resolution staged as closing a zipper: two columns of timestamped edit ops, meshed by dragging a handle down the spine that physically jams at the first same-offset conflict until you pick a side.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/core/zipper-stall/component.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\n\n// ---------------------------------------------------------------------------\n// ZipperStall — merge resolution staged as closing a zipper. Two columns of\n// teeth (your ops, their ops), one operation per tooth, laid down the spine\n// in arrival order. A single scalar, closureY (px down the spine), governs\n// everything: which teeth have meshed flush to the spine, where the drag\n// handle sits, the merged-count readout, and which conflict (if any) is\n// live. There is no per-tooth animation clock — a tooth's transform is a\n// pure function of closureY crossing its row's center, expressed as a CSS\n// transition on a state flip, so scrubbing the handle back deterministically\n// re-opens teeth in the same order they closed.\n//\n// A conflict is two ops that land on the same document offset — they share\n// a row and neither can mesh until the human picks a side. The real\n// mechanism for \"the slider physically cannot pass a conflict\" is that the\n// native <input type=\"range\"> always spans the FULL spine in its min/max\n// (so the handle's pixel position always corresponds to real row geometry),\n// while the COMMITTED value is clamped in JS to conflictCenter - 8px. Native\n// max never shrinks — only the reachable value does — which is what keeps\n// \"where it stops\" honest against the rows actually drawn underneath it,\n// rather than a max attribute that would silently rescale the whole track.\n// A parallel signal (the raw value reported by the same change event, before\n// clamping) drives a small 0-3px \"jam\" bump on the decorative handle cap via\n// a k=500 spring, so pushing past the wall reads as resistance, not a wall\n// that silently swallows input. prefers-reduced-motion turns that spring\n// into a single instant border flash instead.\n//\n// A11y: the range input is real (native min/max/step, arrow/Home/End work),\n// carries aria-valuetext (\"12 of 14 ops merged, stopped at conflict 1 of\n// 3\"). The spine itself is a plain <ol>, one <li> per row, each named for\n// screen readers (\"theirs, 14:02, replaced heading\"; conflicts name both\n// sides plus resolution status). Resolution is two real <button>s that\n// appear only once the handle is actually jammed against that row, so a\n// prior programmatic click on the handle (which jumps value like any native\n// range) still leaves the same buttons re-derivable and clickable.\n// ---------------------------------------------------------------------------\n\nexport type ZipperSide = \"ours\" | \"theirs\";\n\nexport interface ZipperOp {\n  /** stable id */\n  id: string;\n  /** which edit stream this op came from */\n  side: ZipperSide;\n  /** arrival order — lower sorts first; ties are fine */\n  t: number;\n  /** display timestamp, e.g. \"14:02\" — pre-formatted, never Date-derived, so\n   * server and client render byte-identical text */\n  timestamp: string;\n  /** document offset this op targets. two ops sharing an offset conflict. */\n  offset: number;\n  /** short description, e.g. \"replaced heading\" */\n  label: string;\n}\n\nexport interface ZipperStallProps {\n  /** the two edit streams, unsorted — sorted internally by t */\n  ops: ZipperOp[];\n  /** column heading over the left (ours) teeth */\n  oursLabel?: string;\n  /** column heading over the right (theirs) teeth */\n  theirsLabel?: string;\n  /** px height of one row / one tooth */\n  rowHeight?: number;\n  /** called every time a conflict is resolved */\n  onResolve?: (kept: ZipperOp, droppedOp: ZipperOp) => void;\n  /** called once the spine is fully closed with nothing left pending */\n  onComplete?: () => void;\n  /** extra classes merged onto the rendered root element */\n  className?: string;\n}\n\ntype Row = {\n  key: string;\n  offset: number;\n  ours?: ZipperOp;\n  theirs?: ZipperOp;\n  conflict: boolean;\n  center: number; // px, along the spine\n};\n\nconst TRACK_W = 28;\nconst CLAMP_GAP = 8;\nconst BUMP_MAX = 3;\nconst BUMP_GAIN = 0.6; // px raw overrun -> px of visible bump, pre-clamp\nconst SPRING_K = 500; // s^-2\nconst SPRING_ZETA = 0.5;\nconst FLASH_MS = 150;\n\nfunction buildRows(ops: ZipperOp[]): Row[] {\n  const sorted = [...ops].sort((a, b) => a.t - b.t);\n  const rows: Row[] = [];\n  const rowForOffset = new Map<number, number>();\n  for (const op of sorted) {\n    const existingIdx = rowForOffset.get(op.offset);\n    const existing = existingIdx !== undefined ? rows[existingIdx] : undefined;\n    if (existing && !existing[op.side]) {\n      existing[op.side] = op;\n      existing.conflict = !!existing.ours && !!existing.theirs;\n      continue;\n    }\n    const row: Row = {\n      key: `${op.offset}-${rows.length}`,\n      offset: op.offset,\n      conflict: false,\n      center: 0,\n      [op.side]: op,\n    } as Row;\n    rowForOffset.set(op.offset, rows.length);\n    rows.push(row);\n  }\n  return rows;\n}\n\nfunction clamp(v: number, lo: number, hi: number) {\n  return Math.min(hi, Math.max(lo, v));\n}\n\nexport function ZipperStall({\n  ops,\n  oursLabel = \"Yours\",\n  theirsLabel = \"Theirs\",\n  rowHeight = 44,\n  onResolve,\n  onComplete,\n  className = \"\",\n}: ZipperStallProps) {\n  const uid = useId();\n  const ROW_H = rowHeight > 0 ? rowHeight : 44;\n\n  const rows = useMemo(() => {\n    const built = buildRows(ops);\n    return built.map((r, i) => ({ ...r, center: i * ROW_H + ROW_H / 2 }));\n  }, [ops, ROW_H]);\n\n  const spineHeight = rows.length * ROW_H;\n  const totalOps = ops.length;\n\n  const [closureY, setClosureY] = useState(0);\n  const [resolved, setResolved] = useState<Record<string, ZipperSide>>({});\n  const [bump, setBump] = useState(0);\n  const [flash, setFlash] = useState(false);\n  const [announce, setAnnounce] = useState(\"\");\n  const [focused, setFocused] = useState(false);\n  const [hovering, setHovering] = useState(false);\n  const [pressed, setPressed] = useState(false);\n\n  const closureYRef = useRef(closureY);\n  closureYRef.current = closureY;\n\n  const reducedRef = useRef(false);\n  useEffect(() => {\n    const mq = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    reducedRef.current = mq.matches;\n    const onChange = () => {\n      reducedRef.current = mq.matches;\n    };\n    mq.addEventListener(\"change\", onChange);\n    return () => mq.removeEventListener(\"change\", onChange);\n  }, []);\n\n  const conflictRows = useMemo(() => rows.filter((r) => r.conflict), [rows]);\n  const firstUnresolvedConflict = useMemo(\n    () => conflictRows.find((r) => !resolved[r.key]),\n    [conflictRows, resolved]\n  );\n  const effectiveMax = firstUnresolvedConflict\n    ? Math.max(0, firstUnresolvedConflict.center - CLAMP_GAP)\n    : spineHeight;\n  const jammed = firstUnresolvedConflict !== undefined && closureY >= effectiveMax;\n\n  const mergedCount = useMemo(() => {\n    let n = 0;\n    for (const row of rows) {\n      if (row.conflict) {\n        // a resolved conflict is two decided ops (the kept one meshed, the\n        // dropped one filed down) — both count toward the total, since the\n        // filed-down tooth is a decided record, not an unmerged one.\n        const side = resolved[row.key];\n        if (side && closureY >= row.center) n += 2;\n      } else if (closureY >= row.center) {\n        n += 1;\n      }\n    }\n    return n;\n  }, [rows, resolved, closureY]);\n\n  const completedRef = useRef(false);\n  useEffect(() => {\n    const allResolved = conflictRows.every((r) => resolved[r.key]);\n    const done = allResolved && closureY >= spineHeight && spineHeight > 0;\n    if (done && !completedRef.current) {\n      completedRef.current = true;\n      setAnnounce(`Merge complete: ${totalOps} of ${totalOps} ops merged.`);\n      onComplete?.();\n    } else if (!done) {\n      completedRef.current = false;\n    }\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [closureY, resolved, conflictRows, spineHeight]);\n\n  // -- bump / flash engine (excess drag past the clamp, purely visual) -----\n  const excessRef = useRef(0);\n  const bumpRef = useRef(0);\n  const bumpVelRef = useRef(0);\n  const rafRef = useRef(0);\n  const flashTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(\n    undefined\n  );\n  // excess decays on its own ~100ms after the last push registers it, so a\n  // single keypress or a drag that ends mid-push still springs back instead\n  // of sitting jammed forever waiting for a change event that never comes\n  const excessDecayRef = useRef<ReturnType<typeof setTimeout> | undefined>(\n    undefined\n  );\n\n  useEffect(() => {\n    return () => {\n      if (rafRef.current) cancelAnimationFrame(rafRef.current);\n      if (flashTimerRef.current) clearTimeout(flashTimerRef.current);\n      if (excessDecayRef.current) clearTimeout(excessDecayRef.current);\n    };\n  }, []);\n\n  const wakeSpring = () => {\n    if (rafRef.current) return;\n    let last = performance.now();\n    const tick = (now: number) => {\n      const dt = Math.min(0.032, Math.max(0, (now - last) / 1000));\n      last = now;\n      const target = clamp(excessRef.current * BUMP_GAIN, 0, BUMP_MAX);\n      const c = 2 * SPRING_ZETA * Math.sqrt(SPRING_K);\n      const disp = bumpRef.current - target;\n      bumpVelRef.current += (-SPRING_K * disp - c * bumpVelRef.current) * dt;\n      bumpRef.current += bumpVelRef.current * dt;\n      if (\n        Math.abs(bumpRef.current - target) < 0.05 &&\n        Math.abs(bumpVelRef.current) < 1 &&\n        excessRef.current === 0\n      ) {\n        bumpRef.current = 0;\n        bumpVelRef.current = 0;\n        setBump(0);\n        rafRef.current = 0;\n        return;\n      }\n      setBump(bumpRef.current);\n      rafRef.current = requestAnimationFrame(tick);\n    };\n    rafRef.current = requestAnimationFrame(tick);\n  };\n\n  const registerExcess = (excess: number) => {\n    excessRef.current = excess;\n    if (excessDecayRef.current) clearTimeout(excessDecayRef.current);\n    if (excess > 0) {\n      excessDecayRef.current = setTimeout(() => {\n        excessRef.current = 0;\n        if (!reducedRef.current) wakeSpring();\n      }, 100);\n    }\n    if (excess <= 0 && bumpRef.current === 0) return;\n    if (reducedRef.current) {\n      if (excess > 0) {\n        setFlash(true);\n        if (flashTimerRef.current) clearTimeout(flashTimerRef.current);\n        flashTimerRef.current = setTimeout(() => setFlash(false), FLASH_MS);\n      }\n      return;\n    }\n    wakeSpring();\n  };\n\n  const commit = (raw: number) => {\n    const bounded = clamp(raw, 0, spineHeight);\n    const excess = Math.max(0, bounded - effectiveMax);\n    registerExcess(excess);\n    const next = Math.min(bounded, effectiveMax);\n    if (next !== closureYRef.current) setClosureY(next);\n  };\n\n  const inputRef = useRef<HTMLInputElement>(null);\n  const draggingRef = useRef(false);\n\n  // authoritative pointer math — kept independent of native drag-to-value so\n  // synthetic pointer events (the autoplay driver, dispatched programmatically\n  // via dispatchEvent) drive the same commit() path a real drag does; a real\n  // browser's own native slider-drag would otherwise never see a synthetic\n  // pointerdown/move as a drag gesture at all.\n  const rawFromClientY = (clientY: number) => {\n    const rect = inputRef.current?.getBoundingClientRect();\n    if (!rect || rect.height <= 0) return closureYRef.current;\n    return ((clientY - rect.top) / rect.height) * spineHeight;\n  };\n\n  const onPointerDownInput = (e: React.PointerEvent<HTMLInputElement>) => {\n    draggingRef.current = true;\n    setPressed(true);\n    e.currentTarget.setPointerCapture(e.pointerId);\n    commit(rawFromClientY(e.clientY));\n  };\n  const onPointerMoveInput = (e: React.PointerEvent<HTMLInputElement>) => {\n    if (!draggingRef.current) return;\n    commit(rawFromClientY(e.clientY));\n  };\n  const endDrag = () => {\n    draggingRef.current = false;\n    setPressed(false);\n    if (excessDecayRef.current) clearTimeout(excessDecayRef.current);\n    excessRef.current = 0;\n    if (!reducedRef.current) wakeSpring();\n  };\n\n  const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n    // fallback for any change the pointer/keyboard handlers above didn't\n    // already cover (e.g. an assistive-tech-driven value set)\n    commit(Number(e.target.value));\n  };\n\n  const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n    const v = closureYRef.current;\n    let next: number | null = null;\n    switch (e.key) {\n      case \"ArrowDown\":\n      case \"ArrowRight\":\n        next = v + ROW_H;\n        break;\n      case \"ArrowUp\":\n      case \"ArrowLeft\":\n        next = v - ROW_H;\n        break;\n      case \"PageDown\":\n        next = v + ROW_H * 3;\n        break;\n      case \"PageUp\":\n        next = v - ROW_H * 3;\n        break;\n      case \"Home\":\n        next = 0;\n        break;\n      case \"End\":\n        next = spineHeight;\n        break;\n      default:\n        return;\n    }\n    e.preventDefault();\n    commit(next);\n  };\n\n  const resolve = (row: Row, side: ZipperSide) => {\n    if (!row.ours || !row.theirs || resolved[row.key]) return;\n    const kept = side === \"ours\" ? row.ours : row.theirs;\n    const dropped = side === \"ours\" ? row.theirs : row.ours;\n    setResolved((r) => ({ ...r, [row.key]: side }));\n    setAnnounce(\n      `Kept ${kept.side}, ${kept.timestamp}, ${kept.label}. ${dropped.side} version struck through, not taken.`\n    );\n    onResolve?.(kept, dropped);\n    inputRef.current?.focus({ preventScroll: true });\n  };\n\n  const conflictIndex = firstUnresolvedConflict\n    ? conflictRows.indexOf(firstUnresolvedConflict) + 1\n    : 0;\n  const valueText = jammed\n    ? `${mergedCount} of ${totalOps} ops merged, stopped at conflict ${conflictIndex} of ${conflictRows.length}`\n    : `${mergedCount} of ${totalOps} ops merged`;\n\n  const capY = closureY + bump;\n\n  return (\n    <div className={`w-full max-w-2xl font-mono ${className}`}>\n      <style>{`\n.zs-tooth{transition:transform 90ms cubic-bezier(0.16,1,0.3,1),opacity 90ms cubic-bezier(0.16,1,0.3,1),color 90ms linear;}\n.zs-fold{transition:transform 160ms cubic-bezier(0.16,1,0.3,1),opacity 160ms cubic-bezier(0.16,1,0.3,1);}\n.zs-cap{transition:background-color 120ms linear,box-shadow 120ms linear;}\n.zs-flash{transition:border-color 60ms linear;}\n@media (prefers-reduced-motion: reduce){\n  .zs-tooth,.zs-fold,.zs-cap{transition:none;}\n}\n`}</style>\n\n      <div className=\"mb-3 flex items-baseline justify-between gap-3\">\n        <div>\n          <p className=\"text-[10px] uppercase tracking-[0.2em] text-ns-muted\">\n            merge closure\n          </p>\n          <p className=\"mt-0.5 text-xs text-ns-muted\" aria-hidden>\n            {jammed\n              ? `stopped at conflict ${conflictIndex} of ${conflictRows.length}`\n              : `${mergedCount} / ${totalOps} ops merged`}\n          </p>\n        </div>\n        <div className=\"grid grid-cols-[1fr_28px_1fr] gap-1 px-2 text-[10px] uppercase tracking-[0.15em] text-ns-muted\">\n          <span className=\"text-right\">{oursLabel}</span>\n          <span aria-hidden />\n          <span className=\"text-left\">{theirsLabel}</span>\n        </div>\n      </div>\n\n      <div className=\"relative\" style={{ height: spineHeight }}>\n        <ol\n          className=\"relative list-none divide-y divide-border/60 rounded-md border border-border\"\n          aria-label=\"Merge operations, in arrival order\"\n        >\n          {rows.map((row) => (\n            <li\n              key={row.key}\n              style={{ height: ROW_H }}\n              className=\"grid grid-cols-[1fr_28px_1fr] items-center gap-1 px-2\"\n              aria-label={rowAriaLabel(row, resolved[row.key])}\n            >\n              <div className=\"flex justify-end\">\n                {row.ours ? (\n                  <Tooth\n                    op={row.ours}\n                    align=\"right\"\n                    state={toothState(row, \"ours\", closureY, resolved)}\n                  />\n                ) : null}\n              </div>\n              <div aria-hidden />\n              <div className=\"flex justify-start\">\n                {row.theirs ? (\n                  <Tooth\n                    op={row.theirs}\n                    align=\"left\"\n                    state={toothState(row, \"theirs\", closureY, resolved)}\n                  />\n                ) : null}\n              </div>\n            </li>\n          ))}\n        </ol>\n\n        {/* decorative spine: rail, fill, and the visual handle cap — all\n            pure functions of closureY/bump, no independent animation */}\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-y-0 left-1/2\"\n          style={{ width: TRACK_W, transform: \"translateX(-50%)\" }}\n        >\n          <div\n            className=\"absolute left-1/2 top-0 bottom-0 w-px\"\n            style={{ transform: \"translateX(-50%)\", backgroundColor: \"var(--border)\" }}\n          />\n          <div\n            className=\"absolute left-1/2 top-0 w-px\"\n            style={{\n              height: capY,\n              transform: \"translateX(-50%)\",\n              backgroundColor: \"var(--foreground)\",\n              opacity: 0.5,\n            }}\n          />\n          <div\n            className={`zs-cap zs-flash absolute left-1/2 rounded-full border ${\n              flash ? \"border-ns-accent\" : \"border-border\"\n            }`}\n            style={{\n              top: capY,\n              width: TRACK_W,\n              height: 18,\n              transform: \"translate(-50%, -50%)\",\n              backgroundColor:\n                focused || hovering || pressed\n                  ? \"var(--ns-accent)\"\n                  : \"var(--foreground)\",\n              boxShadow: focused\n                ? \"0 0 0 2px var(--background), 0 0 0 4px var(--ns-accent)\"\n                : \"none\",\n            }}\n          />\n        </div>\n\n        {/* the real control — spans the full spine so its pixel position\n            always maps to the rows actually drawn beneath it; the reachable\n            VALUE is clamped in JS, the native max never shrinks */}\n        <input\n          ref={inputRef}\n          type=\"range\"\n          min={0}\n          max={spineHeight}\n          step={1}\n          value={closureY}\n          data-zipper-input\n          aria-label=\"Merge closure\"\n          aria-valuemin={0}\n          aria-valuemax={effectiveMax}\n          aria-valuenow={closureY}\n          aria-valuetext={valueText}\n          onChange={onChange}\n          onKeyDown={onKeyDown}\n          onFocus={() => setFocused(true)}\n          onBlur={() => setFocused(false)}\n          onPointerEnter={() => setHovering(true)}\n          onPointerLeave={() => setHovering(false)}\n          onPointerDown={onPointerDownInput}\n          onPointerMove={onPointerMoveInput}\n          onPointerUp={endDrag}\n          onPointerCancel={endDrag}\n          className=\"absolute cursor-ns-resize touch-none appearance-none bg-transparent opacity-0 outline-none\"\n          style={{\n            top: \"50%\",\n            left: \"50%\",\n            width: spineHeight,\n            height: TRACK_W,\n            margin: 0,\n            transform: \"translate(-50%, -50%) rotate(90deg)\",\n          }}\n        />\n\n        {/* resolution: two real buttons, only present once the handle is\n            genuinely jammed against this row. z-20 keeps them clickable\n            above the full-height transparent input they visually sit atop. */}\n        {jammed && firstUnresolvedConflict?.ours && firstUnresolvedConflict?.theirs ? (\n          <div\n            className=\"absolute left-1/2 z-20 flex -translate-x-1/2 -translate-y-1/2 gap-1.5\"\n            style={{ top: firstUnresolvedConflict.center }}\n          >\n            <button\n              type=\"button\"\n              data-zipper-choice\n              onClick={() => resolve(firstUnresolvedConflict, \"ours\")}\n              className=\"whitespace-nowrap rounded-full border border-border bg-background px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-foreground transition-colors hover:border-ns-accent hover:text-ns-accent focus-visible:border-ns-accent focus-visible:text-ns-accent focus-visible:ring-2 focus-visible:ring-ns-accent\"\n            >\n              Keep {oursLabel.toLowerCase()}\n            </button>\n            <button\n              type=\"button\"\n              data-zipper-choice\n              onClick={() => resolve(firstUnresolvedConflict, \"theirs\")}\n              className=\"whitespace-nowrap rounded-full border border-border bg-background px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-foreground transition-colors hover:border-ns-accent hover:text-ns-accent focus-visible:border-ns-accent focus-visible:text-ns-accent focus-visible:ring-2 focus-visible:ring-ns-accent\"\n            >\n              Keep {theirsLabel.toLowerCase()}\n            </button>\n          </div>\n        ) : null}\n      </div>\n\n      <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n        {announce}\n      </p>\n\n      <p className=\"mt-2 text-[11px] text-ns-muted\">\n        drag, or arrow keys, down the spine to merge · a stall means pick a\n        side before it can continue\n      </p>\n      <p className=\"sr-only\" id={`${uid}-hint`}>\n        Struck-through rows are edits that were not taken; they stay in the\n        list as a permanent record.\n      </p>\n    </div>\n  );\n}\n\nfunction toothState(\n  row: Row,\n  side: ZipperSide,\n  closureY: number,\n  resolved: Record<string, ZipperSide>\n): \"pending\" | \"meshed\" | \"kept\" | \"folded\" {\n  if (!row.conflict) {\n    return closureY >= row.center ? \"meshed\" : \"pending\";\n  }\n  const winner = resolved[row.key];\n  if (!winner) return \"pending\";\n  if (winner === side) return closureY >= row.center ? \"kept\" : \"pending\";\n  return \"folded\";\n}\n\nfunction rowAriaLabel(row: Row, winner: ZipperSide | undefined): string {\n  if (!row.conflict) {\n    const op = (row.ours ?? row.theirs) as ZipperOp;\n    return `${op.side}, ${op.timestamp}, ${op.label}`;\n  }\n  const a = row.ours as ZipperOp;\n  const b = row.theirs as ZipperOp;\n  const status = winner\n    ? `resolved, kept ${winner}`\n    : \"conflict, unresolved, stalls the merge here\";\n  return `ours, ${a.timestamp}, ${a.label}; theirs, ${b.timestamp}, ${b.label} — ${status}`;\n}\n\nfunction Tooth({\n  op,\n  align,\n  state,\n}: {\n  op: ZipperOp;\n  align: \"left\" | \"right\";\n  state: \"pending\" | \"meshed\" | \"kept\" | \"folded\";\n}) {\n  const dx = align === \"right\" ? 16 : -16;\n  const isFolded = state === \"folded\";\n  const flush = state === \"meshed\" || state === \"kept\";\n\n  if (isFolded) {\n    return (\n      <div\n        className=\"zs-fold max-w-[11rem] truncate rounded-md px-1.5 py-0.5 text-[11px]\"\n        style={{ transform: \"translateX(0) scaleY(0.5)\", opacity: 0.7 }}\n        title={`${op.timestamp} · ${op.label} · not taken`}\n      >\n        <s className=\"text-ns-muted decoration-1\">{op.label}</s>\n        <span className=\"ml-1 text-[9px] uppercase tracking-wide text-ns-muted\">\n          not taken\n        </span>\n      </div>\n    );\n  }\n\n  return (\n    <div\n      className=\"zs-tooth max-w-[11rem] truncate rounded-md border px-1.5 py-1 text-[11px]\"\n      style={{\n        transform: `translateX(${flush ? 0 : dx}px)`,\n        borderColor: flush ? \"transparent\" : \"var(--border)\",\n        color: flush ? \"var(--foreground)\" : \"var(--ns-muted)\",\n      }}\n      title={`${op.timestamp} · ${op.label}`}\n    >\n      <span className=\"tabular-nums text-ns-muted\">{op.timestamp}</span>{\" \"}\n      {op.label}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/ui/zipper-stall.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": [
      "merge",
      "diff",
      "conflict-resolution",
      "slider",
      "range",
      "drag",
      "ordered-list",
      "version-control"
    ],
    "instruction": "Build a merge-resolution control where two edit streams (ours, theirs) render as two columns of 'teeth' down a shared spine, one operation per tooth, and a single scalar — closureY, px down the spine — is the ONLY thing that drives every tooth's meshed/open state, the drag handle's position, the merged-op count, and which conflict (if any) is currently live; there must be no per-tooth animation clock, since independently-timed teeth could mesh out of arrival order and misrepresent causality. DATA: ops are {id, side, t (arrival order), timestamp (pre-formatted display string, never Date-derived, so server/client render identically), offset (document position), label}. Sort by t, then group into rows keyed by offset: the first op seen at an offset creates a row at the next spine position; a second op arriving later at the SAME offset joins that row on the other side and marks it a conflict — this is the only conflict condition. GEOMETRY: rows are fixed-height (rowHeight, default 44px) list items; row i's mesh threshold (center) is i*rowHeight + rowHeight/2; spineHeight is rows.length*rowHeight. MESHING: a non-conflict tooth is 'meshed' (flush, translateX 0) exactly when closureY >= its row's center, else it sits at a resting column offset of +-16px; that boolean flip drives a 90ms ease-out-expo (cubic-bezier(0.16,1,0.3,1)) CSS transition on transform/opacity/color — nothing else times it, so scrubbing the handle backward deterministically re-opens every tooth in reverse. A conflict row's teeth stay at their +-16px resting offset forever, regardless of closureY, until resolved. THE STALL: the native <input type=range> driving closureY always has min=0, max=spineHeight (constant, never rescaled) so its pixel position always corresponds to the real rows drawn underneath it; the COMMITTED value is clamped in the onChange/keydown handler to at most (firstUnresolvedConflict.center - 8px). Never shrink the native max to fake this — that would silently rescale the whole track and break 'the handle's position IS the row it's stuck at'. The SAME change event's raw (pre-clamp) value drives a 0-3px 'jam' bump on a decorative handle-cap element via a critically-adjacent spring (k=500 s^-2, zeta=0.5, semi-implicit Euler, rAF loop that tears down once settled) so pushing past the wall reads as resistance, not a control that silently stopped responding. RESOLUTION: once jammed, two real <button>s ('keep yours' / 'keep theirs') render inline at that row (a relatively-positioned wrapper at z-index above the full-height transparent input, since the buttons sit inside the same narrow center column the drag control spans); clicking one sets that row's resolved side, fires onResolve(kept, dropped), returns focus to the range input, and announces the decision through a role=status aria-live=polite region. The chosen op then meshes exactly like any normal tooth (closureY vs its row's center, same transition); the OTHER op immediately and permanently transitions to a folded state — scaleY(0.5), reduced opacity, its label in a <s> strikethrough, captioned 'not taken' — that never depends on closureY again and is never removed from the list, since it's a genuine one-way decision, not something scrubbing should undo. Resolving unblocks the max for whatever conflict comes next, if any. KEYBOARD: the input's own onKeyDown intercepts ArrowDown/Right (+1 row), ArrowUp/Left (-1 row), PageDown/PageUp (+-3 rows), Home/End (0 / spineHeight), each going through the exact same commit()-and-clamp path as pointer dragging — native default stepping is preempted so 'down' always means 'more closure' regardless of the control's visual rotation. A11Y: aria-label 'Merge closure', aria-valuemin/now explicit, aria-valuemax explicitly set to the CURRENT reachable max (not the nominal spine total) so assistive tech reports the real boundary, aria-valuetext formatted as '{merged} of {total} ops merged' or, while jammed, '{merged} of {total} ops merged, stopped at conflict {n} of {N}'. The spine is a plain <ol> — one <li> per row — each with an aria-label naming its op(s): 'theirs, 14:02, replaced heading' for a normal row, both sides plus resolution status ('conflict, unresolved, stalls the merge here' or 'resolved, kept ours') for a conflict row. VISUAL: the native input is full-height, fully transparent (opacity 0, outline none) and rotated 90deg via a centered CSS transform (translate(-50%,-50%) rotate(90deg) on a box whose pre-rotation width equals spineHeight) so native click-to-position and drag physics work correctly against the real rotated geometry; every visible pixel (rail, fill, handle cap, focus ring) is a separate aria-hidden decorative layer computed straight from closureY/bump/focus/hover/press React state, tokens only (var(--foreground) resting, var(--ns-accent) only while focused/hovered/pressed, var(--border) for rails and idle tooth borders, var(--ns-muted) for idle tooth text and folded rows). REDUCED MOTION: the spring loop is replaced outright by a single ~150ms border-color flash on the handle cap (no rAF, a setTimeout toggle) and all tooth transitions become instant via a prefers-reduced-motion media query zeroing their transition property — the merge is fully readable and resolvable with zero animation."
  },
  "type": "registry:ui"
}