{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "typing-text",
  "type": "registry:item",
  "title": "Typing Text",
  "description": "Text typed out a letter at a time with a blinking caret, starting when it scrolls into view. Screen readers get the whole text at once; reduced motion shows it typed.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "motion"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/typing-text.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/typing-text.js",
      "content": "// Generated by zubra from typing-text.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { onMount } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"typing-text\";\n\nexport default $define(tag, {\n  props: {\n    \"text\": { attribute: \"text\", default: \"\", required: false },\n    \"speed\": { attribute: \"speed\", default: 45, required: false },\n    \"delay\": { attribute: \"delay\", default: 200, required: false },\n    \"caret\": { attribute: \"caret\", default: true, required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (typing-text) to ([data-zb-slotted=\\\"typing-text\\\"]) {\\n  :scope { display: inline; }\\n  .typing-shown::after { content: \\\"\\\"; display: inline-block; width: 0.08em; height: 1.05em; margin-left: 0.06em; vertical-align: -0.12em; background: currentColor; animation: typing-caret 1s steps(1) infinite; }\\n  .typing-done.typing-no-caret::after { display: none; }\\n  @keyframes typing-caret { 50% { opacity: 0; } }\\n  .typing-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\\n  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; } }\\n}\\n}\\n\",\n  template: \"\\n  <span class=\\\"typing\\\">\\n    <span class=\\\"typing-label\\\"></span>\\n    <span class=\\\"typing-shown\\\" aria-hidden=\\\"true\\\"></span>\\n  </span>\\n\",\n  setup($p, $emit) {\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                          \n\n  const typed = __zubraState(0)\n  const box = __zubraState(null)\n  const letters = __zubraComputed(() => (Array.from(String($p.text))))\n  const visible = __zubraComputed(() => (letters.get().slice(0, typed.get()).join(\"\")))\n  const done = __zubraComputed(() => (typed.get() >= letters.get().length))\n\n  onMount(() => {\n    const reduced = globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches\n    if (reduced || !(\"IntersectionObserver\" in globalThis)) { __zubraAssign(typed, letters.get().length); return }\n    let timer = 0\n    const next = () => {\n      if (typed.get() >= letters.get().length) return\n      __zubraAssign(typed, typed.get() + (1))\n      timer = setTimeout(next, Math.max(5, $p.speed))\n    }\n    const watcher = new IntersectionObserver((entries) => {\n      if (!entries.some((entry) => entry.isIntersecting)) return\n      watcher.disconnect()\n      timer = setTimeout(next, Math.max(0, $p.delay))\n    })\n    watcher.observe(box.get())\n    return () => { watcher.disconnect(); clearTimeout(timer) }\n  })\n    return [\n      { path: [0], ref: () => (($el) => (__zubraAssign(box, $el))) },\n      { path: [0, 0], text: () => $t($p.text) },\n      { path: [0, 1], toggle: \"typing-done\", value: () => $r(done) },\n      { path: [0, 1], toggle: \"typing-no-caret\", value: () => !($p.caret) },\n      { path: [0, 1], text: () => $t($r(visible)) },\n    ];\n  },\n});\n"
    }
  ]
}
