{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "trust-level-slider",
  "title": "Trust Level Slider",
  "description": "Choose how much an AI bot can do alone: drag along the curve and see what it will handle, what it still asks about, and how many approvals that means a day.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/trust-level-slider/trust-level-slider.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TrustLevel {\n  id: string;\n  label: string;\n  /** One line about how the bot behaves. */\n  summary: string;\n  /** Things you'd expect to approve each day at this level. */\n  approvals: number;\n  /** What it does by itself. */\n  alone: string[];\n  /** What it still brings to you. */\n  asks: string[];\n}\n\nexport interface TrustLevelSliderProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\" | \"onChange\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  subtitle?: string;\n  /** Lowest trust first. */\n  levels?: TrustLevel[];\n  defaultLevel?: number;\n  onChange?: (level: TrustLevel) => void;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst ACCENT = \"#5E6AD2\";\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst H = 148;\nconst TOP = 10;\nconst BASE = H - 28;\nconst SIDE = 44;\n\nconst PALETTES = {\n  dark: {\n    card: \"#08090A\",\n    border: \"rgba(255,255,255,0.08)\",\n    grid: \"rgba(255,255,255,0.05)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    fill: 0.2,\n  },\n  light: {\n    card: \"#FFFFFF\",\n    border: \"rgba(8,9,10,0.08)\",\n    grid: \"rgba(8,9,10,0.06)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    fill: 0.14,\n  },\n};\n\nconst DEFAULT_LEVELS: TrustLevel[] = [\n  {\n    id: \"ask\",\n    label: \"Ask first\",\n    summary: \"Checks with you before doing anything.\",\n    approvals: 46,\n    alone: [\"Read tickets and orders\"],\n    asks: [\"Replying to customers\", \"Refunds of any size\", \"Closing tickets\"],\n  },\n  {\n    id: \"draft\",\n    label: \"Draft\",\n    summary: \"Prepares the work and waits for your yes.\",\n    approvals: 28,\n    alone: [\"Read tickets and orders\", \"Draft replies\"],\n    asks: [\"Sending replies\", \"Refunds of any size\", \"Closing tickets\"],\n  },\n  {\n    id: \"act\",\n    label: \"Act and tell\",\n    summary: \"Handles routine work and tells you afterwards.\",\n    approvals: 9,\n    alone: [\"Read tickets and orders\", \"Send replies\", \"Close solved tickets\"],\n    asks: [\"Refunds over $50\", \"Anything legal\"],\n  },\n  {\n    id: \"auto\",\n    label: \"Full auto\",\n    summary: \"Runs on its own and only flags real exceptions.\",\n    approvals: 2,\n    alone: [\n      \"Read tickets and orders\",\n      \"Send replies\",\n      \"Close solved tickets\",\n      \"Refunds up to $500\",\n    ],\n    asks: [\"Anything legal\"],\n  },\n];\n\nconst round = (n: number) => Math.round(n * 10) / 10;\n\nfunction useWidth<T extends HTMLElement>(fallback: number) {\n  const ref = React.useRef<T>(null);\n  const [width, setWidth] = React.useState(fallback);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) => {\n      setWidth(Math.round(entry.contentRect.width));\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n  return [ref, width] as const;\n}\n\nfunction Mark({ ok, color }: { ok: boolean; color: string }) {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 16 16\"\n      width=\"16\"\n      height=\"16\"\n      fill=\"none\"\n      className=\"block shrink-0\"\n    >\n      <path\n        d={ok ? \"m3.5 8.5 3 3 6-7\" : \"M8 3.5v5.5M8 12v.01\"}\n        stroke={color}\n        strokeWidth=\"1.5\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n      />\n    </svg>\n  );\n}\n\nexport function TrustLevelSlider({\n  theme = \"dark\",\n  title = \"How much can Sift do alone?\",\n  subtitle = \"Support bot, across all customer tickets.\",\n  levels = DEFAULT_LEVELS,\n  defaultLevel = 1,\n  onChange,\n  className,\n  style,\n  ...rest\n}: TrustLevelSliderProps) {\n  const c = PALETTES[theme];\n  const last = levels.length - 1;\n  const [level, setLevel] = React.useState(defaultLevel);\n  const [wrapRef, width] = useWidth<HTMLDivElement>(620);\n  const uid = React.useId();\n  const current = levels[level];\n  const peak = Math.max(...levels.map((l) => l.approvals), 1);\n\n  const x = (i: number) =>\n    round(SIDE + (last > 0 ? i / last : 0) * (width - SIDE * 2));\n  const y = (v: number) => round(BASE - (v / peak) * (BASE - TOP));\n\n  const points = levels.map((l, i) => [x(i), y(l.approvals)] as const);\n  const line = points\n    .map(([px, py], i) => {\n      if (!i) return `M${px} ${py}`;\n      const [ax, ay] = points[i - 1];\n      const mid = round((ax + px) / 2);\n      return `C${mid} ${ay} ${mid} ${py} ${px} ${py}`;\n    })\n    .join(\" \");\n  const area = `${line} L${x(last)} ${BASE} L${x(0)} ${BASE} Z`;\n\n  const set = (i: number) => {\n    const next = Math.max(0, Math.min(last, i));\n    if (next === level) return;\n    setLevel(next);\n    onChange?.(levels[next]);\n  };\n\n  const nearest = (clientX: number, el: HTMLElement) => {\n    const box = el.getBoundingClientRect();\n    const ratio = (clientX - box.left - SIDE) / (box.width - SIDE * 2);\n    return Math.round(ratio * last);\n  };\n\n  return (\n    <section\n      aria-label={title}\n      className={`@container w-full rounded-2xl border ${className ?? \"\"}`}\n      style={{\n        background: c.card,\n        borderColor: c.border,\n        color: c.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...rest}\n    >\n      <div className=\"p-5 pb-3 @xl:p-6 @xl:pb-3\">\n        <div className=\"flex items-start justify-between gap-4\">\n          <header className=\"min-w-0\">\n            <h3 className=\"m-0 text-[20px] leading-[26px] font-[590] tracking-[-0.012em]\">\n              {title}\n            </h3>\n            <p\n              className=\"m-0 mt-1 text-[13px] leading-[20px] tracking-[-0.011em]\"\n              style={{ color: c.sub }}\n            >\n              {subtitle}\n            </p>\n          </header>\n          <div className=\"shrink-0 text-right\">\n            <p\n              aria-live=\"polite\"\n              className=\"m-0 text-[32px] leading-[32px] font-[510] tracking-[-0.022em] tabular-nums\"\n            >\n              {current?.approvals}\n            </p>\n            <p\n              className=\"m-0 mt-1.5 text-[13px] leading-[20px]\"\n              style={{ color: c.sub }}\n            >\n              Approvals a day\n            </p>\n          </div>\n        </div>\n\n        <div\n          ref={wrapRef}\n          role=\"slider\"\n          tabIndex={0}\n          aria-label=\"Trust level\"\n          aria-valuemin={1}\n          aria-valuemax={levels.length}\n          aria-valuenow={level + 1}\n          aria-valuetext={current?.label}\n          onKeyDown={(e) => {\n            if (e.key === \"ArrowRight\" || e.key === \"ArrowUp\") {\n              e.preventDefault();\n              set(level + 1);\n            } else if (e.key === \"ArrowLeft\" || e.key === \"ArrowDown\") {\n              e.preventDefault();\n              set(level - 1);\n            }\n          }}\n          onPointerDown={(e) => {\n            e.currentTarget.setPointerCapture(e.pointerId);\n            set(nearest(e.clientX, e.currentTarget));\n          }}\n          onPointerMove={(e) => {\n            if (e.currentTarget.hasPointerCapture(e.pointerId)) {\n              set(nearest(e.clientX, e.currentTarget));\n            }\n          }}\n          className={`mt-3 w-full cursor-pointer touch-pan-y rounded-lg select-none ${RING}`}\n          style={{ height: H }}\n        >\n          <svg aria-hidden=\"true\" width={width} height={H} className=\"block\">\n            <defs>\n              <linearGradient id={uid} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n                <stop stopColor={ACCENT} stopOpacity={c.fill} />\n                <stop offset=\"1\" stopColor={ACCENT} stopOpacity=\"0\" />\n              </linearGradient>\n            </defs>\n            <line x1={0} x2={width} y1={BASE} y2={BASE} stroke={c.grid} />\n            <path d={area} fill={`url(#${uid})`} />\n            <path d={line} fill=\"none\" stroke={ACCENT} strokeWidth=\"1.75\" />\n            {levels.map((l, i) => {\n              const on = i === level;\n              return (\n                <g key={l.id}>\n                  <line\n                    x1={x(i)}\n                    x2={x(i)}\n                    y1={TOP}\n                    y2={BASE}\n                    stroke={on ? c.faint : c.grid}\n                  />\n                  <circle\n                    data-level={i}\n                    cx={x(i)}\n                    cy={y(l.approvals)}\n                    r={on ? 5.5 : 3.5}\n                    fill={ACCENT}\n                    stroke={c.card}\n                    strokeWidth=\"2\"\n                  />\n                  <text\n                    x={x(i)}\n                    y={H - 8}\n                    textAnchor=\"middle\"\n                    fontSize=\"12\"\n                    fontWeight={on ? 510 : 400}\n                    fill={on ? c.text : c.faint}\n                  >\n                    {l.label}\n                  </text>\n                </g>\n              );\n            })}\n          </svg>\n        </div>\n      </div>\n\n      {/* Every level shares one cell, so moving the slider never changes the card's height. */}\n      <div\n        className=\"grid border-t p-5 @xl:px-6\"\n        style={{\n          borderColor: c.border,\n          gridTemplateColumns: \"minmax(0, 1fr)\",\n        }}\n      >\n        {levels.map((l, i) => {\n          const on = i === level;\n          return (\n            <div\n              key={l.id}\n              aria-hidden={!on}\n              className={`min-w-0 [grid-area:1/1] motion-safe:transition-opacity motion-safe:duration-200 ${on ? \"visible opacity-100\" : \"invisible opacity-0\"}`}\n            >\n              <p\n                className=\"m-0 text-[13.5px] leading-[20px] tracking-[-0.011em]\"\n                style={{ color: c.soft }}\n              >\n                {l.summary}\n              </p>\n              <div className=\"mt-3 grid gap-x-8 gap-y-3 @xl:grid-cols-2\">\n                <div className=\"min-w-0\">\n                  <p\n                    className=\"m-0 text-[12px] leading-[16px] tracking-[-0.005em]\"\n                    style={{ color: c.faint }}\n                  >\n                    Does alone\n                  </p>\n                  <ul className=\"m-0 mt-1 list-none p-0\">\n                    {l.alone.map((item) => (\n                      <li\n                        key={item}\n                        className=\"flex items-center gap-2 py-[3px] text-[13px] leading-[20px] tracking-[-0.011em]\"\n                        style={{ color: c.soft }}\n                      >\n                        <Mark ok color={c.faint} />\n                        <span className=\"truncate\">{item}</span>\n                      </li>\n                    ))}\n                  </ul>\n                </div>\n                <div className=\"min-w-0\">\n                  <p\n                    className=\"m-0 text-[12px] leading-[16px] tracking-[-0.005em]\"\n                    style={{ color: c.faint }}\n                  >\n                    Still asks you\n                  </p>\n                  <ul className=\"m-0 mt-1 list-none p-0\">\n                    {l.asks.map((item) => (\n                      <li\n                        key={item}\n                        className=\"flex items-center gap-2 py-[3px] text-[13px] leading-[20px] tracking-[-0.011em]\"\n                        style={{ color: c.soft }}\n                      >\n                        <Mark ok={false} color=\"#FC7840\" />\n                        <span className=\"truncate\">{item}</span>\n                      </li>\n                    ))}\n                  </ul>\n                </div>\n              </div>\n            </div>\n          );\n        })}\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}