{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "terminal",
  "title": "Terminal",
  "author": "superzero11 <https://github.com/superzero11/uiset>",
  "description": "A terminal on UI SDK's input history and stick-to-bottom: ANSI colors kept readable in every skin, links, streaming commands with progress lines, Tab completion, Ctrl+C and Ctrl+L, built-in help, clear and history, and agent actions.",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.5",
    "@ui-sdk/react@0.1.0-beta.5"
  ],
  "registryDependencies": [
    "https://uiset.dev/r/uiset.json",
    "https://uiset.dev/r/button.json",
    "https://uiset.dev/r/field.json"
  ],
  "files": [
    {
      "path": "registry/uiset/ui/terminal.tsx",
      "content": "\"use client\"\n\nimport {\n  announce,\n  createController,\n  createInputHistory,\n  createStickToBottom,\n  definePrimitive,\n  isComposing,\n  matchesShortcut,\n} from \"@ui-sdk/core\"\nimport { usePart, usePrimitive } from \"@ui-sdk/react/primitive\"\nimport {\n  memo,\n  useEffect,\n  useId,\n  useMemo,\n  useRef,\n  useState,\n  useSyncExternalStore,\n  type CSSProperties,\n  type KeyboardEvent as ReactKeyboardEvent,\n  type ReactNode,\n} from \"react\"\nimport { Button } from \"./button\"\nimport { Input } from \"./field\"\nimport { plain, Screen, urlPattern, type Run, type ScreenLine } from \"./terminal/ansi\"\nimport {\n  createTerminalController,\n  createTerminalSession,\n  english,\n  terminalPrimitive,\n  words,\n  type TerminalCommand,\n  type TerminalController,\n  type TerminalIO,\n  type TerminalMessages,\n  type TerminalResult,\n} from \"./terminal/session\"\nimport \"./terminal/terminal.css\"\n\nfunction RunText({ run }: { run: Run }) {\n  if (run.link)\n    return (\n      <a href={run.link} target=\"_blank\" rel=\"noreferrer\">\n        {run.text}\n      </a>\n    )\n  const parts: ReactNode[] = []\n  let last = 0\n  for (const match of run.text.matchAll(urlPattern)) {\n    if (match.index! > last) parts.push(run.text.slice(last, match.index))\n    parts.push(\n      <a key={match.index} href={match[0]} target=\"_blank\" rel=\"noreferrer\">\n        {match[0]}\n      </a>,\n    )\n    last = match.index! + match[0].length\n  }\n  if (last < run.text.length) parts.push(run.text.slice(last))\n  return <>{parts}</>\n}\n\n/** One line, drawn again only when it changed. */\nconst TerminalLine = memo(\n  function TerminalLine({ line, prompt }: { line: ScreenLine; version: number; prompt: string }) {\n    return (\n      <div className=\"terminal-line\" data-kind={line.kind} aria-hidden={line.quiet ? \"true\" : undefined}>\n        {line.kind === \"command\" && (\n          <span className=\"terminal-ps1\" aria-hidden=\"true\">\n            {prompt}{\" \"}\n          </span>\n        )}\n        {Screen.runs(line).map((run, i) =>\n          !run.fg && !run.bg && !run.bold && !run.dim && !run.italic && !run.underline && !run.strike && !run.inverse && !run.link ? (\n            <RunText key={i} run={run} />\n          ) : (\n            <span\n              key={i}\n              data-fg={run.fg}\n              data-bg={run.bg}\n              data-bold={run.bold ? \"\" : undefined}\n              data-dim={run.dim ? \"\" : undefined}\n              data-italic={run.italic ? \"\" : undefined}\n              data-underline={run.underline ? \"\" : undefined}\n              data-strike={run.strike ? \"\" : undefined}\n              data-inverse={run.inverse ? \"\" : undefined}\n            >\n              <RunText run={run} />\n            </span>\n          ),\n        )}\n      </div>\n    )\n  },\n  (a, b) => a.line === b.line && a.version === b.version && a.prompt === b.prompt,\n)\n\n/**\n * A terminal: output with ANSI colors, cursor codes and links, and a prompt with history\n * (Up and Down), Tab completion, Ctrl+C to stop a command and Ctrl+L to clear. Commands\n * print, stream (an async iterable) or fail; `help`, `clear` and `history` come built in.\n */\nfunction Terminal({\n  label,\n  prompt = \"$\",\n  commands = {},\n  onCommand,\n  welcome,\n  defaultHistory = [],\n  scrollback = 2000,\n  messages: given,\n  controller,\n  className,\n  style,\n}: {\n  /** The terminal's name, for people and agents. */\n  label: string\n  /** What the prompt shows, like \"~/app $\". */\n  prompt?: string\n  commands?: Record<string, TerminalCommand>\n  /** Runs a line no command matched; without it, the terminal says it's not found. */\n  onCommand?: (line: string, io: TerminalIO) => TerminalResult\n  /** Printed first. */\n  welcome?: string\n  defaultHistory?: string[]\n  /** How many lines to keep; older ones go while you're following the end. */\n  scrollback?: number\n  /** The terminal's own words, for other languages. */\n  messages?: Partial<TerminalMessages>\n  /** Writes output, runs and clears from outside, like a socket's messages: `createTerminalController()`. */\n  controller?: TerminalController\n  className?: string\n  style?: CSSProperties\n}) {\n  const messages = { ...english, ...given }\n  const inputId = useId()\n  const helpId = useId()\n  const [running, setRunning] = useState(false)\n  const field = useRef<HTMLInputElement>(null)\n  const scroller = useRef<HTMLDivElement>(null)\n  const lastTab = useRef<string | null>(null)\n\n  const stick = useMemo(() => createStickToBottom({ threshold: 24 }), [])\n  const stuck = useSyncExternalStore(\n    (listener) => stick.subscribe(listener),\n    () => stick.get(),\n    () => stick.get(),\n  )\n  useEffect(() => (scroller.current ? stick.connect(scroller.current) : undefined), [stick])\n\n  // Output goes into a screen and the page catches up once a frame, however fast it comes.\n  const [, setFrame] = useState(0)\n  const frame = useRef<number | null>(null)\n  // Writes before the terminal mounts (a controller, a slow page) can't update it yet: they\n  // wait, and one frame follows on mount. The welcome text is drawn by the first render.\n  const mounted = useRef(false)\n  const missed = useRef(false)\n  const [screen] = useState(() => {\n    const made = new Screen(() => {\n      if (!mounted.current) {\n        missed.current = true\n        return\n      }\n      if (frame.current !== null || typeof requestAnimationFrame === \"undefined\") return\n      frame.current = requestAnimationFrame(() => {\n        frame.current = null\n        // Old lines go only while you're following the end, so what you read stays put.\n        if (stick.get().following) made.trim(scrollback)\n        setFrame((n) => n + 1)\n      })\n    })\n    welcome?.split(\"\\n\").forEach((line) => made.note(line, \"info\"))\n    missed.current = false\n    return made\n  })\n  useEffect(() => {\n    mounted.current = true\n    if (missed.current) {\n      missed.current = false\n      setFrame((n) => n + 1)\n    }\n    return () => {\n      mounted.current = false\n    }\n  }, [])\n\n  // The commands, words and handler as of this render, read by the session at each use.\n  const latest = useRef({ commands, onCommand, messages })\n  latest.current = { commands, onCommand, messages }\n  const [session] = useState(() =>\n    createTerminalSession({\n      screen,\n      commands: () => latest.current.commands,\n      onCommand: () => latest.current.onCommand,\n      messages: () => latest.current.messages,\n      onRunning: setRunning,\n      history: defaultHistory,\n    }),\n  )\n  useEffect(\n    () => () => {\n      session.dispose()\n      // Cleared as well as cancelled: an effect that runs again (React's development\n      // remount) must be able to schedule frames.\n      if (frame.current !== null) cancelAnimationFrame(frame.current)\n      frame.current = null\n    },\n    [session],\n  )\n\n  const setValue = (value: string) => {\n    const el = field.current\n    if (!el) return\n    el.value = value\n    el.setSelectionRange(value.length, value.length)\n  }\n  const history = useMemo(\n    () =>\n      createInputHistory({\n        entries: () => session.sent(),\n        read: () => field.current?.value ?? \"\",\n        write: (value) => setValue(value as string),\n      }),\n    [],\n  )\n\n  const keyDown = (event: ReactKeyboardEvent<HTMLInputElement>) => {\n    const native = event.nativeEvent\n    if (isComposing(native)) return\n    if (event.key !== \"Tab\") lastTab.current = null\n    if (matchesShortcut(native, \"ctrl+c\")) {\n      // With text selected, Ctrl+C copies, as everywhere else.\n      const el = event.currentTarget\n      if (el.selectionStart !== el.selectionEnd) return\n      event.preventDefault()\n      if (session.running()) session.stop()\n      else {\n        if (el.value) screen.note(`${plain(el.value)}^C`, \"command\", { quiet: true })\n        setValue(\"\")\n        history.reset()\n      }\n      return\n    }\n    if (matchesShortcut(native, \"ctrl+l\")) {\n      event.preventDefault()\n      screen.clear()\n      return\n    }\n    if (history.keydown(native)) return\n    // Tab completes what's typed; with nothing to complete, it moves on like anywhere else.\n    if (event.key === \"Tab\" && !event.shiftKey && event.currentTarget.value.trim()) {\n      const value = event.currentTarget.value\n      const found = session.tab(value, lastTab.current)\n      if (!found) return\n      event.preventDefault()\n      if (found.set !== undefined) setValue(found.set)\n      // Several matches: the second Tab lists them, as shells do.\n      else if (found.list) {\n        screen.note(found.list.join(\"   \"), \"info\", { quiet: true })\n        announce(`${found.list.length} matches: ${found.list.join(\", \")}`)\n      }\n      lastTab.current = event.currentTarget.value\n    }\n  }\n\n  const handle = usePrimitive(terminalPrimitive, {\n    onRun: (line) => {\n      stick.scrollToBottom()\n      void session.execute(line)\n    },\n    onClear: () => screen.clear(),\n    onWrite: (text, error) => screen.write(text, { error }),\n    running,\n    busy: messages.busy,\n    controller,\n    output: () =>\n      screen.lines.map((line) => ({\n        id: line.id,\n        text: line.kind === \"command\" ? `${prompt} ${Screen.text(line)}` : Screen.text(line),\n      })),\n  })\n\n  return usePart(\n    handle,\n    \"root\",\n    {},\n    {\n      \"aria-label\": label,\n      className: [\"terminal\", className].filter(Boolean).join(\" \"),\n      style,\n      \"data-running\": running ? \"\" : undefined,\n      onPointerUp: (event: React.PointerEvent) => {\n        // A click on the output puts the caret in the prompt, unless it selected text. A tap\n        // doesn't: it would open the phone's keyboard over what you're reading.\n        if (event.pointerType !== \"mouse\" || (event.target as Element).closest(\"a, button, input\")) return\n        if (!window.getSelection()?.toString()) field.current?.focus({ preventScroll: true })\n      },\n      children: (\n        <>\n          <div\n            ref={scroller}\n            className=\"terminal-scroll\"\n            role=\"log\"\n            aria-label={`${label} output`}\n            // New lines are read out; a line redrawn in place (a progress bar) isn't.\n            aria-relevant=\"additions\"\n            tabIndex={0}\n            translate=\"no\"\n          >\n            {screen.lines.map((line) => (\n              <TerminalLine key={line.id} line={line} version={line.version} prompt={prompt} />\n            ))}\n          </div>\n          {stuck.unseen && !stuck.following && (\n            <Button\n              variant=\"outline\"\n              className=\"terminal-jump\"\n              onClick={() => {\n                stick.scrollToBottom()\n                // The button goes once you're at the end; the prompt takes focus.\n                field.current?.focus({ preventScroll: true })\n              }}\n            >\n              {messages.newOutput}\n            </Button>\n          )}\n          <form\n            className=\"terminal-prompt\"\n            onSubmit={(event) => {\n              event.preventDefault()\n              const value = field.current?.value ?? \"\"\n              if (running) {\n                announce(messages.stillRunning)\n                return\n              }\n              history.reset()\n              setValue(\"\")\n              stick.scrollToBottom()\n              void session.execute(value)\n            }}\n          >\n            <span className=\"terminal-ps1\" aria-hidden=\"true\">\n              {prompt}\n            </span>\n            <Input\n              ref={field}\n              id={inputId}\n              className=\"terminal-input\"\n              aria-label={messages.command}\n              autoComplete=\"off\"\n              autoCapitalize=\"off\"\n              autoCorrect=\"off\"\n              spellCheck={false}\n              translate=\"no\"\n              enterKeyHint=\"send\"\n              aria-describedby={helpId}\n              onKeyDown={keyDown}\n            />\n            <span className=\"terminal-status\" aria-hidden=\"true\">\n              {running ? \"Running… Ctrl+C stops it\" : \"\"}\n            </span>\n          </form>\n          <p id={helpId} hidden>\n            {messages.help}\n          </p>\n        </>\n      ),\n    } as never,\n    \"div\",\n  )\n}\n\nexport { createTerminalController, Terminal, words }\nexport type { TerminalCommand, TerminalController, TerminalIO, TerminalMessages, TerminalResult }\n",
      "type": "registry:ui",
      "target": "@ui/terminal.tsx"
    },
    {
      "path": "registry/uiset/ui/terminal/ansi.ts",
      "content": "// A small terminal screen: text and ANSI escapes in, styled lines out. It keeps a cursor,\n// so \"\\r\" goes back to the start of the line and what follows overwrites it (progress\n// bars), \"\\b\" steps back, and the erase-line and cursor codes spinners use work. Styles\n// carry across lines and chunks; an escape split between two chunks waits for the rest.\n\ntype Color = \"black\" | \"red\" | \"green\" | \"yellow\" | \"blue\" | \"magenta\" | \"cyan\" | \"white\" | \"grey\"\n\ntype Style = {\n  fg?: Color\n  bg?: Color\n  bold?: boolean\n  dim?: boolean\n  italic?: boolean\n  underline?: boolean\n  strike?: boolean\n  inverse?: boolean\n  /** An http(s) link from an OSC 8 hyperlink. */\n  link?: string\n}\n\ntype Run = { text: string } & Style\n\ntype Cell = { ch: string; style: Style }\n\ntype ScreenLine = {\n  id: number\n  kind: \"out\" | \"command\" | \"info\"\n  cells: Cell[]\n  /** Bumped on every change, so a line re-renders only when it changed. */\n  version: number\n  /** Lines the screen reader shouldn't hear (they're announced another way). */\n  quiet?: boolean\n}\n\nconst colors: Color[] = [\"black\", \"red\", \"green\", \"yellow\", \"blue\", \"magenta\", \"cyan\", \"white\"]\nconst plainStyle: Style = Object.freeze({})\n\nfunction applyCodes(style: Style, params: string): Style {\n  const codes = params === \"\" ? [0] : params.split(/[;:]/).map((n) => Number(n) || 0)\n  const next: Style = { ...style }\n  for (let i = 0; i < codes.length; i++) {\n    const code = codes[i]!\n    if (code === 0) {\n      for (const key of Object.keys(next) as (keyof Style)[]) if (key !== \"link\") delete next[key]\n    } else if (code === 1) next.bold = true\n    else if (code === 2) next.dim = true\n    else if (code === 3) next.italic = true\n    else if (code === 4) next.underline = true\n    else if (code === 7) next.inverse = true\n    else if (code === 9) next.strike = true\n    else if (code === 22) (delete next.bold, delete next.dim)\n    else if (code === 23) delete next.italic\n    else if (code === 24) delete next.underline\n    else if (code === 27) delete next.inverse\n    else if (code === 29) delete next.strike\n    else if (code >= 30 && code <= 37) next.fg = colors[code - 30]\n    // Bright black is the grey that test runners and package managers write their asides in.\n    else if (code === 90) next.fg = \"grey\"\n    else if (code >= 91 && code <= 97) next.fg = colors[code - 90]\n    else if (code === 39) delete next.fg\n    else if (code >= 40 && code <= 47) next.bg = colors[code - 40]\n    else if (code === 100) next.bg = \"grey\"\n    else if (code >= 101 && code <= 107) next.bg = colors[code - 100]\n    else if (code === 49) delete next.bg\n    // 256-color, true-color and underline-color codes name colors the skin can't promise to\n    // keep readable: their arguments are skipped and the text keeps the skin's colors.\n    else if (code === 38 || code === 48 || code === 58) i += codes[i + 1] === 5 ? 2 : codes[i + 1] === 2 ? 4 : 0\n  }\n  return next\n}\n\nconst csi = /^\\x1b\\[([0-?]*)([ -/]*)([@-~])/\nconst osc = /^\\x1b\\]([^\\x07\\x1b]*)(?:\\x07|\\x1b\\\\)/\n// Characters that would reorder or hide text: bidi overrides and isolates.\nconst bidi = /[‪-‮⁦-⁩]/\n\nclass Screen {\n  lines: ScreenLine[] = []\n  private row = -1\n  private col = 0\n  private style: Style = plainStyle\n  private partial = \"\"\n  private nextId = 0\n  private errorStyles = new WeakMap<Style, Style>()\n\n  constructor(private onTouch: () => void = () => {}) {}\n\n  /** The text of a line, without styles. */\n  static text(line: ScreenLine) {\n    return line.cells.map((cell) => cell.ch).join(\"\")\n  }\n\n  /** A line as runs of one style. Cells share style objects, so runs group by reference. */\n  static runs(line: ScreenLine): Run[] {\n    const runs: Run[] = []\n    let current: Style | null = null\n    for (const cell of line.cells) {\n      if (cell.style === current) runs[runs.length - 1]!.text += cell.ch\n      else {\n        runs.push({ ...cell.style, text: cell.ch })\n        current = cell.style\n      }\n    }\n    return runs\n  }\n\n  private line(): ScreenLine {\n    if (this.row < 0 || this.row >= this.lines.length) {\n      this.lines.push({ id: this.nextId++, kind: \"out\", cells: [], version: 0 })\n      this.row = this.lines.length - 1\n    }\n    return this.lines[this.row]!\n  }\n\n  private touch(line: ScreenLine) {\n    line.version++\n  }\n\n  private put(ch: string, style: Style) {\n    const line = this.line()\n    while (line.cells.length < this.col) line.cells.push({ ch: \" \", style: plainStyle })\n    line.cells[this.col] = { ch, style }\n    this.col++\n    this.touch(line)\n  }\n\n  /** Writes program output; `error` draws text without its own color in the danger tone. */\n  write(text: string, { error = false } = {}) {\n    let input = this.partial + text\n    this.partial = \"\"\n    // Error output without a color of its own takes the danger tone, one style per style.\n    const styleNow = () => {\n      if (!error || this.style.fg) return this.style\n      let red = this.errorStyles.get(this.style)\n      if (!red) this.errorStyles.set(this.style, (red = { ...this.style, fg: \"red\" }))\n      return red\n    }\n    while (input.length) {\n      const ch = input[0]!\n      if (ch === \"\\x1b\") {\n        const control = input.match(csi)\n        if (control) {\n          this.control(control[1]!, control[3]!)\n          input = input.slice(control[0].length)\n          continue\n        }\n        const command = input.match(osc)\n        if (command) {\n          const [kind, , url] = command[1]!.split(\";\")\n          if (kind === \"8\") {\n            // Only http(s) links are kept; anything else is plain text.\n            const link = url && /^https?:\\/\\//i.test(url) ? url : undefined\n            if (link !== this.style.link) {\n              const next = { ...this.style }\n              if (link) next.link = link\n              else delete next.link\n              this.style = next\n            }\n          }\n          input = input.slice(command[0].length)\n          continue\n        }\n        // An escape cut off by the end of the chunk waits for the next one.\n        if (/^\\x1b(\\[[0-?]*[ -/]*|\\][^\\x07\\x1b]*(\\x1b)?)?$/.test(input) && input.length < 4096) {\n          this.partial = input\n          break\n        }\n        // Any other escape: the escape and its one byte are dropped.\n        input = input.slice(2)\n        continue\n      }\n      input = input.slice(ch.length)\n      if (ch === \"\\n\") {\n        this.row++\n        this.col = 0\n        if (this.row >= this.lines.length) this.line()\n      } else if (ch === \"\\r\") this.col = 0\n      else if (ch === \"\\b\") this.col = Math.max(0, this.col - 1)\n      else if (ch === \"\\t\") {\n        const to = (Math.floor(this.col / 8) + 1) * 8\n        while (this.col < to) this.put(\" \", plainStyle)\n      } else if (ch < \" \" || ch === \"\\x7f\" || bidi.test(ch)) continue\n      else this.put(ch, styleNow())\n    }\n    this.onTouch()\n  }\n\n  private control(params: string, final: string) {\n    // Private sequences (like \"?25l\", hide the cursor) change nothing on a web page.\n    if (/^[<=>?]/.test(params)) return\n    const n = Number(params.split(\";\")[0]) || 0\n    if (final === \"m\") this.style = applyCodes(this.style, params)\n    else if (final === \"K\") {\n      const line = this.line()\n      if (n === 0) line.cells.length = Math.min(line.cells.length, this.col)\n      else if (n === 1) for (let i = 0; i <= this.col && i < line.cells.length; i++) line.cells[i] = { ch: \" \", style: plainStyle }\n      else line.cells = []\n      this.touch(line)\n    } else if (final === \"G\") this.col = Math.max(0, (n || 1) - 1)\n    else if (final === \"C\") this.col += n || 1\n    else if (final === \"D\") this.col = Math.max(0, this.col - (n || 1))\n    else if (final === \"A\") this.row = Math.max(0, (this.row < 0 ? this.lines.length - 1 : this.row) - (n || 1))\n    else if (final === \"B\") this.row = Math.min(this.lines.length - 1, this.row + (n || 1))\n    else if (final === \"J\" && (n === 2 || n === 3)) this.clear()\n  }\n\n  /** A whole line of the terminal's own, like an echoed command or a notice. */\n  note(text: string, kind: \"command\" | \"info\", { quiet = false } = {}) {\n    this.finish()\n    const line: ScreenLine = {\n      id: this.nextId++,\n      kind,\n      cells: [...text].filter((ch) => ch >= \" \" && !bidi.test(ch)).map((ch) => ({ ch, style: plainStyle })),\n      version: 0,\n      quiet,\n    }\n    this.lines.push(line)\n    this.row = -1\n    this.col = 0\n    this.onTouch()\n  }\n\n  /** Ends an open line, so what's written next starts on its own. */\n  finish() {\n    if (this.row >= 0 && this.lines[this.row]?.cells.length === 0 && this.row === this.lines.length - 1) this.lines.pop()\n    this.row = -1\n    this.col = 0\n    this.style = plainStyle\n    this.partial = \"\"\n  }\n\n  /** Drops the oldest lines past `keep`. */\n  trim(keep: number) {\n    if (this.lines.length <= keep) return\n    const drop = this.lines.length - keep\n    this.lines.splice(0, drop)\n    if (this.row >= 0) this.row = Math.max(-1, this.row - drop)\n    this.onTouch()\n  }\n\n  clear() {\n    this.lines = []\n    this.row = -1\n    this.col = 0\n    this.onTouch()\n  }\n}\n\n/** Plain text with every escape and control removed: for agents and announcements. */\nconst plain = (text: string) =>\n  text\n    .replace(/\\x1b\\][^\\x07\\x1b]*(?:\\x07|\\x1b\\\\)?/g, \"\")\n    .replace(/\\x1b\\[[0-?]*[ -/]*[@-~]/g, \"\")\n    .replace(/\\x1b./g, \"\")\n    .replace(/[\\x00-\\x1f\\x7f‪-‮⁦-⁩]/g, \"\")\n\n/** The text's URLs, for links in output; a closing period or comma isn't part of one. */\nconst urlPattern = /\\bhttps?:\\/\\/[^\\s<>\"']+[^\\s<>\"'.,;:!?)\\]]|\\bhttps?:\\/\\/[^\\s<>\"']+\\([^\\s<>\"']*\\)/g\n\nexport { plain, Screen, urlPattern }\nexport type { Color, Run, ScreenLine, Style }\n",
      "type": "registry:file",
      "target": "@ui/terminal/ansi.ts"
    },
    {
      "path": "registry/uiset/ui/terminal/session.ts",
      "content": "// The terminal's behavior without a framework: its primitive (what agents run and read),\n// command lines split into words, the built-in commands, running and stopping a command,\n// and Tab completion. The React Terminal and the web element both run on it, so they can't\n// drift; each only draws the screen and the prompt.\nimport { announce, createController, definePrimitive } from \"@ui-sdk/core\"\nimport { plain, Screen } from \"./ansi\"\n\ntype TerminalIO = {\n  /** Writes output. \"\\n\" ends a line; \"\\r\" goes back to its start, so a progress bar redraws. */\n  print: (text: string) => void\n  /** Writes to the error stream: text without its own color shows in the danger tone. */\n  error: (text: string) => void\n  /** Aborts when someone presses Ctrl+C. The prompt comes back at once either way. */\n  signal: AbortSignal\n}\n\ntype TerminalResult = void | string | Promise<void | string> | AsyncIterable<string>\n\ntype TerminalCommand = {\n  /** One line for `help`. */\n  description?: string\n  /** Its arguments, like \"<file>\", shown by `help`. */\n  usage?: string\n  run: (args: string[], io: TerminalIO) => TerminalResult\n  /** Suggestions for the argument being typed, for Tab. */\n  complete?: (args: string[]) => string[]\n}\n\ntype TerminalMessages = {\n  notFound: (name: string) => string\n  stillRunning: string\n  stopped: string\n  busy: string\n  newOutput: string\n  command: string\n  help: string\n}\n\nconst english: TerminalMessages = {\n  notFound: (name) => `${name}: command not found. Type help for the list.`,\n  stillRunning: \"Still running. Press Ctrl+C to stop it.\",\n  stopped: \"Stopped.\",\n  busy: \"A command is still running. Wait for it, or the person can press Ctrl+C.\",\n  newOutput: \"New output below\",\n  command: \"Command\",\n  help: \"Up and Down bring back earlier commands. Tab completes. Ctrl+C stops a running command, Ctrl+L clears.\",\n}\n\n/** What code outside the terminal can do: write output from a server, run, clear. */\ntype TerminalControllerApi = {\n  run(command: string): boolean\n  clear(): boolean\n  print(text: string): boolean\n  error(text: string): boolean\n}\nconst createTerminalController = () => createController<TerminalControllerApi>()\ntype TerminalController = ReturnType<typeof createTerminalController>\n\n// Agents run commands and read output through the same paths as the person.\n/** @internal Left out of @uiset/web's declarations: its type names UI SDK internals. */\nconst terminalPrimitive = definePrimitive({\n  name: \"terminal\",\n  options: {\n    onRun: \"action\",\n    onClear: \"callback\",\n    onWrite: \"callback\",\n    running: \"boolean\",\n    busy: \"string\",\n    output: \"value\",\n    controller: \"value\",\n  },\n  state: (_options: {\n    onRun?: (line: string) => void\n    onClear?: () => void\n    onWrite?: (text: string, error: boolean) => void\n    running?: boolean\n    busy?: string\n    output?: () => { id: number; text: string }[]\n    controller?: TerminalController\n  }) => ({}),\n  api: (context) => {\n    const opts = () => context.options()\n    return {\n      /** Runs one line, as if typed at the prompt. */\n      run(command: string) {\n        const line = String(command ?? \"\")\n        if (opts().running) throw new Error(opts().busy ?? english.busy)\n        if (!line.trim()) throw new Error(\"Give a command to run.\")\n        // One line of text: control characters could fake what the person sees echoed.\n        if (/[\\x00-\\x1f\\x7f‪-‮⁦-⁩]/.test(line)) throw new Error(\"Give one line of plain text, without control characters.\")\n        opts().onRun?.(line)\n        return true\n      },\n      /** Clears the output. */\n      clear() {\n        opts().onClear?.()\n        return true\n      },\n      print(text: string) {\n        opts().onWrite?.(String(text), false)\n        return true\n      },\n      error(text: string) {\n        opts().onWrite?.(String(text), true)\n        return true\n      },\n      /** The last lines of output, as plain text, keyed by line. */\n      items: () => (opts().output?.() ?? []).slice(-50).map((line) => ({ value: String(line.id), label: line.text })),\n    }\n  },\n  slots: (slot) => ({\n    root: slot({\n      role: \"group\",\n      attrs: () => ({ \"aria-roledescription\": \"terminal\" }),\n    }),\n  }),\n  agent: { actions: [\"run\", \"clear\"], items: (api) => api.items() },\n})\n\n/** Splits a command line into words, keeping quoted words whole. */\nfunction words(line: string) {\n  return [...line.matchAll(/\"([^\"]*)\"|'([^']*)'|(\\S+)/g)].map((m) => m[1] ?? m[2] ?? m[3]!)\n}\n\n/** A word for the command line: quoted when it holds spaces or quotes. */\nconst quote = (word: string) => (/[\\s\"']/.test(word) ? `\"${word.replace(/\"/g, \"'\")}\"` : word)\n\nconst commonPrefix = (list: string[]) =>\n  list.reduce((prefix, word) => {\n    let i = 0\n    while (i < prefix.length && prefix[i] === word[i]) i++\n    return prefix.slice(0, i)\n  })\n\ntype SessionOptions = {\n  screen: Screen\n  /** Read at each use, so new commands, words and handlers take effect at once. */\n  commands: () => Record<string, TerminalCommand>\n  onCommand: () => ((line: string, io: TerminalIO) => TerminalResult) | undefined\n  messages: () => TerminalMessages\n  onRunning: (running: boolean) => void\n  history?: string[]\n}\n\n/**\n * Runs command lines on a screen: the built-in `help`, `clear` and `history`, your\n * commands (printing, streaming an async iterable, or failing), Ctrl+C to stop one, and\n * Tab completion. `onRunning` says when one starts and ends.\n */\nfunction createTerminalSession(options: SessionOptions) {\n  const { screen } = options\n  let sent = [...(options.history ?? [])]\n  let abort: AbortController | null = null\n\n  const builtins: Record<string, TerminalCommand> = {\n    help: {\n      description: \"Lists the commands\",\n      run: (_args, io) => {\n        const all = commands()\n        const width = Math.max(...Object.keys(all).map((name) => name.length + (all[name]!.usage?.length ?? 0) + 1))\n        for (const [name, command] of Object.entries(all).sort(([a], [b]) => a.localeCompare(b))) {\n          const head = `${name}${command.usage ? ` ${command.usage}` : \"\"}`\n          io.print(`\\x1b[1m${head}\\x1b[22m${\" \".repeat(Math.max(2, width - head.length + 2))}${command.description ?? \"\"}\\n`)\n        }\n      },\n    },\n    clear: { description: \"Clears the screen (Ctrl+L)\", run: () => screen.clear() },\n    history: {\n      description: \"Lists the commands you've run\",\n      run: (_args, io) => sent.forEach((line, i) => io.print(`${String(i + 1).padStart(4)}  ${line}\\n`)),\n    },\n  }\n  const commands = () => ({ ...builtins, ...options.commands() })\n  // Own commands only: \"toString\" or \"constructor\" isn't a command.\n  const commandOf = (name: string) => {\n    const all = commands()\n    return Object.hasOwn(all, name) ? all[name] : undefined\n  }\n\n  async function execute(line: string) {\n    screen.note(plain(line), \"command\")\n    if (line.trim()) sent = [...sent.filter((l) => l !== line), line].slice(-500)\n    const [name, ...args] = words(line)\n    if (!name) return\n    const command = commandOf(name)\n    const onCommand = options.onCommand()\n    const messages = options.messages()\n    const controller = new AbortController()\n    abort = controller\n    const io: TerminalIO = {\n      print: (text) => void (!controller.signal.aborted && screen.write(text)),\n      error: (text) => void (!controller.signal.aborted && screen.write(text, { error: true })),\n      signal: controller.signal,\n    }\n    // Ctrl+C ends the wait, even for a command that never looks at its signal.\n    const stopped = new Promise<\"stopped\">((resolve) => controller.signal.addEventListener(\"abort\", () => resolve(\"stopped\"), { once: true }))\n    options.onRunning(true)\n    try {\n      if (!command && !onCommand) io.error(`${messages.notFound(name)}\\n`)\n      const result = command ? command.run(args, io) : onCommand ? onCommand(line, io) : undefined\n      if (result && typeof result === \"object\" && Symbol.asyncIterator in result) {\n        const chunks = (result as AsyncIterable<string>)[Symbol.asyncIterator]()\n        while (true) {\n          const next = await Promise.race([chunks.next(), stopped])\n          if (next === \"stopped\") {\n            void chunks.return?.()\n            break\n          }\n          if (next.done) break\n          io.print(next.value)\n        }\n      } else {\n        const value = await Promise.race([Promise.resolve(result), stopped])\n        if (typeof value === \"string\" && value !== \"stopped\") io.print(value.endsWith(\"\\n\") ? value : `${value}\\n`)\n      }\n    } catch (failure) {\n      if (!controller.signal.aborted) io.error(`${failure instanceof Error ? failure.message : String(failure ?? \"Failed.\")}\\n`)\n    } finally {\n      // Only the command still running clears the running state: a stopped one already did.\n      if (abort === controller) {\n        screen.finish()\n        abort = null\n        options.onRunning(false)\n      }\n    }\n  }\n\n  /** Ctrl+C on a running command: it stops, and the prompt comes back at once. */\n  function stop() {\n    abort?.abort()\n    abort = null\n    screen.finish()\n    screen.note(\"^C\", \"info\", { quiet: true })\n    options.onRunning(false)\n    announce(options.messages().stopped)\n  }\n\n  /** What Tab can put in: the options for the word being typed, and what comes before it. */\n  function complete(value: string) {\n    const found = [...value.matchAll(/\"([^\"]*)\"?|'([^']*)'?|(\\S+)/g)]\n    if (!found.length) return null\n    const ending = /\\s$/.test(value)\n    const last = found.at(-1)!\n    const partial = ending ? \"\" : (last[1] ?? last[2] ?? last[3] ?? \"\")\n    // What's kept is everything before the word being typed, by its place in the line.\n    const before = ending ? value : value.slice(0, last.index)\n    if (found.length === 1 && !ending) {\n      const options = Object.keys(commands()).filter((name) => name.startsWith(partial)).sort()\n      return { options, partial, before }\n    }\n    const command = commandOf(found[0]![1] ?? found[0]![2] ?? found[0]![3]!)\n    if (!command?.complete) return null\n    const args = found.slice(1).map((m) => m[1] ?? m[2] ?? m[3]!)\n    if (ending) args.push(\"\")\n    const options = command.complete(args).filter((option) => option.startsWith(partial)).sort()\n    return { options, partial, before }\n  }\n\n  /**\n   * Tab on `value`: the new text for the prompt, or a list to show (the second Tab with\n   * several matches, as shells do), or nothing to do (Tab then moves on).\n   */\n  function tab(value: string, lastTab: string | null): { set?: string; list?: string[] } | null {\n    const found = complete(value)\n    if (!found || !found.options.length) return null\n    if (found.options.length === 1) return { set: `${found.before}${quote(found.options[0]!)} ` }\n    const prefix = commonPrefix(found.options)\n    if (prefix.length > found.partial.length) return { set: `${found.before}${quote(prefix)}` }\n    return lastTab === value ? { list: found.options } : {}\n  }\n\n  return {\n    execute,\n    stop,\n    complete,\n    tab,\n    /** Aborts a running command quietly, as the terminal leaves the page. */\n    dispose: () => {\n      abort?.abort()\n      abort = null\n    },\n    running: () => abort !== null,\n    sent: () => sent,\n    /** Commands Up brings back, before any have run here. */\n    seed: (lines: string[]) => {\n      if (!sent.length) sent = [...lines]\n    },\n  }\n}\n\nexport { commonPrefix, createTerminalController, createTerminalSession, english, quote, terminalPrimitive, words }\nexport type { TerminalCommand, TerminalController, TerminalControllerApi, TerminalIO, TerminalMessages, TerminalResult }\n",
      "type": "registry:file",
      "target": "@ui/terminal/session.ts"
    },
    {
      "path": "registry/uiset/ui/terminal/terminal.css",
      "content": "@layer ui-sdk, uiset.tokens, uiset.base, uiset.skin;\n\n/*\n * A terminal. ANSI colors map to tokens that hold 4.5:1 on the terminal's surface in each\n * scheme, so output a program colors stays readable in every skin. \"Black\" and \"white\"\n * follow the scheme rather than vanish into it.\n */\n@layer uiset.base {\n  :where([data-uiset]) {\n    --term-black: light-dark(var(--ui-foreground), var(--ui-muted-foreground));\n    --term-red: light-dark(oklch(0.5 0.19 27), oklch(0.8 0.13 25));\n    --term-green: light-dark(oklch(0.48 0.13 150), oklch(0.84 0.15 150));\n    --term-yellow: light-dark(oklch(0.5 0.11 80), oklch(0.89 0.13 95));\n    --term-blue: light-dark(oklch(0.48 0.16 258), oklch(0.8 0.1 250));\n    --term-magenta: light-dark(oklch(0.5 0.18 330), oklch(0.82 0.12 330));\n    --term-cyan: light-dark(oklch(0.48 0.09 210), oklch(0.85 0.1 205));\n    --term-white: light-dark(var(--ui-muted-foreground), var(--ui-foreground));\n    /* Bright black: the grey programs write asides in, muted in both schemes. */\n    --term-grey: var(--ui-muted-foreground);\n  }\n\n  .terminal {\n    position: relative;\n    display: grid;\n    grid-template-rows: 1fr auto;\n    block-size: var(--terminal-height, 22rem);\n    min-block-size: 0;\n    overflow: hidden;\n    border: 1px solid var(--ui-border);\n    border-radius: calc(var(--ui-radius) + 6px);\n    background: var(--ui-background);\n    color: var(--ui-foreground);\n    font-family: var(--ui-font-mono);\n    font-size: 0.8125rem;\n    line-height: 1.5;\n  }\n\n  .terminal-scroll {\n    min-block-size: 0;\n    overflow: auto;\n    padding: 0.75rem 0.875rem 0.25rem;\n    outline: none;\n    overscroll-behavior: contain;\n\n    &:focus-visible {\n      outline: 2px solid var(--ui-ring-border);\n      outline-offset: -2px;\n    }\n  }\n\n  .terminal-line {\n    min-block-size: 1.5em;\n    white-space: pre-wrap;\n    overflow-wrap: anywhere;\n    tab-size: 4;\n    /* Lines out of view skip layout, so long output scrolls smoothly. */\n    content-visibility: auto;\n    contain-intrinsic-size: auto 1.5em;\n\n    &[data-kind=\"err\"] {\n      color: var(--term-red);\n    }\n\n    &[data-kind=\"info\"] {\n      color: var(--ui-muted-foreground);\n    }\n\n    & a {\n      color: var(--term-blue);\n      text-decoration: underline;\n      text-underline-offset: 2px;\n    }\n  }\n\n  .terminal-ps1 {\n    color: var(--term-green);\n    font-weight: 600;\n    white-space: pre;\n  }\n\n  /* Program colors, scoped to terminal lines so they style nothing else on the page. */\n  .terminal-line {\n    [data-fg] { color: var(--term-fg); }\n    [data-fg=\"black\"] { --term-fg: var(--term-black); }\n    [data-fg=\"red\"] { --term-fg: var(--term-red); }\n    [data-fg=\"green\"] { --term-fg: var(--term-green); }\n    [data-fg=\"yellow\"] { --term-fg: var(--term-yellow); }\n    [data-fg=\"blue\"] { --term-fg: var(--term-blue); }\n    [data-fg=\"magenta\"] { --term-fg: var(--term-magenta); }\n    [data-fg=\"cyan\"] { --term-fg: var(--term-cyan); }\n    [data-fg=\"white\"] { --term-fg: var(--term-white); }\n    [data-fg=\"grey\"] { --term-fg: var(--term-grey); }\n\n    /* Backgrounds are tints, so the text over them keeps its contrast. */\n    [data-bg] { background: color-mix(in oklch, var(--term-bg) 18%, transparent); border-radius: 2px; }\n    [data-bg=\"black\"] { --term-bg: var(--term-black); }\n    [data-bg=\"red\"] { --term-bg: var(--term-red); }\n    [data-bg=\"green\"] { --term-bg: var(--term-green); }\n    [data-bg=\"yellow\"] { --term-bg: var(--term-yellow); }\n    [data-bg=\"blue\"] { --term-bg: var(--term-blue); }\n    [data-bg=\"magenta\"] { --term-bg: var(--term-magenta); }\n    [data-bg=\"cyan\"] { --term-bg: var(--term-cyan); }\n    [data-bg=\"white\"] { --term-bg: var(--term-white); }\n    [data-bg=\"grey\"] { --term-bg: var(--term-grey); }\n\n    /* Inverse is a solid fill of the text's color under the background color: a token that\n       clears 4.5:1 as text clears it as a fill, so badges like \" PASS \" stay readable. */\n    [data-inverse] {\n      border-radius: 2px;\n      background: var(--term-fg, var(--ui-foreground));\n      color: var(--ui-background);\n    }\n\n    [data-bold] { font-weight: 700; }\n    /* Dim text keeps its color (opacity would drop it under 4.5:1); plain dim text is muted. */\n    [data-dim]:not([data-fg]) { color: var(--ui-muted-foreground); }\n    [data-italic] { font-style: italic; }\n    [data-underline] { text-decoration: underline; }\n    [data-strike] { text-decoration: line-through; }\n    [data-underline][data-strike] { text-decoration: underline line-through; }\n  }\n\n  .terminal-prompt {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    /* One character after the prompt, as in the lines above it (B32). */\n    gap: 0 1ch;\n    padding: 0.25rem 0.875rem 0.75rem;\n  }\n\n  .terminal-input[data-slot] {\n    flex: 1;\n    /* Room to type in a narrow terminal; the status moves to its own row instead. */\n    min-inline-size: 10ch;\n    block-size: 1.5em;\n    padding: 0;\n    border: 0;\n    border-radius: 0;\n    background: transparent;\n    box-shadow: none;\n    color: inherit;\n    font: inherit;\n    caret-color: var(--term-green);\n\n    &:focus-visible {\n      outline: none;\n    }\n  }\n\n  .terminal:has(.terminal-input:focus-visible) {\n    outline: 2px solid var(--ui-ring-border);\n    outline-offset: 2px;\n  }\n\n  .terminal-status {\n    overflow: hidden;\n    color: var(--ui-muted-foreground);\n    font-size: 0.75rem;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n\n    &:empty {\n      display: none;\n    }\n  }\n\n  .terminal-jump[data-slot] {\n    position: absolute;\n    inset-block-end: 3rem;\n    inset-inline-end: 1rem;\n    font-family: var(--ui-font-sans, system-ui);\n    font-size: 0.8125rem;\n  }\n}\n\n/* The prompt is a command line, not a form field: skins' field dressing is undone here. */\n@layer uiset.skin {\n  [data-uiset] .terminal .terminal-input[data-slot=\"input\"] {\n    border: 0;\n    border-radius: 0;\n    background: transparent;\n    box-shadow: none;\n    color: inherit;\n\n    /* The whole terminal draws the ring; the line itself draws none. */\n    &:focus-visible {\n      outline: none;\n    }\n  }\n\n  @media (forced-colors: active) {\n    .terminal-line [data-inverse] {\n      forced-color-adjust: none;\n      background: CanvasText;\n      color: Canvas;\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/terminal/terminal.css"
    },
    {
      "path": "registry/uiset/ui/shell/shell.css",
      "content": "@layer ui-sdk, uiset.tokens, uiset.base, uiset.skin;\n\n@layer uiset.base {\n  :where([data-uiset]) {\n    /* Status colors: text and edges hold 4.5:1 / 3:1 on --ui-background in each scheme. */\n    /* Dark values also clear 4.5:1 on the mid-dark Blueprint and Studio panels. */\n    --tone-info: light-dark(oklch(0.48 0.15 255), oklch(0.86 0.08 240));\n    --tone-success: light-dark(oklch(0.47 0.12 150), oklch(0.87 0.11 150));\n    --tone-warning: light-dark(oklch(0.5 0.12 70), oklch(0.89 0.11 85));\n    --tone-danger: light-dark(oklch(0.46 0.19 27), oklch(0.86 0.08 25));\n    --tone-neutral: var(--ui-muted-foreground);\n  }\n\n  .uiset-visually-hidden {\n    position: absolute;\n    width: 1px;\n    height: 1px;\n    overflow: hidden;\n    clip-path: inset(50%);\n    white-space: nowrap;\n  }\n\n  .uiset-icon {\n    width: 1rem;\n    height: 1rem;\n    flex-shrink: 0;\n    fill: none;\n    stroke: currentColor;\n    stroke-width: 1.75;\n    stroke-linecap: round;\n    stroke-linejoin: round;\n  }\n\n  /* App shell */\n\n  .app-shell {\n    --sidebar-width: 15rem;\n    display: grid;\n    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);\n    min-height: var(--app-shell-height, 100dvh);\n    background: var(--ui-background);\n    color: var(--ui-foreground);\n\n    &[data-narrow] {\n      grid-template-columns: minmax(0, 1fr);\n    }\n  }\n\n  [data-sidebar=\"collapsed\"] .app-shell:not([data-narrow]) {\n    --sidebar-width: 3.75rem;\n  }\n\n  .app-sidebar,\n  .app-drawer {\n    display: flex;\n    flex-direction: column;\n    gap: 0.75rem;\n    min-width: 0;\n    padding: 0.75rem;\n    border-inline-end: 1px solid var(--ui-border);\n    background: color-mix(in oklab, var(--ui-muted) 55%, var(--ui-background));\n    overflow: hidden;\n  }\n\n  .app-sidebar-top {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 0.5rem;\n    min-height: 2.25rem;\n  }\n\n  .app-brand {\n    min-width: 0;\n    margin: 0;\n    overflow: hidden;\n    font-weight: 600;\n    white-space: nowrap;\n    text-overflow: ellipsis;\n  }\n\n  [data-sidebar=\"collapsed\"] .app-sidebar .app-brand {\n    display: none;\n  }\n\n  .app-sidebar-toggle,\n  .app-menu-button {\n    flex-shrink: 0;\n    width: 2.25rem;\n    height: 2.25rem;\n    padding: 0;\n  }\n\n  .app-main {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n  }\n\n  /* Its padding counts in its height, with or without a page's box-sizing reset. */\n  .app-header {\n    box-sizing: border-box;\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    gap: 0.75rem;\n    min-height: 3.25rem;\n    padding: 0.5rem 1rem;\n    border-bottom: 1px solid var(--ui-border);\n  }\n\n  /* The padding is a variable, so a full-bleed page (an inbox) can cancel it exactly. */\n  .app-content {\n    --app-shell-pad: clamp(1rem, 3vw, 2rem);\n    flex: 1;\n    min-width: 0;\n    padding: var(--app-shell-pad);\n  }\n\n  .sidebar-nav {\n    display: grid;\n    gap: 1rem;\n  }\n\n  .sidebar-group {\n    display: grid;\n    gap: 0.25rem;\n\n    ul {\n      display: grid;\n      gap: 2px;\n      margin: 0;\n      padding: 0;\n      list-style: none;\n    }\n  }\n\n  .sidebar-group-title {\n    margin: 0;\n    padding-inline: 0.5rem;\n    font-size: 0.75rem;\n    font-weight: 600;\n    color: var(--ui-muted-foreground);\n  }\n\n  /* Collapsed to icons: group titles leave the layout (a hidden title used to keep its\n     width and push the icons off center), and a rule separates the groups instead. */\n  [data-sidebar=\"collapsed\"] .app-sidebar {\n    .sidebar-group-title {\n      position: absolute;\n      width: 1px;\n      height: 1px;\n      overflow: hidden;\n      clip-path: inset(50%);\n      white-space: nowrap;\n    }\n\n    .sidebar-nav {\n      gap: 0.5rem;\n    }\n\n    .sidebar-group + .sidebar-group {\n      padding-block-start: 0.5rem;\n      border-block-start: 1px solid var(--ui-border);\n    }\n  }\n\n  /* A tooltip trigger, so UI SDK's stylesheet would draw it as a button: reset that. */\n  .sidebar-link {\n    display: flex;\n    align-items: center;\n    justify-content: flex-start;\n    gap: 0.625rem;\n    width: 100%;\n    height: auto;\n    min-height: 2.25rem;\n    padding: 0.375rem 0.5rem;\n    border: 0;\n    border-radius: var(--ui-radius);\n    background: transparent;\n    color: var(--ui-foreground);\n    font-weight: 400;\n    text-decoration: none;\n\n    &:hover {\n      background: var(--ui-muted);\n    }\n\n    &[aria-current=\"page\"] {\n      position: relative;\n      background: var(--ui-muted);\n      font-weight: 600;\n\n      /* A short bar, inset from the corners (an inset shadow bent around them). */\n      &::before {\n        content: \"\";\n        position: absolute;\n        inset-block: 0.5rem;\n        inset-inline-start: 0;\n        inline-size: 3px;\n        border-radius: 999px;\n        background: var(--ui-primary);\n      }\n    }\n\n    &:focus-visible {\n      outline: 2px solid var(--ui-ring-border);\n      outline-offset: -2px;\n    }\n  }\n\n  .sidebar-icon {\n    display: inline-grid;\n    place-items: center;\n    width: 1.25rem;\n    flex-shrink: 0;\n  }\n\n  .sidebar-label {\n    flex: 1;\n    min-width: 0;\n    overflow: hidden;\n    white-space: nowrap;\n    text-overflow: ellipsis;\n  }\n\n  .sidebar-badge {\n    font-size: 0.75rem;\n  }\n\n  /* Each link is a square icon button, centered in the rail under the toggle; the current\n     page shows by its fill and an accent icon (a side bar on a square reads as a glitch). */\n  [data-sidebar=\"collapsed\"] .app-sidebar {\n    .sidebar-link {\n      justify-content: center;\n      inline-size: 2.25rem;\n      min-block-size: 2.25rem;\n      margin-inline: auto;\n      padding: 0;\n\n      &[aria-current=\"page\"] {\n        color: color-mix(in oklch, var(--ui-primary) 55%, var(--ui-foreground));\n\n        &::before {\n          display: none;\n        }\n      }\n    }\n\n    .sidebar-label,\n    .sidebar-badge {\n      position: absolute;\n      width: 1px;\n      height: 1px;\n      overflow: hidden;\n      clip-path: inset(50%);\n    }\n  }\n\n  /* The tooltip repeats the visible label, so it only shows when labels are hidden. */\n  [data-sidebar=\"expanded\"] .sidebar-tooltip,\n  .app-drawer .sidebar-tooltip {\n    display: none;\n  }\n\n  /* Page structure */\n\n  .breadcrumbs ol {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    gap: 0.25rem;\n    margin: 0;\n    padding: 0;\n    list-style: none;\n    font-size: 0.875rem;\n  }\n\n  .breadcrumbs li {\n    display: inline-flex;\n    align-items: center;\n    gap: 0.25rem;\n    color: var(--ui-muted-foreground);\n\n    a {\n      color: inherit;\n      text-underline-offset: 0.2em;\n    }\n\n    [aria-current=\"page\"] {\n      color: var(--ui-foreground);\n      font-weight: 500;\n    }\n  }\n\n  .breadcrumbs-separator {\n    width: 0.875rem;\n    height: 0.875rem;\n  }\n\n  .page-header {\n    display: grid;\n    gap: 0.75rem;\n    margin-bottom: 1.5rem;\n  }\n\n  .page-header-row {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: flex-end;\n    justify-content: space-between;\n    gap: 1rem;\n  }\n\n  .page-header-title {\n    margin: 0;\n    font-size: clamp(1.5rem, 3vw, 1.875rem);\n    line-height: 1.15;\n    text-wrap: balance;\n  }\n\n  .page-header-description {\n    max-width: 42rem;\n    margin: 0.375rem 0 0;\n    color: var(--ui-muted-foreground);\n  }\n\n  .page-header-actions {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 0.5rem;\n  }\n\n  .card {\n    display: grid;\n    gap: 1rem;\n    min-width: 0;\n    padding: 1.25rem;\n    border: 1px solid var(--ui-border);\n    border-radius: calc(var(--ui-radius) + 6px);\n    background: var(--ui-background);\n  }\n\n  .card-header {\n    display: grid;\n    gap: 0.25rem;\n  }\n\n  .card-title {\n    margin: 0;\n    font-size: 1rem;\n    font-weight: 600;\n  }\n\n  .card-description {\n    margin: 0;\n    color: var(--ui-muted-foreground);\n    font-size: 0.875rem;\n  }\n\n  .card-footer {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 0.5rem;\n    padding-top: 1rem;\n    border-top: 1px solid var(--ui-border);\n  }\n\n  /* Data display */\n\n  .badge {\n    --badge-color: var(--tone-neutral);\n    display: inline-flex;\n    align-items: center;\n    gap: 0.25rem;\n    padding: 0.0625rem 0.5rem;\n    border: 1px solid color-mix(in oklab, var(--badge-color) 55%, transparent);\n    border-radius: min(999px, calc(var(--ui-radius) * 999));\n    background: color-mix(in oklab, var(--badge-color) 10%, var(--ui-background));\n    color: var(--badge-color);\n    font-size: 0.75rem;\n    font-weight: 600;\n    line-height: 1.5;\n    white-space: nowrap;\n\n    &[data-tone=\"info\"] {\n      --badge-color: var(--tone-info);\n    }\n\n    &[data-tone=\"success\"] {\n      --badge-color: var(--tone-success);\n    }\n\n    &[data-tone=\"warning\"] {\n      --badge-color: var(--tone-warning);\n    }\n\n    &[data-tone=\"danger\"] {\n      --badge-color: var(--tone-danger);\n    }\n  }\n\n  .count-badge {\n    position: relative;\n    display: inline-flex;\n    vertical-align: middle;\n  }\n\n  /* The solid button's colors: every skin already holds 4.5:1 between them. */\n  .count-badge-count {\n    position: absolute;\n    inset-block-start: 0;\n    inset-inline-end: 0;\n    translate: 40% -40%;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    box-sizing: border-box;\n    min-width: 1.125rem;\n    height: 1.125rem;\n    padding-inline: 0.3125rem;\n    border-radius: min(999px, calc(var(--ui-radius) * 999));\n    background: var(--uiset-solid-bg);\n    color: var(--uiset-solid-fg);\n    box-shadow: 0 0 0 2px var(--ui-background);\n    font-size: 0.6875rem;\n    font-weight: 600;\n    font-variant-numeric: tabular-nums;\n    line-height: 1;\n    white-space: nowrap;\n    pointer-events: none;\n\n    &:dir(rtl) {\n      translate: -40% -40%;\n    }\n\n    &[data-dot] {\n      min-width: 0.625rem;\n      width: 0.625rem;\n      height: 0.625rem;\n      padding: 0;\n      translate: 20% -20%;\n\n      &:dir(rtl) {\n        translate: -20% -20%;\n      }\n    }\n  }\n\n  /* Each avatar overlaps the one before it, with a ring of the page color between them. */\n  .avatar-group {\n    display: inline-flex;\n    align-items: center;\n    vertical-align: middle;\n\n    & > * {\n      box-shadow: 0 0 0 2px var(--ui-background);\n    }\n\n    /* A small overlap: more would cover the next avatar's initials. */\n    & > * + * {\n      margin-inline-start: calc(var(--ui-spacing) * -1);\n    }\n  }\n\n  .avatar-group-more {\n    font-variant-numeric: tabular-nums;\n  }\n\n  /* Content sits at the top, so figures in a row line up whether or not one has a trend. */\n  .stat {\n    display: grid;\n    align-content: start;\n    gap: 0.25rem;\n\n    p {\n      margin: 0;\n    }\n  }\n\n  .stat-label {\n    font-size: 0.875rem;\n    color: var(--ui-muted-foreground);\n  }\n\n  .stat-trend {\n    max-inline-size: 100%;\n  }\n\n  /* A standalone figure keeps proportional digits; tabular ones look loose this big. */\n  .stat-value {\n    font-size: 1.75rem;\n    font-weight: 650;\n    line-height: 1.15;\n  }\n\n  .stat-change {\n    display: inline-flex;\n    align-items: center;\n    gap: 0.25rem;\n    font-size: 0.875rem;\n    font-weight: 600;\n\n    &[data-good] {\n      color: var(--tone-success);\n    }\n\n    &[data-bad] {\n      color: var(--tone-danger);\n    }\n  }\n\n  .stat-period,\n  .stat-description {\n    color: var(--ui-muted-foreground);\n    font-weight: 400;\n  }\n\n  .stat-description {\n    font-size: 0.8125rem;\n  }\n\n  .empty-state {\n    display: grid;\n    justify-items: center;\n    gap: 0.5rem;\n    padding: 2.5rem 1rem;\n    text-align: center;\n  }\n\n  .empty-state-icon {\n    width: 2rem;\n    height: 2rem;\n    color: var(--ui-muted-foreground);\n  }\n\n  .empty-state-title {\n    margin: 0.25rem 0 0;\n    font-size: 1.0625rem;\n  }\n\n  .empty-state-description {\n    max-width: 28rem;\n    margin: 0;\n    color: var(--ui-muted-foreground);\n  }\n\n  .empty-state-actions {\n    display: flex;\n    flex-wrap: wrap;\n    justify-content: center;\n    gap: 0.5rem;\n    margin-top: 0.5rem;\n  }\n\n  .skeleton {\n    display: block;\n    width: 100%;\n    border-radius: var(--ui-radius);\n    background: linear-gradient(\n        90deg,\n        var(--ui-muted) 0 35%,\n        color-mix(in oklab, var(--ui-muted), var(--ui-foreground) 8%) 50%,\n        var(--ui-muted) 65% 100%\n      )\n      0 0 / 300% 100%;\n    animation: skeleton-wave 1.6s ease-in-out infinite;\n  }\n\n  .skeleton-text {\n    display: grid;\n    gap: 0.5rem;\n\n    .skeleton {\n      height: 0.75rem;\n    }\n  }\n\n  @keyframes skeleton-wave {\n    from {\n      background-position: 100% 0;\n    }\n    to {\n      background-position: 0 0;\n    }\n  }\n\n  .description-list {\n    display: grid;\n    margin: 0;\n\n    &[data-layout=\"columns\"] .description-item {\n      display: grid;\n      grid-template-columns: minmax(8rem, 1fr) 2fr;\n      gap: 1rem;\n    }\n\n    dt {\n      color: var(--ui-muted-foreground);\n    }\n\n    dd {\n      margin: 0;\n      min-width: 0;\n      overflow-wrap: anywhere;\n    }\n  }\n\n  .description-item {\n    padding-block: 0.625rem;\n    border-bottom: 1px solid var(--ui-border);\n\n    &:last-child {\n      border-bottom: 0;\n    }\n  }\n\n  .item-list {\n    display: grid;\n    margin: 0;\n    padding: 0;\n    list-style: none;\n  }\n\n  .item {\n    display: flex;\n    align-items: center;\n    gap: 0.75rem;\n    min-height: 3rem;\n    padding-block: 0.625rem;\n    border-bottom: 1px solid var(--ui-border);\n\n    &:last-child {\n      border-bottom: 0;\n    }\n  }\n\n  .item-text {\n    display: grid;\n    flex: 1;\n    min-width: 0;\n  }\n\n  .item-title {\n    overflow: hidden;\n    color: var(--ui-foreground);\n    font-weight: 500;\n    white-space: nowrap;\n    text-overflow: ellipsis;\n  }\n\n  a.item-title {\n    text-decoration: none;\n\n    &:hover {\n      text-decoration: underline;\n    }\n  }\n\n  .item-description,\n  .item-meta {\n    color: var(--ui-muted-foreground);\n    font-size: 0.8125rem;\n  }\n\n  .item-actions {\n    display: flex;\n    gap: 0.25rem;\n  }\n\n  .alert {\n    --alert-color: var(--tone-info);\n    display: grid;\n    grid-template-columns: auto minmax(0, 1fr) auto;\n    gap: 0.75rem;\n    align-items: start;\n    padding: 0.875rem 1rem;\n    position: relative;\n    overflow: hidden;\n    padding-inline-start: calc(1rem + 3px);\n    border: 1px solid color-mix(in oklab, var(--alert-color) 45%, var(--ui-border));\n    border-radius: calc(var(--ui-radius) + 4px);\n    background: color-mix(in oklab, var(--alert-color) 7%, var(--ui-background));\n\n    /* The accent is a straight bar the corners clip; a thick border would taper into them. */\n    &::before {\n      content: \"\";\n      position: absolute;\n      inset-block: 0;\n      inset-inline-start: 0;\n      inline-size: 4px;\n      background: var(--alert-color);\n    }\n\n    &[data-tone=\"success\"] {\n      --alert-color: var(--tone-success);\n    }\n\n    &[data-tone=\"warning\"] {\n      --alert-color: var(--tone-warning);\n    }\n\n    &[data-tone=\"danger\"] {\n      --alert-color: var(--tone-danger);\n    }\n  }\n\n  .alert-icon {\n    width: 1.25rem;\n    height: 1.25rem;\n    color: var(--alert-color);\n  }\n\n  .alert-body {\n    display: grid;\n    gap: 0.25rem;\n  }\n\n  .alert-title {\n    margin: 0;\n    font-weight: 600;\n  }\n\n  .alert-text {\n    color: var(--ui-foreground);\n  }\n\n  .alert-actions {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 0.5rem;\n    margin-top: 0.375rem;\n  }\n\n  .alert-dismiss {\n    width: 2rem;\n    height: 2rem;\n    padding: 0;\n  }\n\n  /* Sized in its own em so a key sits inside a line of text, not below it. */\n  .kbd {\n    display: inline-flex;\n    align-items: center;\n    min-width: 1.75em;\n    height: 1.75em;\n    justify-content: center;\n    padding-inline: 0.4em;\n    vertical-align: 0.125em;\n    line-height: 1;\n    border: 1px solid var(--ui-input);\n    border-bottom-width: 2px;\n    border-radius: calc(var(--ui-radius) / 2 + 2px);\n    background: var(--ui-background);\n    color: var(--ui-foreground);\n    font-family: var(--ui-font-mono);\n    font-size: 0.75rem;\n  }\n\n  .spinner {\n    display: inline-block;\n    flex-shrink: 0;\n    border: 2px solid color-mix(in oklab, var(--ui-foreground) 18%, transparent);\n    border-top-color: var(--ui-primary);\n    border-radius: 50%;\n    animation: spinner-turn 0.8s linear infinite;\n  }\n\n  @keyframes spinner-turn {\n    to {\n      rotate: 1turn;\n    }\n  }\n\n  .stepper {\n    container-type: inline-size;\n  }\n\n  .stepper ol {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 0.25rem 1rem;\n    margin: 0;\n    padding: 0;\n    list-style: none;\n  }\n\n  /* Marks line up across steps, whether a step has a description or not. */\n  .stepper-step {\n    align-items: flex-start;\n    gap: 0.625rem;\n    height: auto;\n    min-height: 2.75rem;\n    padding: 0.375rem 0.625rem 0.375rem 0.375rem;\n    text-align: start;\n  }\n\n  @container (max-width: 30rem) {\n    .stepper ol {\n      flex-direction: column;\n      flex-wrap: nowrap;\n    }\n  }\n\n  .stepper-mark {\n    box-sizing: border-box;\n    display: inline-grid;\n    place-items: center;\n    width: 1.75rem;\n    height: 1.75rem;\n    flex-shrink: 0;\n    border: 2px solid var(--ui-input);\n    border-radius: 50%;\n    font-size: 0.8125rem;\n    font-weight: 600;\n    font-variant-numeric: tabular-nums;\n  }\n\n  .stepper li[data-state=\"current\"] .stepper-mark {\n    border-color: var(--ui-primary);\n    color: var(--ui-primary);\n  }\n\n  .stepper li[data-state=\"complete\"] .stepper-mark {\n    border-color: var(--ui-primary);\n    background: var(--ui-primary);\n    color: var(--ui-primary-foreground);\n  }\n\n  /* The label's first line centers on the mark, whatever the page's line height. */\n  .stepper-text {\n    display: grid;\n    padding-block-start: max(0px, calc((1.75rem - 1lh) / 2));\n  }\n\n  .stepper-label {\n    font-weight: 600;\n  }\n\n  .stepper-description {\n    font-size: 0.75rem;\n    color: var(--ui-muted-foreground);\n  }\n\n  .search-field {\n    position: relative;\n    display: flex;\n    /* A row even as a UI SDK field (which stacks its parts), so the icon centers. */\n    flex-direction: row;\n    align-items: center;\n    width: 100%;\n\n    [data-slot=\"input\"] {\n      width: 100%;\n      padding-inline: 2.125rem 3rem;\n    }\n  }\n\n  .search-field-icon {\n    position: absolute;\n    inset-inline-start: 0.625rem;\n    color: var(--ui-muted-foreground);\n    pointer-events: none;\n  }\n\n  .search-field-clear {\n    position: absolute;\n    inset-inline-end: 0.25rem;\n    width: 1.75rem;\n    height: 1.75rem;\n    padding: 0;\n  }\n\n  /* The browser's own clear button would duplicate ours. */\n  .search-field input[type=\"search\"]::-webkit-search-cancel-button {\n    display: none;\n  }\n\n  .search-field-hint {\n    position: absolute;\n    inset-inline-end: 0.5rem;\n    pointer-events: none;\n  }\n\n  .copy-button {\n    gap: 0.375rem;\n  }\n\n  @media (prefers-reduced-motion: reduce) {\n    .skeleton,\n    .spinner {\n      animation-duration: 0s;\n    }\n\n    .spinner {\n      border-top-color: var(--ui-muted-foreground);\n    }\n  }\n\n  @media (forced-colors: active) {\n    .badge,\n    .alert,\n    .kbd {\n      border-color: CanvasText;\n    }\n\n    /* Shadows don't draw here, so the rings become real edges. */\n    .avatar-group > *,\n    .count-badge-count {\n      outline: 1px solid CanvasText;\n    }\n\n    .count-badge-count {\n      background: Canvas;\n      color: CanvasText;\n    }\n\n    .sidebar-link[aria-current=\"page\"] {\n      outline: 2px solid Highlight;\n    }\n\n    .stepper li[data-state=\"complete\"] .stepper-mark {\n      background: Highlight;\n      color: HighlightText;\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/shell/shell.css"
    }
  ],
  "type": "registry:ui"
}