{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "code-block-vue",
  "title": "Code Block (Vue)",
  "description": "A code block with its language, a wrap toggle and a copy button.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-scroll-area-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/code-block.ts",
      "content": "import { codeBlockPrimitive, type Token } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { defineComponent, h } from \"vue\";\nimport {\n  KindScrollArea,\n  KindScrollAreaContent,\n  KindScrollAreaScrollbar,\n  KindScrollAreaThumb,\n  KindScrollAreaViewport,\n} from \"./internal/scroll-area\";\n\nconst parts = createParts(codeBlockPrimitive, {\n  root: \"div\",\n  header: \"div\",\n  language: \"span\",\n  wrap: \"button\",\n  copy: \"button\",\n  code: \"pre\",\n});\n\nconst tokenStyle = (token: Token) => (token.color ? { \"--kind-code-block-token\": token.color } : undefined);\n\nconst code = () =>\n  h(parts.Code, null, {\n    default: ({ state }: { state: { lines: Token[][] } }) =>\n      h(\n        \"code\",\n        state.lines.map((line, index) =>\n          h(\n            \"span\",\n            { key: index, \"data-line\": \"\" },\n            line.map((token, at) =>\n              h(\n                \"span\",\n                { key: at, \"data-font-style\": token.fontStyle, style: tokenStyle(token) },\n                token.content,\n              ),\n            ),\n          ),\n        ),\n      ),\n  });\n\nconst scrollContent = () => [\n  h(KindScrollAreaViewport, null, () => h(KindScrollAreaContent, null, code)),\n  h(KindScrollAreaScrollbar, { orientation: \"horizontal\" }, () => h(KindScrollAreaThumb)),\n  h(KindScrollAreaScrollbar, { orientation: \"vertical\" }, () => h(KindScrollAreaThumb)),\n];\n\n/** A code block with its language, a wrap toggle and a copy button. Name it with `aria-label`. */\nexport const CodeBlock = defineComponent({\n  name: \"CodeBlock\",\n  inheritAttrs: false,\n  props: {\n    /** Shows the language, the wrap toggle and the copy button. */\n    header: { type: Boolean, default: true },\n    streaming: { type: Boolean, default: undefined },\n  },\n  setup(props, { attrs, slots }) {\n    return () =>\n      h(\n        parts.Root,\n        { ...attrs, streaming: props.streaming },\n        {\n          ...slots,\n          default: () => [\n            props.header &&\n              h(parts.Header, null, () => [\n                h(parts.Language, null, {\n                  default: ({ state }: { state: { language: string | undefined } }) => state.language,\n                }),\n                h(parts.Wrap),\n                h(parts.Copy),\n              ]),\n            h(KindScrollArea, { stickToEnd: props.streaming ?? false }, scrollContent),\n          ],\n        },\n      );\n  },\n});\n",
      "type": "registry:ui",
      "target": "@ui/vue/code-block.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
