require("./chunk-9hOWP6kD.cjs");
const require_src = require("./src-Cx7UyT_c.cjs");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
let lucide_react = require("lucide-react");
//#region ../../platform/ui-components/src/components/Combobox.tsx
function Combobox({ options, value, onValueChange, placeholder = "Select...", emptyText = "No results found.", disabled = false }) {
	const [open, setOpen] = (0, react.useState)(false);
	const [search, setSearch] = (0, react.useState)("");
	const selectedOption = options.find((opt) => opt.value === value);
	const filtered = search ? options.filter((opt) => opt.label.toLowerCase().includes(search.toLowerCase())) : options;
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Command, {
		className: "overflow-visible bg-transparent",
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.Popover, {
			open,
			onOpenChange: setOpen,
			modal: true,
			children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.PopoverAnchor, {
				asChild: true,
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
					className: require_src.cn("border-input flex h-9 w-full items-center rounded-md border bg-transparent shadow-xs transition-[color,box-shadow]", open && "border-ring ring-ring/50 ring-[3px]", disabled && "cursor-not-allowed opacity-50"),
					children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
						role: "combobox",
						"aria-expanded": open,
						disabled,
						placeholder: selectedOption ? selectedOption.label : placeholder,
						value: open ? search : "",
						className: require_src.cn("placeholder:text-foreground h-full w-full rounded-md bg-transparent px-3 text-sm outline-none disabled:cursor-not-allowed", !open && !selectedOption && "placeholder:text-muted-foreground"),
						onChange: (e) => {
							setSearch(e.target.value);
							if (!open) setOpen(true);
						},
						onClick: () => setOpen(true),
						onKeyDown: (e) => {
							if (e.key === "Escape") {
								setOpen(false);
								setSearch("");
							}
						}
					}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, { className: "mr-2 size-4 shrink-0 opacity-50" })]
				})
			}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.PopoverContent, {
				className: "bg-popover w-[var(--radix-popover-trigger-width)] rounded-md border p-0 shadow-md",
				align: "start",
				onOpenAutoFocus: (e) => e.preventDefault(),
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.CommandList, { children: [filtered.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.CommandEmpty, { children: emptyText }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.CommandGroup, { children: filtered.map((opt) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.CommandItem, {
					value: opt.label,
					onSelect: () => {
						onValueChange(opt.value === value ? "" : opt.value);
						setOpen(false);
						setSearch("");
					},
					children: [opt.label, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, { className: require_src.cn("ml-auto size-4", value === opt.value ? "opacity-100" : "opacity-0") })]
				}, opt.value)) })] })
			})]
		})
	});
}
//#endregion
Object.defineProperty(exports, "Combobox", {
	enumerable: true,
	get: function() {
		return Combobox;
	}
});

//# sourceMappingURL=Combobox-BqqGQkac.cjs.map