{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sources-vue",
  "title": "Sources (Vue)",
  "description": "The sources a response used, as a compact count that opens a list of links.",
  "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"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/sources.ts",
      "content": "import type { Source } from \"@kind-ui/agent-ui\";\nimport { sourcesPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { Avatar, AvatarFallback, AvatarImage } from \"@ui-sdk/vue/avatar\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h, type Slot, type VNode } from \"vue\";\n\nconst parts = createParts(sourcesPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  content: \"div\",\n  list: \"ul\",\n  item: \"li\",\n  link: \"a\",\n  icon: \"span\",\n  title: \"span\",\n  host: \"span\",\n  snippet: \"p\",\n});\n\n// Slot state is a proxy that answers reads, so fallbacks read each key they need.\ntype PartState = {\n  label: string;\n  sources: Source[];\n  favicon: string | undefined;\n  title: string;\n  host: string;\n  snippet: string;\n};\n\n// A part whose default slot falls back to content built from its state.\nfunction withDefault<C extends Component>(part: C, name: string, fallback: (state: PartState) => unknown) {\n  return defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      const fill: Slot = ({ state }) => fallback(state) as VNode[];\n      return () => h(part, attrs, { ...slots, default: slots.default ?? fill });\n    },\n  }) as unknown as C;\n}\n\nexport const SourcesContent = parts.Content;\nexport const SourcesLink = parts.Link;\n\n/** Shows and hides the list. Reads the `label`, else \"Used N sources\", unless you fill the default slot. */\nexport const SourcesTrigger = withDefault(parts.Trigger, \"SourcesTrigger\", (state) => state.label);\n\n/** A UI SDK Avatar of the source's `favicon`, showing a link glyph until it loads or without one. */\nexport const SourcesIcon = withDefault(parts.Icon, \"SourcesIcon\", (state) => {\n  const favicon = state.favicon;\n  return h(Avatar, null, () => [\n    favicon ? h(AvatarImage, { src: favicon, alt: \"\" }) : null,\n    h(AvatarFallback),\n  ]);\n});\n\n/** The source's `title`, unless you fill the default slot. */\nexport const SourcesTitle = withDefault(parts.Title, \"SourcesTitle\", (state) => state.title);\n\n/** The host name of the source's `url`, unless you fill the default slot. Rendered only with a safe `url`. */\nexport const SourcesHost = withDefault(parts.Host, \"SourcesHost\", (state) => state.host);\n\n/** The source's `snippet`, unless you fill the default slot. Rendered only with a `snippet`. */\nexport const SourcesSnippet = withDefault(parts.Snippet, \"SourcesSnippet\", (state) => state.snippet);\n\n/** The source whose `id` is `value`. Without a default slot, it shows a link to it and its snippet. */\nexport const SourcesItem = withDefault(parts.Item, \"SourcesItem\", () => [\n  h(SourcesLink, null, () => [h(SourcesIcon), h(SourcesTitle), h(SourcesHost)]),\n  h(SourcesSnippet),\n]);\n\n/** An item for each of the `sources`, unless you fill the default slot. */\nexport const SourcesList = withDefault(parts.List, \"SourcesList\", (state) =>\n  state.sources.map((source) => h(SourcesItem, { key: source.id, value: source.id })),\n);\n\n/**\n * The sources a response used, as \"Used N sources\" that opens a list of links. A default slot replaces the default\n * trigger and content.\n */\nexport const Sources = withDefault(parts.Root, \"Sources\", () => [\n  h(SourcesTrigger),\n  h(SourcesContent, null, () => h(SourcesList)),\n]);\n",
      "type": "registry:ui",
      "target": "@ui/vue/sources.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
