{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kit-a-docs",
  "type": "registry:lib",
  "title": "Kit a-docs",
  "description": "Helpers shared by the docs blocks.",
  "dependencies": [
    "lucide-react@^1.49.0"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/copy-button.json",
    "https://ui.klarhimmel.com/r/demos.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-d-chrome.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/_shared/a-docs-kit.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/_shared/a-docs-kit.tsx",
      "content": "// Pieces shared by the docs-kit blocks (package A): code panel, live/placeholder stage, copy action, variable highlighting.\nimport { useInteractive } from './d-chrome-kit';\nimport { useEffect, useRef, useState, type ReactNode } from 'react';\nimport { Check, Copy } from 'lucide-react';\nimport { Media, Text, type PropPath } from '../../editing';\nimport { Demo } from '../../demos/demo';\nimport { Button, type ButtonVariant } from '../../ui/button';\nimport { CopyButton } from '../../ui/copy-button';\nimport { cn } from '../../lib/utils';\nimport { useEditing } from './kit';\n\n/**\n * Code with an optional file name bar and a copy button. The code is an editable slot.\n * `command` shows a `$` prompt (single-line shell commands). `flush` drops the outer border so the panel can sit inside a card.\n */\nexport function CodePanel({\n  path, code, filename, filenamePath, command, flush, className,\n}: { path: PropPath; code: string; filename?: string; filenamePath?: PropPath; command?: boolean; flush?: boolean; className?: string }) {\n  const editing = useEditing();\n  const bar = !!filenamePath && (!!filename || editing);\n  const oneLine = !!command && !code.includes('\\n');\n  const pre = (\n    <pre tabIndex={0} className={cn('min-w-0 overflow-x-auto p-4 font-kh-mono text-kh-small leading-relaxed text-kh-ink focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--kh-focus)', oneLine && 'flex-1 whitespace-nowrap py-3.5')}>\n      {oneLine ? <span aria-hidden className=\"mr-3 select-none text-kh-muted\">$</span> : null}\n      <Text path={path} value={code} as=\"code\" multiline placeholder=\"Code\" className=\"whitespace-pre\" />\n    </pre>\n  );\n  return (\n    // As CodeSnippet: the overlaid copy button gets its own strip above the code, so a long first line never runs under it (KB-432).\n    <div className={cn('relative bg-kh-surface [&:has(>button)>pre]:pt-12', !flush && 'overflow-hidden rounded-kh-lg border border-kh-line', className)}>\n      {bar && (\n        <div className=\"flex items-center justify-between gap-3 border-b border-kh-line bg-kh-surface-2 py-1 pl-4 pr-2\">\n          <Text path={filenamePath} value={filename ?? ''} as=\"span\" placeholder=\"File name\" className=\"min-w-0 truncate font-kh-mono text-kh-caption text-kh-muted\" />\n          <CopyButton value={code} label=\"Copy code\" />\n        </div>\n      )}\n      {oneLine && !bar ? (\n        <div className=\"flex items-center pr-2\">\n          {pre}\n          <CopyButton value={code} label=\"Copy command\" />\n        </div>\n      ) : (\n        <>\n          {!bar && <CopyButton value={code} label=\"Copy code\" className=\"absolute right-2 top-2 z-10 bg-kh-surface\" />}\n          {pre}\n        </>\n      )}\n    </div>\n  );\n}\n\n/** True when a media value holds something worth a stage (image or alt text). */\nexport const hasMedia = (m: { src?: string; alt: string } | undefined) => !!m && (!!m.src || !!m.alt);\n\n/**\n * The stage of a docs block: a live demo when `demo` names one, else the media placeholder/image.\n * While editing, the demo id is an editable caption so it can be changed.\n */\nexport function Stage({\n  demoPath, demo, mediaPath, media, ratio = '16 / 8', className,\n}: { demoPath: PropPath; demo: string | undefined; mediaPath: PropPath; media: { src?: string; alt: string } | undefined; ratio?: string; className?: string }) {\n  const editing = useEditing();\n  return (\n    <div className={cn('flex flex-col bg-kh-surface-2', className)}>\n      {demo ? (\n        <div className=\"flex min-h-44 flex-1 items-center justify-center overflow-x-auto bg-kh-canvas p-6 @3xl:p-10\">\n          <div className=\"max-w-full\" data-kh-specimen>\n            <Demo id={demo} />\n          </div>\n        </div>\n      ) : (\n        <Media path={mediaPath} value={media ?? { src: '', alt: '' }} ratio={ratio} className=\"rounded-none\" />\n      )}\n      {editing && (\n        <p className=\"flex items-center gap-2 border-t border-kh-line px-4 py-2 text-kh-caption text-kh-muted\">\n          Demo id\n          <Text path={demoPath} value={demo ?? ''} as=\"code\" placeholder=\"e.g. button-variants\" className=\"font-kh-mono text-kh-ink\" />\n        </p>\n      )}\n    </div>\n  );\n}\n\n/** A button that copies `value` and confirms. The label is an editable slot. */\nexport function CopyAction({\n  path, label, value, variant = 'primary', className,\n}: { path: PropPath; label: string; value: string; variant?: ButtonVariant; className?: string }) {\n  const interactive = useInteractive();\n  const [done, setDone] = useState(false);\n  const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n  useEffect(() => () => clearTimeout(timer.current), []);\n  if (!interactive) return null; // copying needs JavaScript: no dead button in HTML read without scripts\n  return (\n    <Button\n      variant={variant}\n      size=\"md\"\n      className={className}\n      icon={done ? <Check aria-hidden className=\"size-4\" /> : <Copy aria-hidden className=\"size-4\" />}\n      onClick={async () => {\n        try {\n          await navigator.clipboard.writeText(value);\n          setDone(true);\n          clearTimeout(timer.current);\n          timer.current = setTimeout(() => setDone(false), 1600);\n        } catch {\n          /* clipboard unavailable: leave the button as is */\n        }\n      }}\n    >\n      <Text path={path} value={label} as=\"span\" placeholder=\"Label\" />\n      <span role=\"status\" className=\"sr-only\">{done ? 'Copied' : ''}</span>\n    </Button>\n  );\n}\n\n/** Splits text on {variables} and wraps each in a highlight. */\nexport function Variables({ text, className }: { text: string; className?: string }): ReactNode {\n  const parts = text.split(/(\\{[A-Za-z0-9_-]+\\})/g);\n  return (\n    <span className={className}>\n      {parts.map((p, i) =>\n        /^\\{[A-Za-z0-9_-]+\\}$/.test(p) ? (\n          <mark key={i} className=\"rounded-kh-sm bg-kh-surface-3 px-1 py-0.5 font-kh-mono text-[0.92em] font-medium text-inherit ring-1 ring-inset ring-[color-mix(in_oklab,currentColor_28%,transparent)]\">{p}</mark>\n        ) : (\n          p\n        ),\n      )}\n    </span>\n  );\n}\n"
    }
  ]
}
