{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shared-slots",
  "type": "registry:lib",
  "title": "shared/slots",
  "description": "Internal module shared by the ui-* components (slots). Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [
    "lit@^3.3.0"
  ],
  "registryDependencies": [
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/shared/slots.ts",
      "type": "registry:lib",
      "target": "components/ui/primitives/shared/slots.ts",
      "content": "import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\ntype Host = ReactiveControllerHost & Element;\n\n/**\n * Knows which named slots of the host currently have light-DOM content, so a component can\n * render the slot's wrapper only when there is something to show (Shoelace `HasSlotController`).\n * Re-renders the host when children are added, removed or re-assigned with a `slot` attribute.\n */\nexport class SlotController implements ReactiveController {\n    private readonly host: Host;\n    /** Created on connect: there is no MutationObserver when Lit renders on the server. */\n    private observer?: MutationObserver;\n\n    constructor(host: Host) {\n        this.host = host;\n        host.addController(this);\n    }\n\n    hostConnected() {\n        this.observer ??= new MutationObserver(() => this.host.requestUpdate());\n        this.observer.observe(this.host, { childList: true, attributes: true, attributeFilter: ['slot'] });\n    }\n\n    hostDisconnected() {\n        this.observer?.disconnect();\n    }\n\n    /** True when a light-DOM child is assigned to `name`. On the server the children aren't visible, so false until the client renders. */\n    has(name: string): boolean {\n        if (typeof this.host.querySelector !== 'function') return false;\n        return this.host.querySelector(`:scope > [slot=\"${name}\"]`) !== null;\n    }\n}\n"
    }
  ]
}
