import { Button as e } from "../ui/button.js";
import { Badge as t } from "../ui/badge.js";
import { Select as n, SelectContent as r, SelectItem as i, SelectTrigger as a, SelectValue as o } from "../ui/select.js";
import { jsx as s, jsxs as c } from "react/jsx-runtime";
import { X as l } from "lucide-react";
//#region src/components/data-table/DataTableFilters.tsx
function u(e) {
	return typeof e == "string" ? e : e.value;
}
function d(e) {
	return typeof e == "string" ? e : e.label;
}
var f = ({ filters: f, filterConfig: p, onFiltersChange: m, isOpen: h }) => {
	if (!h) return null;
	let g = (e, t) => {
		let n = { ...f };
		t === "all" ? delete n[e] : n[e] = t, m?.(n);
	}, _ = () => {
		m?.({});
	}, v = Object.entries(f).filter(([e, t]) => t), y = (e, t) => {
		let n = p[e];
		if (!n) return t;
		let r = n.find((e) => u(e) === t);
		return r ? d(r) : t;
	};
	return /* @__PURE__ */ c("div", {
		className: "flex flex-wrap gap-4",
		children: [
			Object.entries(p).map(([e, t]) => /* @__PURE__ */ s("div", { children: /* @__PURE__ */ c(n, {
				value: f[e] || "all",
				onValueChange: (t) => g(e, t),
				children: [/* @__PURE__ */ s(a, { children: /* @__PURE__ */ s(o, { placeholder: `Select ${e}` }) }), /* @__PURE__ */ c(r, { children: [/* @__PURE__ */ c(i, {
					value: "all",
					children: ["All ", e]
				}), t.map((e) => /* @__PURE__ */ s(i, {
					value: u(e),
					children: d(e)
				}, u(e)))] })]
			}) }, e)),
			v.length > 0 && /* @__PURE__ */ s("div", {
				className: "flex flex-wrap gap-2",
				children: v.map(([e, n]) => /* @__PURE__ */ c(t, {
					variant: "secondary",
					className: "flex items-center gap-1",
					children: [
						e,
						": ",
						y(e, n),
						/* @__PURE__ */ s("button", {
							onClick: () => {
								g(e, "all");
							},
							children: /* @__PURE__ */ s(l, { className: "h-3 w-3 cursor-pointer" })
						})
					]
				}, e))
			}),
			v.length > 0 && /* @__PURE__ */ s(e, {
				variant: "outline",
				size: "sm",
				onClick: _,
				className: "ml-auto",
				children: "Clear All"
			})
		]
	});
};
//#endregion
export { f as default };
