'use client';import { a as a$1 } from './chunk-37TUZSO4.js';
import { a } from './chunk-B746ACGT.js';
import * as t from '@radix-ui/react-popover';
import { DownIcon, SuccessIcon } from '@onbeam/icons';
import { cx } from '@onbeam/styled-system/css';
import { useDisclosure } from '@onbeam/utils';
import { Command } from 'cmdk';
import { combobox, gridBackground, noiseBackground } from '@onbeam/styled-system/recipes';
import { forwardRef } from 'react';
import { jsxs, jsx } from 'react/jsx-runtime';

var K=({label:h,hasError:I=!1,errorMessage:u,className:P,inputClassName:y,value:n,onChange:w,placeholder:T,searchPlaceholder:R,items:i,emptyMessage:E,disabled:p,disableSearch:l,searchKeys:L=["name","value"],renderItem:v,...k},B)=>{let{isOpen:d,onClose:F,setOpen:O}=useDisclosure(!1),o=combobox(),b=i.find(e=>e.value===n),D=!!u||I,M=(e,c)=>{let r=i.find(f=>f.value===e);if(!r)return 0;let x=!1;for(let f of L)r[f]?.toString().toLowerCase().includes(c.toLowerCase())&&(x=!0);return Number(x)};return jsxs(t.Root,{open:d,onOpenChange:O,children:[jsxs("label",{className:cx(o.root,P),children:[h,jsx(t.Trigger,{asChild:!0,children:jsxs("button",{ref:B,type:"button",role:"combobox","aria-controls":"combobox-list","aria-expanded":d,className:cx(o.button,y),"data-error":D,disabled:p,"aria-disabled":p,...k,children:[b?.image&&jsx("div",{className:o.image,children:b?.image}),jsx("span",{className:o.name,children:b?.name||T}),jsx(DownIcon,{"data-open":d,"data-disabled":p,className:o.chevron})]})}),u]}),jsx(t.Content,{sideOffset:4,align:"start",side:"bottom",className:o.popover,id:"combobox-list",children:jsxs(Command,{filter:M,shouldFilter:!l,className:cx(gridBackground(),noiseBackground()),children:[jsx("div",{className:o.input,"data-hidden":l,children:jsx(Command.Input,{placeholder:R,asChild:!0,children:jsx(a,{"aria-disabled":l,hasClearButton:!0})})}),jsxs(Command.List,{className:o.list,children:[jsx(Command.Empty,{className:o.emptyMessage,children:E}),i.map((e,c)=>jsxs(Command.Item,{className:o.row,value:e.value,onSelect:r=>{w?.(r===n?"":r),F();},disabled:e.disabled,children:[v?v(e,e.value===n):jsxs("div",{className:o.rowContent,children:[e.image&&jsx("div",{className:o.image,children:e.image}),jsx("span",{className:o.name,children:e.name}),e.value===n&&jsx(SuccessIcon,{height:16,width:16,className:o.selectedIcon})]}),c!==i.length-1&&jsx(a$1,{})]},e.value))]})]})})]})},Q=forwardRef(K);

export { Q as a };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-MM2K6JZB.js.map