{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "model-control-solid",
  "title": "Model Control (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/settings-menu-solid",
    "@kind-ui/internal-menu-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/model-control.tsx",
      "content": "import {\n  type MenuPartState,\n  type ModelControlOptions,\n  type ModelControlTriggerState,\n  modelControlPrimitive,\n  type SettingsMenuContentState,\n} from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { MenuTrigger } from \"@ui-sdk/solid/menu\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { createMemo, For, omit, Show } from \"solid-js\";\nimport { iconElement } from \"./internal/kind-class\";\nimport {\n  childrenOr,\n  KindMenu,\n  KindMenuContent,\n  KindMenuItemIcon,\n  menuProps,\n  menuTriggerProps,\n} 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 | JSX.Element | (() => JSX.Element);\n\n/** A model, whose `icon` is an image URL, an element such as an inline `svg`, or a function returning one. */\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?: JSX.Element;\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(props: ModelControlProps) {\n  return (\n    <parts.Root {...omit(props, \"children\")}>\n      {(menu: MenuPartState) => (\n        <KindMenu {...menuProps(menu)}>{props.children ?? <DefaultParts />}</KindMenu>\n      )}\n    </parts.Root>\n  );\n}\n\nfunction TriggerContent(props: { state: ModelControlTriggerState }) {\n  const icon = createMemo(() => props.state.model.icon);\n  return (\n    <>\n      <Show when={icon() !== undefined}>\n        <KindMenuItemIcon>\n          {typeof icon() === \"string\" ? <img src={icon() as string} alt=\"\" /> : iconElement(icon())}\n        </KindMenuItemIcon>\n      </Show>\n      <span data-model-control-model=\"\">{props.state.model.label}</span>\n      <Show when={props.state.effort}>\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              <For each={effort().options} keyed={(option) => option.value}>\n                {(option) => (\n                  <span data-current={option().value === effort().value ? \"\" : undefined}>\n                    {option().label}\n                  </span>\n                )}\n              </For>\n            </span>\n          </>\n        )}\n      </Show>\n      <span data-menu-chevron=\"\" />\n    </>\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?: JSX.Element | ((state: ModelControlTriggerState) => JSX.Element);\n};\n\n/** Opens the menu: UI SDK's `MenuTrigger`, named by the `label`, the model and the effort. */\nexport function ModelControlTrigger(props: ModelControlTriggerProps) {\n  return (\n    <parts.Trigger>\n      {(state: ModelControlTriggerState) => (\n        // Hidden from agents, which use the Model Control's own actions.\n        <MenuTrigger {...menuTriggerProps(state)} data-agent-hidden=\"\" {...omit(props, \"children\")}>\n          {childrenOr(props.children, state, () => (\n            <TriggerContent state={state} />\n          ))}\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?: JSX.Element | ((state: SettingsMenuContentState) => JSX.Element);\n};\n\n/** The menu: UI SDK's `MenuContent` holding the rows unless you pass children. Props go to it. */\nexport function ModelControlContent(props: ModelControlContentProps) {\n  return (\n    <parts.Content>\n      {(state: SettingsMenuContentState) => (\n        <KindMenuContent align=\"start\" sideOffset={6} {...omit(props, \"children\")}>\n          {childrenOr(props.children, state, () => (\n            <SettingsMenuRows rows={state.rows} />\n          ))}\n        </KindMenuContent>\n      )}\n    </parts.Content>\n  );\n}\n\nconst DefaultParts = () => (\n  <>\n    <ModelControlTrigger />\n    <ModelControlContent />\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/solid/model-control.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
