{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "model-control",
  "title": "Model Control",
  "description": "A button showing the model and its effort, opening a settings menu with Model and Effort submenus.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/settings-menu",
    "@kind-ui/internal-menu"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/model-control.tsx",
      "content": "\"use client\";\n\nimport {\n  type ModelControlOptions,\n  type ModelControlTriggerState,\n  modelControlPrimitive,\n  type SettingsMenuContentState,\n} from \"@kind-ui/agent-ui/core\";\nimport { MenuTrigger } from \"@ui-sdk/react/menu\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport type { ComponentProps, ReactElement, ReactNode } from \"react\";\nimport { KindMenu, KindMenuContent, KindMenuItemIcon } from \"./internal/menu\";\nimport { SettingsMenuRows, type SettingsMenuSetting } from \"./settings-menu\";\n\nconst parts = createParts(modelControlPrimitive, { root: \"div\", trigger: \"span\", content: \"div\" });\n\ntype Icon = string | ReactElement;\n\n/** A model, whose `icon` is an image URL or an element such as an inline `svg`. */\nexport type ModelControlModel = Omit<NonNullable<ModelControlOptions[\"models\"]>[number], \"icon\"> & {\n  icon?: Icon;\n};\n\nexport type ModelControlProps = Omit<\n  ComponentProps<typeof parts.Root>,\n  \"children\" | \"models\" | \"actions\" | \"settings\"\n> & {\n  models?: ModelControlModel[];\n  /** Items after the models, like \"More models\". */\n  actions?: (Omit<NonNullable<ModelControlOptions[\"actions\"]>[number], \"icon\"> & { icon?: Icon })[];\n  /** More rows after Model and Effort: choices, then toggles. */\n  settings?: SettingsMenuSetting[];\n  children?: ReactNode;\n};\n\n/**\n * One button for the model and its effort, reading \"GPT-5 · High\", that opens one menu: the models, grouped with\n * their icons, then the effort levels the model supports, then your own choices and toggles. Any `children` replace\n * the trigger and the content, inside UI SDK Menu.\n */\nexport function ModelControl({ children = DEFAULT_PARTS, ...props }: ModelControlProps) {\n  return <parts.Root {...props}>{(menu) => <KindMenu {...menu}>{children}</KindMenu>}</parts.Root>;\n}\n\nconst triggerContent = ({ model, effort }: ModelControlTriggerState) => (\n  <>\n    {model.icon !== undefined ? (\n      <KindMenuItemIcon>\n        {typeof model.icon === \"string\" ? <img src={model.icon} alt=\"\" /> : (model.icon as ReactElement)}\n      </KindMenuItemIcon>\n    ) : null}\n    <span data-model-control-model=\"\">{model.label}</span>\n    {effort ? (\n      <>\n        {/* Spaces around the \"·\", so the accessible name reads \"GPT-5 · High\"; the trigger's gap spaces it on screen. */}{\" \"}\n        <span data-model-control-separator=\"\">·</span>{\" \"}\n        {/* Every level's label shares one cell and only the chosen one shows, so the trigger keeps its width. */}\n        <span data-model-control-effort=\"\">\n          {effort.options.map((option) => (\n            <span key={option.value} data-current={option.value === effort.value ? \"\" : undefined}>\n              {option.label}\n            </span>\n          ))}\n        </span>\n      </>\n    ) : null}\n    <span data-menu-chevron=\"\" />\n  </>\n);\n\nexport type ModelControlTriggerProps = Omit<ComponentProps<typeof MenuTrigger>, \"children\"> & {\n  /** What the button shows: the model's icon and name, then its effort, by default. */\n  children?: ReactNode | ((state: ModelControlTriggerState) => ReactNode);\n};\n\n/** Opens the menu: UI SDK's `MenuTrigger`, named by the `label`, the model and the effort. */\nexport function ModelControlTrigger({ children = triggerContent, ...props }: ModelControlTriggerProps) {\n  return (\n    <parts.Trigger>\n      {({ model, effort, ...trigger }) => (\n        // Hidden from agents, which use the Model Control's own actions.\n        <MenuTrigger {...trigger} data-agent-hidden=\"\" {...props}>\n          {typeof children === \"function\" ? children({ model, effort, ...trigger }) : children}\n        </MenuTrigger>\n      )}\n    </parts.Trigger>\n  );\n}\n\nexport type ModelControlContentProps = Omit<ComponentProps<typeof KindMenuContent>, \"children\"> & {\n  /** What the menu holds, or a function of its rows: the rows by default. */\n  children?: ReactNode | ((state: SettingsMenuContentState) => ReactNode);\n};\n\n/** The menu: UI SDK's `MenuContent` holding the rows unless you pass children. Props go to it. */\nexport function ModelControlContent({ children = DEFAULT_ROWS, ...props }: ModelControlContentProps) {\n  return (\n    <parts.Content>\n      {(state) => (\n        <KindMenuContent align=\"start\" sideOffset={6} {...props}>\n          {typeof children === \"function\" ? children(state) : children}\n        </KindMenuContent>\n      )}\n    </parts.Content>\n  );\n}\n\nconst DEFAULT_ROWS = ({ rows }: SettingsMenuContentState) => <SettingsMenuRows rows={rows} />;\n\n// Shared, so an update doesn't render the default parts' wrappers again.\nconst DEFAULT_PARTS = (\n  <>\n    <ModelControlTrigger />\n    <ModelControlContent />\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/model-control.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
