{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "status-web",
  "title": "Status (Web Components)",
  "description": "A run status badge with a mark and a label.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/web@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/web/status.ts",
      "content": "import { stalledText, statusPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/web\";\nimport type { AttributeProperties, UiElement } from \"@ui-sdk/web/events\";\n\n// Labels this element filled in. A label someone wrote text into keeps it, as React's `StatusLabel` children do.\n// Kept across instances, because UI SDK rebuilds one when the element returns to the page.\nconst owned = new WeakSet<Element>();\n\n/**\n * `<kind-status status=\"…\">` fills in its mark, label and stalled words when it has no children, and writes the label\n * into an empty `<kind-status-label>` and \"No update for 5 min\" into an empty `<kind-status-stalled>`.\n */\nexport function defineStatus(): void {\n  if (customElements.get(\"kind-status\")) return;\n  createParts(statusPrimitive, {\n    root: {\n      tag: \"kind-status\",\n      render: (el, instance) => {\n        if (!el.firstElementChild)\n          el.innerHTML =\n            \"<kind-status-icon></kind-status-icon><kind-status-label></kind-status-label><kind-status-stalled></kind-status-stalled>\";\n        const fill = (part: Element | null, text: string) => {\n          if (!part || (!owned.has(part) && part.textContent)) return;\n          owned.add(part);\n          if (part.textContent !== text) part.textContent = text;\n        };\n        const draw = () => {\n          const { label, stalledMinutes } = instance.get();\n          fill(el.querySelector(\"kind-status-label\"), label);\n          fill(el.querySelector(\"kind-status-stalled\"), stalledText(stalledMinutes));\n        };\n        draw();\n        const unsubscribe = instance.subscribe(draw);\n        const arrivals = new MutationObserver((records) => {\n          if (records.some((record) => [...record.addedNodes].some((node) => node instanceof Element)))\n            draw();\n        });\n        arrivals.observe(el, { childList: true, subtree: true });\n        return () => {\n          unsubscribe();\n          arrivals.disconnect();\n        };\n      },\n    },\n    icon: \"kind-status-icon\",\n    label: \"kind-status-label\",\n    stalled: \"kind-status-stalled\",\n  });\n}\n\nexport interface KindStatusElement\n  extends UiElement<Record<never, never>>,\n    AttributeProperties<typeof statusPrimitive> {}\n\ndeclare global {\n  interface HTMLElementTagNameMap {\n    \"kind-status\": KindStatusElement;\n    \"kind-status-icon\": HTMLElement;\n    \"kind-status-label\": HTMLElement;\n    \"kind-status-stalled\": HTMLElement;\n  }\n}\n",
      "type": "registry:ui",
      "target": "@ui/web/status.ts"
    }
  ],
  "meta": {
    "layer": "web"
  },
  "type": "registry:ui"
}
