{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "comparison-slider",
  "type": "registry:component",
  "title": "Comparison Slider",
  "description": "A light section with a draggable divider over two release timelines. Drag or use the arrow keys to reveal how the same stages shrink from weeks to days.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "comparison",
    "comparison",
    "slider",
    "before after",
    "timeline",
    "light",
    "section"
  ],
  "docs": "https://hyperblur.dev/effects/comparison-slider",
  "files": [
    {
      "path": "registry/hyperblur/comparison-slider.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/comparison-slider.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ComparisonSliderStage {\n  label: string;\n  before: { start: number; wait?: number; length: number };\n  after: { start: number; length: number };\n}\n\nexport interface ComparisonSliderSide {\n  label: string;\n  caption: string;\n  total: string;\n}\n\nexport interface ComparisonSliderProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\" | \"onChange\" | \"defaultValue\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  windowTitle?: string;\n  span?: number;\n  stages?: ComparisonSliderStage[];\n  before?: ComparisonSliderSide;\n  after?: ComparisonSliderSide;\n  highlight?: string;\n  value?: number;\n  defaultValue?: number;\n  onChange?: (position: number) => void;\n  accent?: string;\n}\n\nconst defaultStages: ComparisonSliderStage[] = [\n  { label: \"Code freeze\", before: { start: 0, length: 2 }, after: { start: 0, length: 0.3 } },\n  { label: \"Regression tests\", before: { start: 2, wait: 1, length: 5 }, after: { start: 0.3, length: 0.6 } },\n  { label: \"Security review\", before: { start: 8, wait: 2, length: 3 }, after: { start: 0.4, length: 0.6 } },\n  { label: \"Staging soak\", before: { start: 13, length: 3 }, after: { start: 1, length: 0.8 } },\n  { label: \"Release notes\", before: { start: 14, wait: 1, length: 2 }, after: { start: 1.3, length: 0.4 } },\n  { label: \"Rollout\", before: { start: 17, wait: 0.5, length: 2.5 }, after: { start: 1.8, length: 0.7 } },\n];\n\nconst defaultBefore: ComparisonSliderSide = { label: \"Before\", caption: \"Manual QA and handoffs\", total: \"19.5 days, 4 handoffs\" };\nconst defaultAfter: ComparisonSliderSide = { label: \"After\", caption: \"Automated with Pipeline\", total: \"2.5 days, zero handoffs\" };\n\nconst css = `\n.hb-kc7 {\n  --hb-kc7-accent: #6d5dfc;\n  container-type: inline-size;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  background: #f7f5ef;\n  color: #151515;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-kc7 *, .hb-kc7 *::before, .hb-kc7 *::after { box-sizing: border-box; }\n.hb-kc7-inner { max-width: 1120px; margin: 0 auto; padding: 72px 18px 64px; }\n.hb-kc7-head { display: grid; gap: 14px; margin-bottom: 32px; }\n.hb-kc7-eyebrow { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--hb-kc7-accent); font-size: 13px; font-weight: 650; }\n.hb-kc7-eyebrow svg { width: 14px; height: 14px; }\n.hb-kc7-title { margin: 0; max-width: 600px; font-size: clamp(30px, 5cqi, 48px); font-weight: 700; line-height: 1.04; letter-spacing: -.04em; text-wrap: balance; }\n.hb-kc7-sub { margin: 0; max-width: 430px; color: #5c5a54; font-size: 16px; line-height: 1.6; text-wrap: pretty; }\n.hb-kc7-frame {\n  overflow: hidden;\n  border: 1px solid rgba(21, 21, 21, .1);\n  border-radius: 20px;\n  background: #fff;\n  box-shadow: 0 1px 2px rgba(21, 21, 21, .04), 0 30px 70px -36px rgba(21, 21, 21, .35);\n}\n.hb-kc7-bar { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 16px; border-bottom: 1px solid rgba(21, 21, 21, .08); background: #fbfaf7; }\n.hb-kc7-dots { display: flex; gap: 6px; }\n.hb-kc7-dots i { width: 10px; height: 10px; border-radius: 50%; background: #e3e0d8; }\n.hb-kc7-wtitle { color: #6b6962; font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-kc7-compare {\n  position: relative;\n  display: grid;\n  cursor: ew-resize;\n  touch-action: pan-y;\n  user-select: none;\n  -webkit-user-select: none;\n}\n.hb-kc7-layer { grid-area: 1 / 1; padding: 50px 14px 16px; }\n.hb-kc7-layer[data-k=\"before\"] { background: #f3f1ea; }\n.hb-kc7-layer[data-k=\"after\"] { background: #fff; clip-path: inset(0 0 0 var(--hb-kc7-pos)); }\n.hb-kc7-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 10px; }\n.hb-kc7-axis { height: 30px; }\n.hb-kc7-ticks { position: relative; height: 100%; }\n.hb-kc7-ticks span { position: absolute; top: 6px; color: #9a978f; font-size: 10.5px; font-weight: 550; transform: translateX(-50%); white-space: nowrap; }\n.hb-kc7-ticks span:first-child { transform: none; }\n.hb-kc7-ticks span:last-child { transform: translateX(-100%); }\n.hb-kc7-name { overflow: hidden; color: #3b3a36; font-size: 12px; font-weight: 550; white-space: nowrap; text-overflow: ellipsis; }\n.hb-kc7-track {\n  position: relative;\n  height: 38px;\n  border-top: 1px solid rgba(21, 21, 21, .06);\n  background-image: linear-gradient(90deg, rgba(21, 21, 21, .06) 1px, transparent 1px);\n  background-size: calc(100% / var(--hb-kc7-cols)) 100%;\n}\n.hb-kc7-seg { position: absolute; top: 10px; height: 18px; min-width: 8px; border-radius: 6px; }\n.hb-kc7-layer[data-k=\"before\"] .hb-kc7-seg[data-t=\"wait\"] {\n  border-radius: 6px 0 0 6px;\n  background: repeating-linear-gradient(135deg, rgba(196, 78, 60, .28) 0 3px, transparent 3px 7px);\n  box-shadow: inset 0 0 0 1px rgba(196, 78, 60, .25);\n}\n.hb-kc7-layer[data-k=\"before\"] .hb-kc7-seg[data-t=\"work\"] { background: #b9b5aa; }\n.hb-kc7-layer[data-k=\"before\"] .hb-kc7-seg[data-t=\"work\"][data-joined=\"true\"] { border-radius: 0 6px 6px 0; }\n.hb-kc7-layer[data-k=\"after\"] .hb-kc7-seg {\n  background: linear-gradient(90deg, var(--hb-kc7-accent), color-mix(in srgb, var(--hb-kc7-accent) 60%, #fff));\n  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--hb-kc7-accent) 80%, transparent);\n}\n.hb-kc7-total { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(21, 21, 21, .08); font-size: 12.5px; }\n.hb-kc7-total span { color: #6b6962; }\n.hb-kc7-total b { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }\n.hb-kc7-layer[data-k=\"before\"] .hb-kc7-total b { color: #9c3d2e; }\n.hb-kc7-layer[data-k=\"after\"] .hb-kc7-total b { color: var(--hb-kc7-accent); }\n.hb-kc7-hl {\n  position: absolute;\n  right: 18px;\n  top: 50%;\n  max-width: 46%;\n  color: var(--hb-kc7-accent);\n  font-size: clamp(22px, 4cqi, 40px);\n  font-weight: 750;\n  line-height: 1;\n  letter-spacing: -.04em;\n  text-align: right;\n  transform: translateY(-60%);\n  pointer-events: none;\n}\n.hb-kc7-hl small { display: block; margin-top: 8px; color: #8a877f; font-size: 13px; font-weight: 550; letter-spacing: 0; }\n.hb-kc7-label {\n  position: absolute;\n  top: 12px;\n  z-index: 2;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  height: 26px;\n  padding: 0 10px;\n  border-radius: 999px;\n  font-size: 11.5px;\n  font-weight: 650;\n  white-space: nowrap;\n  transition: opacity .25s ease;\n  pointer-events: none;\n}\n.hb-kc7-label[data-k=\"before\"] { left: 12px; background: rgba(21, 21, 21, .78); color: #fff; }\n.hb-kc7-label[data-k=\"after\"] { right: 12px; background: var(--hb-kc7-accent); color: #fff; box-shadow: 0 6px 16px -6px var(--hb-kc7-accent); }\n.hb-kc7-label[data-hidden=\"true\"] { opacity: 0; }\n.hb-kc7-label em { display: none; font-style: normal; font-weight: 500; opacity: .75; }\n.hb-kc7-divider {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: var(--hb-kc7-pos);\n  z-index: 3;\n  width: 2px;\n  margin-left: -1px;\n  background: var(--hb-kc7-accent);\n  box-shadow: 0 0 0 1px rgba(255, 255, 255, .8), 0 0 18px color-mix(in srgb, var(--hb-kc7-accent) 60%, transparent);\n  pointer-events: none;\n}\n.hb-kc7-handle {\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  display: grid;\n  place-items: center;\n  width: 40px;\n  height: 40px;\n  border: 0;\n  border-radius: 50%;\n  background: #fff;\n  color: var(--hb-kc7-accent);\n  box-shadow: 0 0 0 2px var(--hb-kc7-accent), 0 8px 20px -6px rgba(21, 21, 21, .45);\n  transform: translate(-50%, -50%);\n  cursor: ew-resize;\n  pointer-events: auto;\n  transition: transform .2s cubic-bezier(.3, 1.5, .5, 1), box-shadow .2s ease;\n}\n.hb-kc7-handle:hover, .hb-kc7-compare[data-drag=\"true\"] .hb-kc7-handle { transform: translate(-50%, -50%) scale(1.1); }\n.hb-kc7-handle:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--hb-kc7-accent), 0 0 0 6px color-mix(in srgb, var(--hb-kc7-accent) 30%, transparent), 0 8px 20px -6px rgba(21, 21, 21, .45); }\n.hb-kc7-handle svg { width: 20px; height: 20px; }\n.hb-kc7-compare[data-touched=\"false\"] .hb-kc7-handle svg { animation: hb-kc7-nudge 1.8s ease-in-out infinite; }\n.hb-kc7-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 16px 2px 0; color: #6b6962; font-size: 12.5px; }\n.hb-kc7-legend span { display: inline-flex; align-items: center; gap: 8px; }\n.hb-kc7-legend i { width: 18px; height: 8px; border-radius: 3px; }\n@keyframes hb-kc7-nudge {\n  0%, 100% { transform: translateX(0); }\n  25% { transform: translateX(-3px); }\n  75% { transform: translateX(3px); }\n}\n@container (min-width: 720px) {\n  .hb-kc7-inner { padding: 104px 32px 96px; }\n  .hb-kc7-head { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: end; gap: 40px; margin-bottom: 44px; }\n  .hb-kc7-layer { padding: 62px 28px 20px; }\n  .hb-kc7-row { grid-template-columns: 150px minmax(0, 1fr); gap: 18px; }\n  .hb-kc7-name { font-size: 13.5px; }\n  .hb-kc7-track { height: 46px; }\n  .hb-kc7-seg { top: 13px; height: 20px; }\n  .hb-kc7-label { top: 18px; height: 28px; font-size: 12px; }\n  .hb-kc7-label em { font-style: normal; display: inline; }\n  .hb-kc7-label[data-k=\"before\"] { left: 20px; }\n  .hb-kc7-label[data-k=\"after\"] { right: 20px; }\n  .hb-kc7-total { font-size: 13.5px; }\n  .hb-kc7-hl { right: 32px; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-kc7-handle, .hb-kc7-label { transition: none; }\n  .hb-kc7-compare[data-touched=\"false\"] .hb-kc7-handle svg { animation: none; }\n}\n`;\n\nfunction pct(n: number, span: number) {\n  return `${((n / span) * 100).toFixed(3)}%`;\n}\n\nfunction Layer({ kind, stages, span, side, ticks, highlight }: {\n  kind: \"before\" | \"after\";\n  stages: ComparisonSliderStage[];\n  span: number;\n  side: ComparisonSliderSide;\n  ticks: number[];\n  highlight?: string;\n}) {\n  return (\n    <div className=\"hb-kc7-layer\" data-k={kind} aria-hidden={kind === \"after\" ? undefined : true}>\n      <div className=\"hb-kc7-row hb-kc7-axis\">\n        <span />\n        <div className=\"hb-kc7-ticks\">\n          {ticks.map((t) => (\n            <span key={t} style={{ left: pct(t, span) }}>{`Day ${t}`}</span>\n          ))}\n        </div>\n      </div>\n      {stages.map((s) => (\n        <div key={s.label} className=\"hb-kc7-row\">\n          <span className=\"hb-kc7-name\">{s.label}</span>\n          <div className=\"hb-kc7-track\">\n            {kind === \"before\" ? (\n              <>\n                {s.before.wait ? (\n                  <span className=\"hb-kc7-seg\" data-t=\"wait\" style={{ left: pct(s.before.start, span), width: pct(s.before.wait, span) }} />\n                ) : null}\n                <span\n                  className=\"hb-kc7-seg\"\n                  data-t=\"work\"\n                  data-joined={s.before.wait ? \"true\" : \"false\"}\n                  style={{ left: pct(s.before.start + (s.before.wait ?? 0), span), width: pct(s.before.length, span) }}\n                />\n              </>\n            ) : (\n              <span className=\"hb-kc7-seg\" data-t=\"work\" style={{ left: pct(s.after.start, span), width: pct(s.after.length, span) }} />\n            )}\n          </div>\n        </div>\n      ))}\n      <div className=\"hb-kc7-total\">\n        <span>{side.caption}</span>\n        <b>{side.total}</b>\n      </div>\n      {kind === \"after\" && highlight ? (\n        <div className=\"hb-kc7-hl\">\n          {highlight}\n          <small>{side.total}</small>\n        </div>\n      ) : null}\n    </div>\n  );\n}\n\nexport function ComparisonSlider({\n  eyebrow = \"Release timeline\",\n  title = \"Drag to see three weeks become two days\",\n  subtitle = \"The same six release stages for a mobile banking app, before and after Pipeline took over the waiting.\",\n  windowTitle = \"Release plan, Ledger iOS 4.2\",\n  span = 20,\n  stages = defaultStages,\n  before = defaultBefore,\n  after = defaultAfter,\n  highlight = \"17 days back\",\n  value,\n  defaultValue = 52,\n  onChange,\n  accent = \"#6d5dfc\",\n  className = \"\",\n  style,\n  ...rest\n}: ComparisonSliderProps) {\n  const [inner, setInner] = React.useState(defaultValue);\n  const [drag, setDrag] = React.useState(false);\n  const [touched, setTouched] = React.useState(false);\n  const area = React.useRef<HTMLDivElement>(null);\n  const pos = Math.min(100, Math.max(0, value ?? inner));\n\n  const set = (next: number) => {\n    const clamped = Math.min(100, Math.max(0, next));\n    setTouched(true);\n    if (value === undefined) setInner(clamped);\n    onChange?.(clamped);\n  };\n\n  const fromPointer = (clientX: number) => {\n    const el = area.current;\n    if (!el) return;\n    const r = el.getBoundingClientRect();\n    set(((clientX - r.left) / Math.max(1, r.width)) * 100);\n  };\n\n  const onKey = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n    const step = e.shiftKey ? 10 : 2;\n    let next: number | null = null;\n    if (e.key === \"ArrowLeft\" || e.key === \"ArrowDown\") next = pos - step;\n    if (e.key === \"ArrowRight\" || e.key === \"ArrowUp\") next = pos + step;\n    if (e.key === \"PageDown\") next = pos - 10;\n    if (e.key === \"PageUp\") next = pos + 10;\n    if (e.key === \"Home\") next = 0;\n    if (e.key === \"End\") next = 100;\n    if (next === null) return;\n    e.preventDefault();\n    set(next);\n  };\n\n  const ticks = [0, Math.round(span / 4), Math.round(span / 2), Math.round((span * 3) / 4), span];\n  const vars = {\n    \"--hb-kc7-accent\": accent,\n    \"--hb-kc7-pos\": `${pos.toFixed(2)}%`,\n    \"--hb-kc7-cols\": String(Math.max(1, Math.round(span / 2))),\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <section className={`hb-kc7 ${className}`} style={vars} {...rest}>\n      <style href=\"hb-comparison-slider\" precedence=\"default\">{css}</style>\n      <div className=\"hb-kc7-inner\">\n        <div className=\"hb-kc7-head\">\n          <div>\n            {eyebrow ? (\n              <p className=\"hb-kc7-eyebrow\">\n                <svg viewBox=\"0 0 14 14\" aria-hidden=\"true\">\n                  <path d=\"M1.5 7h11M4.5 4l-3 3 3 3M9.5 4l3 3-3 3\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                </svg>\n                {eyebrow}\n              </p>\n            ) : null}\n            <h2 className=\"hb-kc7-title\" style={{ marginTop: eyebrow ? 14 : 0 }}>{title}</h2>\n          </div>\n          {subtitle ? <p className=\"hb-kc7-sub\">{subtitle}</p> : null}\n        </div>\n        <div className=\"hb-kc7-frame\">\n          <div className=\"hb-kc7-bar\">\n            <span className=\"hb-kc7-dots\" aria-hidden=\"true\">\n              <i />\n              <i />\n              <i />\n            </span>\n            <span className=\"hb-kc7-wtitle\">{windowTitle}</span>\n          </div>\n          <div\n            ref={area}\n            className=\"hb-kc7-compare\"\n            data-drag={drag ? \"true\" : \"false\"}\n            data-touched={touched ? \"true\" : \"false\"}\n            onPointerDown={(e) => {\n              if (e.button !== 0) return;\n              e.currentTarget.setPointerCapture(e.pointerId);\n              setDrag(true);\n              fromPointer(e.clientX);\n            }}\n            onPointerMove={(e) => {\n              if (drag) fromPointer(e.clientX);\n            }}\n            onPointerUp={(e) => {\n              if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n              setDrag(false);\n            }}\n            onPointerCancel={() => setDrag(false)}\n          >\n            <Layer kind=\"before\" stages={stages} span={span} side={before} ticks={ticks} />\n            <Layer kind=\"after\" stages={stages} span={span} side={after} ticks={ticks} highlight={highlight} />\n            <span className=\"hb-kc7-label\" data-k=\"before\" data-hidden={pos < 22 ? \"true\" : \"false\"}>\n              {before.label}\n              <em>{before.caption}</em>\n            </span>\n            <span className=\"hb-kc7-label\" data-k=\"after\" data-hidden={pos > 78 ? \"true\" : \"false\"}>\n              {after.label}\n              <em>{after.caption}</em>\n            </span>\n            <div className=\"hb-kc7-divider\">\n              <button\n                type=\"button\"\n                className=\"hb-kc7-handle\"\n                role=\"slider\"\n                aria-label={`Compare ${before.label.toLowerCase()} and ${after.label.toLowerCase()}`}\n                aria-valuemin={0}\n                aria-valuemax={100}\n                aria-valuenow={Math.round(pos)}\n                aria-valuetext={`${Math.round(pos)}% ${before.label}, ${100 - Math.round(pos)}% ${after.label}`}\n                onKeyDown={onKey}\n              >\n                <svg viewBox=\"0 0 20 20\" aria-hidden=\"true\">\n                  <path d=\"M7.5 5.5L3 10l4.5 4.5M12.5 5.5L17 10l-4.5 4.5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                </svg>\n              </button>\n            </div>\n          </div>\n        </div>\n        <div className=\"hb-kc7-legend\" aria-hidden=\"true\">\n          <span>\n            <i style={{ background: \"repeating-linear-gradient(135deg, rgba(196, 78, 60, .35) 0 3px, transparent 3px 7px)\", boxShadow: \"inset 0 0 0 1px rgba(196, 78, 60, .3)\" }} />\n            Waiting on someone\n          </span>\n          <span>\n            <i style={{ background: \"#b9b5aa\" }} />\n            Manual work\n          </span>\n          <span>\n            <i style={{ background: accent }} />\n            Automated\n          </span>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}