'use client';'use strict';

var chunkIFXORR66_cjs = require('./chunk-IFXORR66.cjs');
var chunkJ5PH5EHB_cjs = require('./chunk-J5PH5EHB.cjs');
var t = require('@radix-ui/react-popover');
var icons = require('@onbeam/icons');
var css = require('@onbeam/styled-system/css');
var utils = require('@onbeam/utils');
var cmdk = require('cmdk');
var recipes = require('@onbeam/styled-system/recipes');
var react = require('react');
var jsxRuntime = require('react/jsx-runtime');

function _interopNamespace(e) {
	if (e && e.__esModule) return e;
	var n = Object.create(null);
	if (e) {
		Object.keys(e).forEach(function (k) {
			if (k !== 'default') {
				var d = Object.getOwnPropertyDescriptor(e, k);
				Object.defineProperty(n, k, d.get ? d : {
					enumerable: true,
					get: function () { return e[k]; }
				});
			}
		});
	}
	n.default = e;
	return Object.freeze(n);
}

var t__namespace = /*#__PURE__*/_interopNamespace(t);

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}=utils.useDisclosure(!1),o=recipes.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 jsxRuntime.jsxs(t__namespace.Root,{open:d,onOpenChange:O,children:[jsxRuntime.jsxs("label",{className:css.cx(o.root,P),children:[h,jsxRuntime.jsx(t__namespace.Trigger,{asChild:!0,children:jsxRuntime.jsxs("button",{ref:B,type:"button",role:"combobox","aria-controls":"combobox-list","aria-expanded":d,className:css.cx(o.button,y),"data-error":D,disabled:p,"aria-disabled":p,...k,children:[b?.image&&jsxRuntime.jsx("div",{className:o.image,children:b?.image}),jsxRuntime.jsx("span",{className:o.name,children:b?.name||T}),jsxRuntime.jsx(icons.DownIcon,{"data-open":d,"data-disabled":p,className:o.chevron})]})}),u]}),jsxRuntime.jsx(t__namespace.Content,{sideOffset:4,align:"start",side:"bottom",className:o.popover,id:"combobox-list",children:jsxRuntime.jsxs(cmdk.Command,{filter:M,shouldFilter:!l,className:css.cx(recipes.gridBackground(),recipes.noiseBackground()),children:[jsxRuntime.jsx("div",{className:o.input,"data-hidden":l,children:jsxRuntime.jsx(cmdk.Command.Input,{placeholder:R,asChild:!0,children:jsxRuntime.jsx(chunkJ5PH5EHB_cjs.a,{"aria-disabled":l,hasClearButton:!0})})}),jsxRuntime.jsxs(cmdk.Command.List,{className:o.list,children:[jsxRuntime.jsx(cmdk.Command.Empty,{className:o.emptyMessage,children:E}),i.map((e,c)=>jsxRuntime.jsxs(cmdk.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):jsxRuntime.jsxs("div",{className:o.rowContent,children:[e.image&&jsxRuntime.jsx("div",{className:o.image,children:e.image}),jsxRuntime.jsx("span",{className:o.name,children:e.name}),e.value===n&&jsxRuntime.jsx(icons.SuccessIcon,{height:16,width:16,className:o.selectedIcon})]}),c!==i.length-1&&jsxRuntime.jsx(chunkIFXORR66_cjs.a,{})]},e.value))]})]})})]})},Q=react.forwardRef(K);

exports.a = Q;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-HQ3WWZAY.cjs.map