{
  "name": "ai-redact",
  "type": "registry:component",
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "files": [
    {
      "type": "registry:component",
      "content": "\"use client\";\n\n/**\n * @author: @kokonutui\n * @description: AI Redact\n * @version: 1.1.0\n * @date: 2026-10-21\n * @license: MIT\n * @website: https://kokonutui.com\n * @github: https://github.com/kokonut-labs/kokonutui\n */\n\nimport {\n  ArrowUp,\n  CreditCard,\n  KeyRound,\n  Lock,\n  type LucideIcon,\n  Mail,\n  Phone,\n  ShieldCheck,\n  User,\n} from \"lucide-react\";\nimport {\n  AnimatePresence,\n  MotionConfig,\n  motion,\n  useReducedMotion,\n} from \"motion/react\";\nimport {\n  type KeyboardEvent,\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type RedactKind = \"email\" | \"phone\" | \"card\" | \"secret\" | \"name\";\n\nexport interface AIRedactProps {\n  title?: string;\n  /** Text already in the composer when it mounts. */\n  defaultValue?: string;\n  /** Names to mask, e.g. contacts from your CRM. Regexes cover the rest. */\n  names?: string[];\n  /**\n   * Answers the masked prompt. It only ever sees placeholders like\n   * `EMAIL_1`; any it writes back are filled in on this side. Return the\n   * reply, a Promise of it, or a stream of text deltas (like the AI SDK's\n   * `textStream`). Throw and the reply shows the error's message.\n   */\n  respond?: (masked: string, signal: AbortSignal) => Reply;\n  className?: string;\n}\n\n/** A reply: the text, a Promise of it, or a stream of text deltas. */\nexport type Reply = string | Promise<string> | AsyncIterable<string>;\n\ninterface Match {\n  start: number;\n  end: number;\n  kind: RedactKind;\n  value: string;\n  token: string;\n}\n\ntype Segment = string | { token: string; value: string; kind: RedactKind };\n\ninterface Message {\n  id: string;\n  role: \"user\" | \"assistant\";\n  segments: Segment[];\n  /** The reply failed; segments hold why. */\n  error?: boolean;\n}\n\nconst EASE_OUT = [0.23, 1, 0.32, 1] as const;\n\nconst PATTERNS: { kind: RedactKind; pattern: RegExp }[] = [\n  {\n    kind: \"secret\",\n    pattern:\n      /\\b(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]{8,}|\\bghp_[A-Za-z0-9]{20,}/g,\n  },\n  { kind: \"card\", pattern: /\\b\\d{4}(?:[ -]?\\d{4}){3}\\b/g },\n  { kind: \"email\", pattern: /[\\w.+-]+@[\\w-]+(?:\\.[\\w-]+)+/g },\n  { kind: \"phone\", pattern: /\\+\\d[\\d ().-]{7,}\\d/g },\n];\nconst TOKEN = /\\b(EMAIL|PHONE|CARD|SECRET|PERSON)_\\d+\\b/g;\nconst ESCAPE = /[.*+?^${}()|[\\]\\\\]/g;\nconst WORDS = /\\S+\\s*|\\s+/g;\nconst PERSON_TOKEN = /PERSON_\\d+/;\nconst CARD_TOKEN = /CARD_\\d+/;\nconst PHONE_TOKEN = /PHONE_\\d+/;\nconst SECRET_TOKEN = /SECRET_\\d+/;\n\nconst LABEL: Record<RedactKind, string> = {\n  email: \"EMAIL\",\n  phone: \"PHONE\",\n  card: \"CARD\",\n  secret: \"SECRET\",\n  name: \"PERSON\",\n};\n\nconst ICON: Record<RedactKind, LucideIcon> = {\n  email: Mail,\n  phone: Phone,\n  card: CreditCard,\n  secret: KeyRound,\n  name: User,\n};\n\nconst DEMO_TEXT =\n  \"Draft a reply to Dana Whitfield (dana.whitfield@acme.co, +1 415 555 0132) confirming the refund to card 4242 4242 4242 4242. The charge failed with key sk_live_51Hx9aQ2vT8eLm, what does that error mean?\";\n\nconst DEMO_NAMES = [\"Dana Whitfield\"];\n\n/**\n * What \"send as is\" remembers. Tokens are numbered by position, so keying on\n * the token would unmask a different value once the text above it changes.\n */\nconst keepKey = (m: { kind: RedactKind; value: string }) =>\n  `${m.kind}:${m.value}`;\n\nconst demoRespond = (masked: string) => {\n  const person = masked.match(PERSON_TOKEN)?.[0] ?? \"there\";\n  const card = masked.match(CARD_TOKEN)?.[0] ?? \"your card\";\n  const phone = masked.match(PHONE_TOKEN)?.[0];\n  const secret = masked.match(SECRET_TOKEN)?.[0];\n  const callBack = phone ? `, or call us back on ${phone}` : \"\";\n  const keyNote = secret\n    ? ` On the error: I only saw ${secret}, not the key itself, so I can't tell which account it belongs to. A failed charge with a live key usually means the card was declined, not that the key is wrong.`\n    : \"\";\n  return `Hi ${person}, thanks for bearing with us. Your refund to ${card} is confirmed and should land within 5 to 10 business days. If anything looks off, just reply here${callBack}.${keyNote}`;\n};\n\n/** Finds everything worth masking, numbering repeats with the same token. */\nconst detect = (text: string, names: string[]): Match[] => {\n  const found: Omit<Match, \"token\">[] = [];\n  const taken = (start: number, end: number) =>\n    found.some((m) => start < m.end && end > m.start);\n  const patterns = [\n    ...PATTERNS,\n    ...names.map((name) => ({\n      kind: \"name\" as const,\n      pattern: new RegExp(`\\\\b${name.replace(ESCAPE, \"\\\\$&\")}\\\\b`, \"g\"),\n    })),\n  ];\n  for (const { kind, pattern } of patterns) {\n    for (const m of text.matchAll(pattern)) {\n      const start = m.index ?? 0;\n      const end = start + m[0].length;\n      if (!taken(start, end)) {\n        found.push({ start, end, kind, value: m[0] });\n      }\n    }\n  }\n  found.sort((a, b) => a.start - b.start);\n  const tokens = new Map<string, string>();\n  const counts: Partial<Record<RedactKind, number>> = {};\n  return found.map((m) => {\n    const key = `${m.kind}:${m.value}`;\n    let token = tokens.get(key);\n    if (!token) {\n      counts[m.kind] = (counts[m.kind] ?? 0) + 1;\n      token = `${LABEL[m.kind]}_${counts[m.kind]}`;\n      tokens.set(key, token);\n    }\n    return { ...m, token };\n  });\n};\n\nconst toSegments = (text: string, matches: Match[], kept: Set<string>) => {\n  const out: Segment[] = [];\n  let at = 0;\n  for (const m of matches) {\n    if (kept.has(keepKey(m))) {\n      continue;\n    }\n    if (m.start > at) {\n      out.push(text.slice(at, m.start));\n    }\n    out.push({ token: m.token, value: m.value, kind: m.kind });\n    at = m.end;\n  }\n  out.push(text.slice(at));\n  return out.filter((s) => s !== \"\");\n};\n\nconst flatten = (segments: Segment[]) =>\n  segments.map((s) => (typeof s === \"string\" ? s : s.token)).join(\"\");\n\n/** Turns placeholders in the reply back into segments with real values. */\nconst restore = (reply: string, matches: Match[]): Segment[] => {\n  const byToken = new Map(matches.map((m) => [m.token, m]));\n  const out: Segment[] = [];\n  let at = 0;\n  for (const m of reply.matchAll(TOKEN)) {\n    const hit = byToken.get(m[0]);\n    const start = m.index ?? 0;\n    if (!hit) {\n      continue;\n    }\n    out.push(reply.slice(at, start));\n    out.push({ token: hit.token, value: hit.value, kind: hit.kind });\n    at = start + m[0].length;\n  }\n  out.push(reply.slice(at));\n  return out.filter((s) => s !== \"\");\n};\n\n/** Splits text segments into words so a reply can stream in. */\nconst pieces = (segments: Segment[]): Segment[] =>\n  segments.flatMap((s): Segment[] =>\n    typeof s === \"string\" ? [...(s.match(WORDS) ?? [])] : [s]\n  );\n\nconst isStream = (value: Reply): value is AsyncIterable<string> =>\n  typeof value === \"object\" && Symbol.asyncIterator in value;\n\n/** Reads a reply, calling `onText` with all the text so far. */\nasync function readReply(reply: Reply, onText: (text: string) => void) {\n  if (!isStream(reply)) {\n    onText(await reply);\n    return;\n  }\n  let text = \"\";\n  for await (const delta of reply) {\n    text += delta;\n    onText(text);\n  }\n}\n\nconst reasonOf = (error: unknown) =>\n  error instanceof Error && error.message\n    ? error.message\n    : \"Something went wrong. Try again.\";\n\nlet counter = 0;\nconst uid = () => {\n  counter += 1;\n  return `m${counter}`;\n};\n\nexport default function AIRedact({\n  title = \"Support assistant\",\n  defaultValue = DEMO_TEXT,\n  names = DEMO_NAMES,\n  respond = demoRespond,\n  className,\n}: AIRedactProps) {\n  const reduceMotion = useReducedMotion();\n  const [text, setText] = useState(defaultValue);\n  const [kept, setKept] = useState<Set<string>>(new Set());\n  const [messages, setMessages] = useState<Message[]>([]);\n  const [shown, setShown] = useState(0);\n  const [restored, setRestored] = useState(true);\n  const [modelView, setModelView] = useState(false);\n  const [pointed, setPointed] = useState<string | null>(null);\n  // A streamed reply is still arriving; its placeholders stay until it ends.\n  const [receiving, setReceiving] = useState(false);\n  const abortRef = useRef<AbortController>(undefined);\n  const textareaRef = useRef<HTMLTextAreaElement>(null);\n  const highlightRef = useRef<HTMLDivElement>(null);\n  const threadRef = useRef<HTMLDivElement>(null);\n\n  const matches = useMemo(() => detect(text, names), [text, names]);\n  const tokens = useMemo(\n    () => [...new Map(matches.map((m) => [m.token, m])).values()],\n    [matches]\n  );\n  const masking = tokens.filter((t) => !kept.has(keepKey(t)));\n\n  const reply = messages.at(-1);\n  const replyPieces = useMemo(\n    () => (reply?.role === \"assistant\" ? pieces(reply.segments) : []),\n    [reply]\n  );\n  const streaming =\n    reply?.role === \"assistant\" && (receiving || shown < replyPieces.length);\n\n  // Grow the composer with its text, so the highlight layer lines up.\n  // biome-ignore lint/correctness/useExhaustiveDependencies: text drives the height\n  useLayoutEffect(() => {\n    const el = textareaRef.current;\n    if (!el) {\n      return;\n    }\n    el.style.height = \"auto\";\n    el.style.height = `${el.scrollHeight}px`;\n  }, [text]);\n\n  // Stream the reply with placeholders, then fill the real values back in.\n  useEffect(() => {\n    if (reply?.role !== \"assistant\") {\n      return;\n    }\n    if (reduceMotion) {\n      setShown(replyPieces.length);\n      setRestored(true);\n      return;\n    }\n    if (shown < replyPieces.length) {\n      const id = setTimeout(() => setShown((n) => n + 1), 38);\n      return () => clearTimeout(id);\n    }\n    if (receiving) {\n      return;\n    }\n    const id = setTimeout(() => setRestored(true), 420);\n    return () => clearTimeout(id);\n  }, [reply, replyPieces, shown, reduceMotion, receiving]);\n\n  useEffect(() => () => abortRef.current?.abort(), []);\n\n  const messageCount = messages.length;\n  useEffect(() => {\n    const el = threadRef.current;\n    if (messageCount > 0 && el) {\n      el.scrollTo({ top: el.scrollHeight + shown, behavior: \"smooth\" });\n    }\n  }, [messageCount, shown]);\n\n  const send = () => {\n    if (!text.trim() || streaming) {\n      return;\n    }\n    const segments = toSegments(text, matches, kept);\n    const controller = new AbortController();\n    abortRef.current = controller;\n    const result = respond(flatten(segments), controller.signal);\n    const id = uid();\n    const write = (next: Partial<Message>) =>\n      setMessages((list) =>\n        list.map((m) => (m.id === id ? { ...m, ...next } : m))\n      );\n    setMessages((list) => [\n      ...list,\n      { id: uid(), role: \"user\", segments },\n      {\n        id,\n        role: \"assistant\",\n        segments: typeof result === \"string\" ? restore(result, matches) : [],\n      },\n    ]);\n    setShown(0);\n    setRestored(false);\n    setText(\"\");\n    setKept(new Set());\n    if (typeof result === \"string\") {\n      return;\n    }\n    setReceiving(true);\n    readReply(result, (reply) => write({ segments: restore(reply, matches) }))\n      .catch((e: unknown) => {\n        if (!controller.signal.aborted) {\n          write({ segments: [reasonOf(e)], error: true });\n        }\n      })\n      .finally(() => setReceiving(false));\n  };\n\n  const onKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n    if (\n      event.key === \"Enter\" &&\n      !event.shiftKey &&\n      !event.nativeEvent.isComposing\n    ) {\n      event.preventDefault();\n      send();\n    }\n  };\n\n  const toggle = (key: string) =>\n    setKept((set) => {\n      const next = new Set(set);\n      if (next.has(key)) {\n        next.delete(key);\n      } else {\n        next.add(key);\n      }\n      return next;\n    });\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <div\n        className={cn(\n          \"flex w-full max-w-lg flex-col rounded-2xl bg-white ring-1 ring-black/[0.08] dark:bg-zinc-900 dark:ring-white/10\",\n          className\n        )}\n        data-state={streaming ? \"streaming\" : \"idle\"}\n      >\n        <header className=\"flex items-center gap-2 border-black/[0.06] border-b py-2.5 pr-2.5 pl-4 dark:border-white/[0.08]\">\n          <ShieldCheck\n            aria-hidden=\"true\"\n            className=\"size-3.5 text-zinc-400 dark:text-zinc-500\"\n          />\n          <h2 className=\"min-w-0 flex-1 truncate font-medium text-[13px] text-zinc-900 dark:text-zinc-100\">\n            {title}\n          </h2>\n          <ViewSwitch model={modelView} onChange={setModelView} />\n        </header>\n\n        <div\n          className=\"h-64 space-y-4 overflow-y-auto overscroll-contain px-4 py-4 [scrollbar-width:thin]\"\n          ref={threadRef}\n        >\n          {messages.length === 0 && (\n            <p className=\"mx-auto max-w-72 pt-16 text-center text-[12px] text-zinc-400 leading-relaxed dark:text-zinc-500\">\n              Names, emails, numbers and keys are swapped for placeholders\n              before anything leaves the browser. Replies are filled back in\n              here.\n            </p>\n          )}\n          {messages.map((message) => {\n            const live = message === reply && message.role === \"assistant\";\n            return message.role === \"user\" ? (\n              <div className=\"flex justify-end\" key={message.id}>\n                <p className=\"max-w-[88%] rounded-2xl rounded-br-md bg-zinc-100 px-3.5 py-2 text-[13px] text-zinc-800 leading-6 dark:bg-zinc-800 dark:text-zinc-100\">\n                  <Segments masked={modelView} segments={message.segments} />\n                </p>\n              </div>\n            ) : (\n              <p\n                className={cn(\n                  \"text-[13px] leading-6\",\n                  message.error\n                    ? \"text-rose-600 dark:text-rose-400\"\n                    : \"text-zinc-800 dark:text-zinc-200\"\n                )}\n                key={message.id}\n                role={message.error ? \"alert\" : undefined}\n              >\n                <Segments\n                  hideSecrets\n                  masked={modelView || (live && !restored)}\n                  segments={\n                    live ? replyPieces.slice(0, shown) : message.segments\n                  }\n                />\n              </p>\n            );\n          })}\n        </div>\n\n        <div className=\"p-2 pt-0\">\n          <div className=\"rounded-xl bg-zinc-50 ring-1 ring-black/[0.07] dark:bg-zinc-800/60 dark:ring-white/[0.08]\">\n            <div className=\"relative px-3 pt-2.5\">\n              {/* Highlights sit under the transparent textarea, letter for letter. */}\n              <div\n                aria-hidden=\"true\"\n                className=\"pointer-events-none absolute inset-x-3 top-2.5 bottom-0 overflow-hidden [scrollbar-gutter:stable]\"\n              >\n                <div\n                  className=\"whitespace-pre-wrap break-words text-[13px] text-transparent leading-6 [@media(pointer:coarse)]:text-base\"\n                  ref={highlightRef}\n                >\n                  <Highlights\n                    kept={kept}\n                    matches={matches}\n                    pointed={pointed}\n                    text={text}\n                  />\n                  {\"​\"}\n                </div>\n              </div>\n              <textarea\n                aria-label=\"Message\"\n                className=\"relative block max-h-40 min-h-12 w-full resize-none overflow-y-auto bg-transparent text-[13px] text-zinc-900 leading-6 outline-hidden [scrollbar-gutter:stable] placeholder:text-zinc-400 dark:text-zinc-100 dark:placeholder:text-zinc-500 [@media(pointer:coarse)]:text-base\"\n                onChange={(event) => setText(event.target.value)}\n                onKeyDown={onKeyDown}\n                onScroll={(event) => {\n                  // Past max height the textarea scrolls; the highlights follow.\n                  const layer = highlightRef.current;\n                  if (layer) {\n                    layer.style.transform = `translateY(${-event.currentTarget.scrollTop}px)`;\n                  }\n                }}\n                placeholder=\"Paste a customer message…\"\n                ref={textareaRef}\n                rows={2}\n                value={text}\n              />\n            </div>\n            <div className=\"flex items-end gap-2 p-2\">\n              <div className=\"flex min-h-7 min-w-0 flex-1 flex-wrap items-center gap-1\">\n                {tokens.length === 0 && (\n                  <span className=\"px-1 text-[11px] text-zinc-400 dark:text-zinc-500\">\n                    Nothing to mask\n                  </span>\n                )}\n                <AnimatePresence initial={false} mode=\"popLayout\">\n                  {tokens.map((t) => (\n                    <TokenChip\n                      kept={kept.has(keepKey(t))}\n                      key={t.token}\n                      match={t}\n                      onPoint={(on) => setPointed(on ? t.token : null)}\n                      onToggle={() => toggle(keepKey(t))}\n                    />\n                  ))}\n                </AnimatePresence>\n              </div>\n              <button\n                aria-label=\"Send\"\n                className=\"flex size-8 shrink-0 items-center justify-center rounded-lg bg-zinc-900 text-white transition-[background-color,opacity] duration-150 hover:bg-zinc-700 active:bg-zinc-600 disabled:opacity-30 dark:bg-white dark:text-zinc-900 dark:active:bg-zinc-300 dark:hover:bg-zinc-200\"\n                disabled={!text.trim() || streaming}\n                onClick={send}\n                type=\"button\"\n              >\n                <ArrowUp className=\"size-3.5\" />\n              </button>\n            </div>\n          </div>\n          <p\n            aria-live=\"polite\"\n            className=\"flex h-7 items-center px-2 text-[11px] text-zinc-400 dark:text-zinc-500\"\n          >\n            {masking.length > 0\n              ? `${masking.length} ${masking.length === 1 ? \"item\" : \"items\"} will be masked. Click one to send it as is.`\n              : \"Sent exactly as written\"}\n          </p>\n        </div>\n      </div>\n    </MotionConfig>\n  );\n}\n\nfunction Highlights({\n  text,\n  matches,\n  kept,\n  pointed,\n}: {\n  text: string;\n  matches: Match[];\n  kept: Set<string>;\n  /** The token whose chip is hovered or focused, lit up in the text. */\n  pointed: string | null;\n}) {\n  const out: (string | Match)[] = [];\n  let at = 0;\n  for (const m of matches) {\n    out.push(text.slice(at, m.start), m);\n    at = m.end;\n  }\n  out.push(text.slice(at));\n  return out.map((part) =>\n    typeof part === \"string\" ? (\n      part\n    ) : (\n      <mark\n        className={cn(\n          \"rounded-[3px] text-transparent transition-[background-color,box-shadow] duration-150 [box-decoration-break:clone]\",\n          kept.has(keepKey(part))\n            ? \"bg-transparent underline decoration-zinc-400 decoration-dotted underline-offset-4\"\n            : \"bg-orange-500/[0.16] dark:bg-orange-400/20\",\n          pointed === part.token &&\n            (kept.has(keepKey(part))\n              ? \"bg-zinc-900/[0.07] dark:bg-white/10\"\n              : \"bg-orange-500/30 shadow-[0_0_0_1px_rgb(249_115_22/0.45)] dark:bg-orange-400/35\")\n        )}\n        key={part.start}\n      >\n        {part.value}\n      </mark>\n    )\n  );\n}\n\nfunction TokenChip({\n  match,\n  kept,\n  onToggle,\n  onPoint,\n}: {\n  match: Match;\n  kept: boolean;\n  onToggle: () => void;\n  /** Lights up this token's spans in the composer. */\n  onPoint: (on: boolean) => void;\n}) {\n  const Icon = ICON[match.kind];\n  const locked = match.kind === \"secret\";\n  let label = `${match.value} is sent as ${match.token}. Send it as is`;\n  if (locked) {\n    label = `${match.token}. Keys and secrets are always masked`;\n  } else if (kept) {\n    label = `${match.value} is sent as is. Mask it again`;\n  }\n  return (\n    <motion.button\n      animate={{ opacity: 1, filter: \"blur(0px)\" }}\n      aria-disabled={locked || undefined}\n      aria-label={label}\n      aria-pressed={!kept}\n      className={cn(\n        \"flex h-6 items-center gap-1 rounded-md px-1.5 font-mono text-[10.5px] ring-1 transition-colors duration-150\",\n        kept &&\n          \"text-zinc-400 ring-black/[0.06] hover:text-zinc-600 active:bg-zinc-900/[0.05] dark:text-zinc-500 dark:ring-white/[0.08] dark:active:bg-white/[0.06] dark:hover:text-zinc-300\",\n        !kept &&\n          \"bg-white text-zinc-700 ring-black/[0.08] dark:bg-zinc-900 dark:text-zinc-200 dark:ring-white/10\",\n        !(kept || locked) &&\n          \"hover:bg-zinc-100 active:bg-zinc-200/80 dark:active:bg-zinc-700 dark:hover:bg-zinc-800\",\n        locked && \"cursor-default\"\n      )}\n      exit={{\n        opacity: 0,\n        filter: \"blur(2px)\",\n        transition: { duration: 0.1 },\n      }}\n      initial={{ opacity: 0, filter: \"blur(2px)\" }}\n      onBlur={() => onPoint(false)}\n      onClick={locked ? undefined : onToggle}\n      onFocus={() => onPoint(true)}\n      onPointerEnter={(event) => {\n        if (event.pointerType === \"mouse\") {\n          onPoint(true);\n        }\n      }}\n      onPointerLeave={() => onPoint(false)}\n      title={locked ? \"Keys and secrets are always masked\" : match.value}\n      transition={{ duration: 0.15, ease: EASE_OUT }}\n      type=\"button\"\n    >\n      <Icon aria-hidden=\"true\" className=\"size-3\" />\n      <span className={cn(kept && \"line-through\")}>{match.token}</span>\n      {locked && (\n        <Lock\n          aria-hidden=\"true\"\n          className=\"-mr-0.5 size-2.5 text-zinc-400 dark:text-zinc-500\"\n        />\n      )}\n    </motion.button>\n  );\n}\n\nfunction Segments({\n  segments,\n  masked,\n  hideSecrets = false,\n}: {\n  segments: Segment[];\n  masked: boolean;\n  /** Keys never come back into a reply, even on your side. */\n  hideSecrets?: boolean;\n}) {\n  let offset = 0;\n  let order = 0;\n  return segments.map((segment) => {\n    const key = `${offset}`;\n    offset +=\n      typeof segment === \"string\" ? segment.length : segment.token.length;\n    if (typeof segment === \"string\") {\n      return <span key={key}>{segment}</span>;\n    }\n    // Swaps ripple through the message one placeholder at a time.\n    const delay = Math.min(order, 6) * 0.06;\n    order += 1;\n    return (\n      <span className=\"inline-block\" key={key}>\n        <AnimatePresence initial={false} mode=\"wait\">\n          {masked || (hideSecrets && segment.kind === \"secret\") ? (\n            <motion.span\n              animate={{ opacity: 1, filter: \"blur(0px)\" }}\n              className=\"inline-flex translate-y-[-1px] items-center rounded-[5px] bg-zinc-900/[0.07] px-1 align-middle font-mono text-[11px] text-zinc-600 leading-5 dark:bg-white/10 dark:text-zinc-300\"\n              exit={{\n                opacity: 0,\n                filter: \"blur(2px)\",\n                transition: { duration: 0.12, delay, ease: EASE_OUT },\n              }}\n              initial={{ opacity: 0, filter: \"blur(2px)\" }}\n              key=\"token\"\n              transition={{ duration: 0.16, ease: EASE_OUT }}\n            >\n              {segment.token}\n            </motion.span>\n          ) : (\n            <motion.span\n              animate={{ opacity: 1, filter: \"blur(0px)\" }}\n              className=\"underline decoration-zinc-400/70 decoration-dotted underline-offset-4 dark:decoration-zinc-500\"\n              exit={{\n                opacity: 0,\n                filter: \"blur(2px)\",\n                transition: { duration: 0.12, delay, ease: EASE_OUT },\n              }}\n              initial={{ opacity: 0, filter: \"blur(2px)\" }}\n              key=\"value\"\n              title={`Sent as ${segment.token}`}\n              transition={{ duration: 0.2, ease: EASE_OUT }}\n            >\n              {segment.value}\n            </motion.span>\n          )}\n        </AnimatePresence>\n      </span>\n    );\n  });\n}\n\nfunction ViewSwitch({\n  model,\n  onChange,\n}: {\n  model: boolean;\n  onChange: (model: boolean) => void;\n}) {\n  const id = useId();\n  return (\n    <div className=\"flex h-7 items-center rounded-lg bg-zinc-100 p-0.5 text-[12px] dark:bg-zinc-800\">\n      {[\n        { value: false, label: \"You see\" },\n        { value: true, label: \"Model sees\" },\n      ].map((option) => (\n        <button\n          aria-pressed={model === option.value}\n          className={cn(\n            \"relative h-6 rounded-md px-2 transition-colors duration-150\",\n            model === option.value\n              ? \"text-zinc-900 dark:text-zinc-100\"\n              : \"text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200\"\n          )}\n          key={option.label}\n          onClick={() => onChange(option.value)}\n          type=\"button\"\n        >\n          {model === option.value && (\n            <motion.span\n              className=\"absolute inset-0 rounded-md bg-white shadow-xs dark:bg-zinc-700\"\n              layoutId={`${id}-view`}\n              transition={{ duration: 0.22, ease: EASE_OUT }}\n            />\n          )}\n          <span className=\"relative\">{option.label}</span>\n        </button>\n      ))}\n    </div>\n  );\n}\n",
      "path": "/components/kokonutui/ai-redact.tsx",
      "target": "components/kokonutui/ai-redact.tsx"
    }
  ]
}