{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "local-before-after",
  "type": "registry:component",
  "title": "Local Before and After",
  "description": "A draggable, keyboard accessible before and after slider with two illustrated kitchen scenes, caption chips and a strip of project results.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "local",
    "before after",
    "compare",
    "slider",
    "renovation",
    "results",
    "portfolio"
  ],
  "docs": "https://hyperblur.dev/effects/local-before-after",
  "files": [
    {
      "path": "registry/hyperblur/local-before-after.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/local-before-after.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface LocalBeforeAfterStat {\n  value: string;\n  label: string;\n}\n\nexport interface LocalBeforeAfterProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\" | \"onChange\" | \"defaultValue\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  beforeLabel?: string;\n  afterLabel?: string;\n  before?: React.ReactNode;\n  after?: React.ReactNode;\n  value?: number;\n  defaultValue?: number;\n  onChange?: (value: number) => void;\n  stats?: LocalBeforeAfterStat[];\n  cta?: { label: string; href: string };\n  accent?: string;\n}\n\nconst defaultStats: LocalBeforeAfterStat[] = [\n  { value: \"6 weeks\", label: \"From demo to dinner party\" },\n  { value: \"+40%\", label: \"More storage, same footprint\" },\n  { value: \"$38,400\", label: \"Final cost, on budget\" },\n  { value: \"4.9\", label: \"Average from 212 homeowners\" },\n];\n\nconst css = `\n.hb-kl7 {\n  --hb-kl7-accent: #d9a35b;\n  box-sizing: border-box;\n  width: 100%;\n  container-type: inline-size;\n  background: #121110;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-kl7 *, .hb-kl7 *::before, .hb-kl7 *::after { box-sizing: border-box; }\n.hb-kl7-wrap { max-width: 1120px; margin: 0 auto; padding: 88px 24px 96px; }\n.hb-kl7-head { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 32px; align-items: end; margin-bottom: 36px; }\n.hb-kl7-eyebrow { margin: 0 0 14px; color: var(--hb-kl7-accent); font-size: 12.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }\n.hb-kl7-title { margin: 0; font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif); font-weight: 400; font-size: clamp(38px, 5.4cqw, 62px); line-height: 1; letter-spacing: -.02em; color: #f4efe7; text-wrap: balance; }\n.hb-kl7-side { color: #a39d93; font-size: 16px; line-height: 1.6; }\n.hb-kl7-side p { margin: 0 0 18px; }\n.hb-kl7-cta { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 999px; background: #f4efe7; color: #121110; font-size: 14.5px; font-weight: 600; text-decoration: none; transition: background .2s, transform .2s; }\n.hb-kl7-cta:hover { background: var(--hb-kl7-accent); transform: translateY(-1px); }\n.hb-kl7-cta:focus-visible { outline: 2px solid var(--hb-kl7-accent); outline-offset: 3px; }\n.hb-kl7-stage { position: relative; aspect-ratio: 16 / 8.2; border-radius: 24px; overflow: hidden; border: 1px solid rgba(255,255,255,.08); background: #1b1a18; user-select: none; touch-action: pan-y; cursor: ew-resize; box-shadow: 0 40px 80px -40px rgba(0,0,0,.8); }\n.hb-kl7-layer { position: absolute; inset: 0; }\n.hb-kl7-layer > svg { width: 100%; height: 100%; display: block; }\n.hb-kl7-after { clip-path: inset(0 0 0 var(--hb-kl7-pos)); }\n.hb-kl7-chip { position: absolute; top: 16px; padding: 7px 12px; border-radius: 999px; background: rgba(18, 17, 16, .72); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.12); color: #f4efe7; font-size: 12.5px; font-weight: 500; white-space: nowrap; pointer-events: none; transition: opacity .3s; }\n.hb-kl7-chip b { color: var(--hb-kl7-accent); font-weight: 600; margin-right: 6px; }\n.hb-kl7-chip-l { left: 16px; }\n.hb-kl7-chip-r { right: 16px; }\n.hb-kl7-line { position: absolute; top: 0; bottom: 0; left: var(--hb-kl7-pos); width: 2px; margin-left: -1px; background: #f4efe7; box-shadow: 0 0 20px rgba(0,0,0,.5); pointer-events: none; }\n.hb-kl7-handle { position: absolute; top: 50%; left: var(--hb-kl7-pos); width: 52px; height: 52px; margin: -26px 0 0 -26px; display: grid; place-items: center; border: 0; border-radius: 50%; background: #f4efe7; color: #121110; cursor: ew-resize; box-shadow: 0 10px 30px rgba(0,0,0,.45); padding: 0; }\n.hb-kl7-handle::before { content: \"\"; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(244, 239, 231, .6); animation: hb-kl7-ring 2.2s ease-out infinite; }\n@keyframes hb-kl7-ring { 0% { transform: scale(.85); opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }\n.hb-kl7-handle:focus-visible { outline: 3px solid var(--hb-kl7-accent); outline-offset: 4px; }\n.hb-kl7-handle svg { animation: hb-kl7-nudge 2.2s ease-in-out infinite; }\n@keyframes hb-kl7-nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }\n.hb-kl7-stage[data-moved] .hb-kl7-handle::before, .hb-kl7-stage[data-moved] .hb-kl7-handle svg { animation: none; }\n.hb-kl7-stats { margin: 16px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; border-radius: 18px; overflow: hidden; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.08); }\n.hb-kl7-stat { min-width: 0; padding: 20px 22px; background: #161513; animation: hb-kl7-in .6s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--hb-kl7-i) * 90ms + .2s); }\n@keyframes hb-kl7-in { from { opacity: 0; transform: translateY(10px); } }\n.hb-kl7-stat b { display: block; font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif); font-weight: 400; font-size: 32px; line-height: 1; color: #f4efe7; }\n.hb-kl7-stat span { display: block; margin-top: 8px; color: #8f8a82; font-size: 13.5px; line-height: 1.4; }\n@container (max-width: 820px) {\n  .hb-kl7-head { grid-template-columns: minmax(0, 1fr); }\n  .hb-kl7-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n  .hb-kl7-stage { aspect-ratio: 4 / 3; }\n  .hb-kl7-wrap { padding: 64px 20px 72px; }\n}\n@container (max-width: 400px) {\n  .hb-kl7-chip { font-size: 11.5px; padding: 6px 10px; top: 10px; }\n  .hb-kl7-chip-l { left: 10px; }\n  .hb-kl7-chip-r { right: 10px; }\n  .hb-kl7-stat { padding: 16px; }\n  .hb-kl7-stat b { font-size: 26px; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-kl7 *, .hb-kl7 *::before, .hb-kl7 *::after { animation: none !important; transition: none !important; }\n}\n`;\n\nfunction BeforeKitchen() {\n  return (\n    <svg viewBox=\"0 0 800 410\" preserveAspectRatio=\"xMidYMid slice\" aria-hidden=\"true\">\n      <rect width=\"800\" height=\"410\" fill=\"#cdbf9f\" />\n      <g opacity=\".35\" stroke=\"#a8996f\" strokeWidth=\"1\">\n        {Array.from({ length: 21 }, (_, i) => <path key={i} d={`M${i * 40} 0 V 260`} />)}\n      </g>\n      <rect x=\"0\" y=\"0\" width=\"800\" height=\"18\" fill=\"#b9ab88\" />\n      <rect x=\"300\" y=\"18\" width=\"200\" height=\"10\" rx=\"3\" fill=\"#efeee2\" />\n      <rect x=\"310\" y=\"28\" width=\"180\" height=\"6\" fill=\"#fffde8\" opacity=\".8\" />\n      <rect x=\"60\" y=\"50\" width=\"260\" height=\"110\" fill=\"#7a5532\" stroke=\"#5e3f22\" strokeWidth=\"3\" />\n      {[0, 1, 2].map((i) => <rect key={i} x={70 + i * 84} y=\"60\" width=\"74\" height=\"90\" fill=\"#8a6239\" stroke=\"#5e3f22\" strokeWidth=\"2\" />)}\n      <rect x=\"480\" y=\"50\" width=\"260\" height=\"110\" fill=\"#7a5532\" stroke=\"#5e3f22\" strokeWidth=\"3\" />\n      {[0, 1, 2].map((i) => <rect key={i} x={490 + i * 84} y=\"60\" width=\"74\" height=\"90\" fill=\"#8a6239\" stroke=\"#5e3f22\" strokeWidth=\"2\" />)}\n      <rect x=\"340\" y=\"56\" width=\"120\" height=\"100\" fill=\"#b9d3d6\" stroke=\"#efeee2\" strokeWidth=\"8\" />\n      <path d=\"M400 56 V 156 M340 106 H 460\" stroke=\"#efeee2\" strokeWidth=\"5\" />\n      <rect x=\"0\" y=\"240\" width=\"800\" height=\"18\" fill=\"#d8c79a\" />\n      <g opacity=\".5\">{Array.from({ length: 20 }, (_, i) => <rect key={i} x={i * 40} y=\"160\" width=\"40\" height=\"80\" fill=\"none\" stroke=\"#e8dcc0\" strokeWidth=\"1.5\" />)}</g>\n      <rect x=\"0\" y=\"258\" width=\"800\" height=\"152\" fill=\"#6d4a2b\" />\n      {Array.from({ length: 6 }, (_, i) => (\n        <g key={i}>\n          <rect x={20 + i * 130} y=\"272\" width=\"116\" height=\"120\" fill=\"#7a5532\" stroke=\"#5e3f22\" strokeWidth=\"3\" />\n          <circle cx={i % 2 ? 40 + i * 130 : 116 + i * 130} cy=\"332\" r=\"5\" fill=\"#c9a86a\" />\n        </g>\n      ))}\n      <rect x=\"150\" y=\"214\" width=\"34\" height=\"28\" rx=\"4\" fill=\"#e9e3cf\" />\n      <rect x=\"560\" y=\"200\" width=\"60\" height=\"42\" rx=\"6\" fill=\"#bfbfb4\" />\n      <rect x=\"566\" y=\"206\" width=\"38\" height=\"28\" fill=\"#55574f\" />\n      <circle cx=\"230\" cy=\"232\" r=\"10\" fill=\"#a0442c\" />\n      <rect x=\"650\" y=\"220\" width=\"20\" height=\"22\" fill=\"#d9d3be\" />\n      <rect x=\"0\" y=\"392\" width=\"800\" height=\"18\" fill=\"#a59673\" />\n      <rect width=\"800\" height=\"410\" fill=\"#e8d27a\" opacity=\".12\" />\n    </svg>\n  );\n}\n\nfunction AfterKitchen({ accent }: { accent: string }) {\n  return (\n    <svg viewBox=\"0 0 800 410\" preserveAspectRatio=\"xMidYMid slice\" aria-hidden=\"true\">\n      <defs>\n        <linearGradient id=\"hb-kl7-wall\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\"0%\" stopColor=\"#f2eee6\" />\n          <stop offset=\"100%\" stopColor=\"#e4ddd0\" />\n        </linearGradient>\n        <radialGradient id=\"hb-kl7-lamp\" cx=\"50%\" cy=\"0%\" r=\"60%\">\n          <stop offset=\"0%\" stopColor=\"#ffe2b0\" stopOpacity=\".7\" />\n          <stop offset=\"100%\" stopColor=\"#ffe2b0\" stopOpacity=\"0\" />\n        </radialGradient>\n      </defs>\n      <rect width=\"800\" height=\"410\" fill=\"url(#hb-kl7-wall)\" />\n      <rect x=\"250\" y=\"40\" width=\"300\" height=\"140\" rx=\"4\" fill=\"#bcd2cf\" />\n      <rect x=\"250\" y=\"40\" width=\"300\" height=\"140\" rx=\"4\" fill=\"none\" stroke=\"#1f2a26\" strokeWidth=\"6\" />\n      <path d=\"M400 40 V 180\" stroke=\"#1f2a26\" strokeWidth=\"4\" />\n      <path d=\"M270 160 C 300 120, 330 150, 360 110 S 420 120, 440 90 S 510 110, 530 80 L 530 175 L 270 175 Z\" fill=\"#9db8ad\" opacity=\".6\" />\n      <rect x=\"40\" y=\"40\" width=\"180\" height=\"160\" rx=\"3\" fill=\"#2f4a3e\" />\n      <rect x=\"580\" y=\"40\" width=\"180\" height=\"160\" rx=\"3\" fill=\"#2f4a3e\" />\n      {[40, 130, 580, 670].map((x) => <rect key={x} x={x + 8} y=\"48\" width=\"74\" height=\"144\" rx=\"2\" fill=\"#35554a\" />)}\n      {[118, 132, 658, 672].map((x) => <rect key={x} x={x - 1} y=\"110\" width=\"2\" height=\"28\" rx=\"1\" fill={accent} />)}\n      <rect x=\"0\" y=\"200\" width=\"800\" height=\"50\" fill=\"#f7f4ee\" />\n      <g stroke=\"#e3ddd2\" strokeWidth=\"1\">{Array.from({ length: 27 }, (_, i) => <path key={i} d={`M${i * 30} 200 V 250`} />)}<path d=\"M0 225 H 800\" /></g>\n      {[240, 400, 560].map((x) => (\n        <g key={x}>\n          <path d={`M${x} 0 V 54`} stroke=\"#1f2a26\" strokeWidth=\"2\" />\n          <path d={`M${x - 22} 74 Q ${x} 46 ${x + 22} 74 Z`} fill={accent} />\n          <ellipse cx={x} cy=\"150\" rx=\"90\" ry=\"110\" fill=\"url(#hb-kl7-lamp)\" />\n        </g>\n      ))}\n      <rect x=\"0\" y=\"246\" width=\"800\" height=\"14\" fill=\"#d8c4a2\" />\n      <rect x=\"0\" y=\"260\" width=\"800\" height=\"150\" fill=\"#2f4a3e\" />\n      {Array.from({ length: 5 }, (_, i) => (\n        <g key={i}>\n          <rect x={16 + i * 156} y=\"272\" width=\"146\" height=\"126\" rx=\"3\" fill=\"#35554a\" />\n          <rect x={60 + i * 156} y=\"282\" width=\"58\" height=\"3\" rx=\"1.5\" fill={accent} />\n        </g>\n      ))}\n      <path d=\"M520 246 Q 524 214 548 214 Q 572 214 572 236\" stroke=\"#c9c2b4\" strokeWidth=\"5\" fill=\"none\" strokeLinecap=\"round\" />\n      <ellipse cx=\"170\" cy=\"236\" rx=\"30\" ry=\"10\" fill=\"#e9e1d1\" />\n      <path d=\"M150 236 Q 170 206 190 236\" fill=\"#7a9a5b\" />\n      <rect x=\"650\" y=\"206\" width=\"16\" height=\"40\" rx=\"3\" fill=\"#c9b08a\" />\n      <rect x=\"672\" y=\"214\" width=\"14\" height=\"32\" rx=\"3\" fill=\"#8a9a8f\" />\n      <rect x=\"0\" y=\"398\" width=\"800\" height=\"12\" fill=\"#c7b08c\" />\n    </svg>\n  );\n}\n\nexport function LocalBeforeAfter({\n  eyebrow = \"Hollis & Co. Renovation\",\n  title = \"Same kitchen. Whole new morning.\",\n  subtitle = \"A 1987 galley kitchen in Cobble Hill, opened up with sage cabinetry, white oak and three warm pendants. Drag to compare.\",\n  beforeLabel = \"1987 original\",\n  afterLabel = \"Six weeks later\",\n  before,\n  after,\n  value,\n  defaultValue = 46,\n  onChange,\n  stats = defaultStats,\n  cta = { label: \"Book a free home visit\", href: \"#visit\" },\n  accent = \"#d9a35b\",\n  className,\n  style,\n  ...rest\n}: LocalBeforeAfterProps) {\n  const [inner, setInner] = React.useState(defaultValue);\n  const [moved, setMoved] = React.useState(false);\n  const pos = Math.min(100, Math.max(0, value ?? inner));\n  const stageRef = React.useRef<HTMLDivElement>(null);\n  const dragging = React.useRef(false);\n\n  const update = (next: number) => {\n    const v = Math.round(Math.min(100, Math.max(0, next)) * 10) / 10;\n    if (value === undefined) setInner(v);\n    setMoved(true);\n    onChange?.(v);\n  };\n\n  const fromPointer = (clientX: number) => {\n    const el = stageRef.current;\n    if (!el) return;\n    const rect = el.getBoundingClientRect();\n    update(((clientX - rect.left) / rect.width) * 100);\n  };\n\n  const onKey = (event: React.KeyboardEvent) => {\n    const step = event.shiftKey ? 10 : 2;\n    let next: number | null = null;\n    if (event.key === \"ArrowLeft\" || event.key === \"ArrowDown\") next = pos - step;\n    if (event.key === \"ArrowRight\" || event.key === \"ArrowUp\") next = pos + step;\n    if (event.key === \"Home\") next = 0;\n    if (event.key === \"End\") next = 100;\n    if (event.key === \"PageDown\") next = pos - 10;\n    if (event.key === \"PageUp\") next = pos + 10;\n    if (next === null) return;\n    event.preventDefault();\n    update(next);\n  };\n\n  return (\n    <section\n      className={[\"hb-kl7\", className].filter(Boolean).join(\" \")}\n      style={{ \"--hb-kl7-accent\": accent, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-local-before-after\" precedence=\"default\">{css}</style>\n      <div className=\"hb-kl7-wrap\">\n        <div className=\"hb-kl7-head\">\n          <div>\n            <p className=\"hb-kl7-eyebrow\">{eyebrow}</p>\n            <h2 className=\"hb-kl7-title\">{title}</h2>\n          </div>\n          <div className=\"hb-kl7-side\">\n            <p>{subtitle}</p>\n            {cta ? (\n              <a className=\"hb-kl7-cta\" href={cta.href}>\n                {cta.label}\n                <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\n                  <path d=\"M5 12h14M13 6l6 6-6 6\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                </svg>\n              </a>\n            ) : null}\n          </div>\n        </div>\n        <div\n          ref={stageRef}\n          className=\"hb-kl7-stage\"\n          data-moved={moved ? \"\" : undefined}\n          style={{ \"--hb-kl7-pos\": `${pos.toFixed(1)}%` } as React.CSSProperties}\n          onPointerDown={(e) => {\n            dragging.current = true;\n            e.currentTarget.setPointerCapture(e.pointerId);\n            fromPointer(e.clientX);\n          }}\n          onPointerMove={(e) => { if (dragging.current) fromPointer(e.clientX); }}\n          onPointerUp={() => { dragging.current = false; }}\n          onPointerCancel={() => { dragging.current = false; }}\n        >\n          <div className=\"hb-kl7-layer\">{before ?? <BeforeKitchen />}</div>\n          <div className=\"hb-kl7-layer hb-kl7-after\">{after ?? <AfterKitchen accent={accent} />}</div>\n          <span className=\"hb-kl7-chip hb-kl7-chip-l\" style={{ opacity: pos < 18 ? 0 : 1 }}><b>Before</b>{beforeLabel}</span>\n          <span className=\"hb-kl7-chip hb-kl7-chip-r\" style={{ opacity: pos > 82 ? 0 : 1 }}><b>After</b>{afterLabel}</span>\n          <span className=\"hb-kl7-line\" aria-hidden=\"true\" />\n          <button\n            type=\"button\"\n            className=\"hb-kl7-handle\"\n            role=\"slider\"\n            aria-label=\"Compare before and after\"\n            aria-valuemin={0}\n            aria-valuemax={100}\n            aria-valuenow={Math.round(pos)}\n            aria-valuetext={`${Math.round(pos)}% before, ${100 - Math.round(pos)}% after`}\n            onKeyDown={onKey}\n          >\n            <svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\n              <path d=\"M9 6l-6 6 6 6M15 6l6 6-6 6\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n            </svg>\n          </button>\n        </div>\n        {stats.length ? (\n          <ul className=\"hb-kl7-stats\">\n            {stats.map((s, i) => (\n              <li key={s.label} className=\"hb-kl7-stat\" style={{ \"--hb-kl7-i\": i } as React.CSSProperties}>\n                <b>{s.value}</b>\n                <span>{s.label}</span>\n              </li>\n            ))}\n          </ul>\n        ) : null}\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}