import { Button } from "../ui/button.js";
import { Badge } from "../ui/badge.js";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select.js";
import { c } from "react/compiler-runtime";
import { jsx, jsxs } from "react/jsx-runtime";
import { X } from "lucide-react";
var DataTableFilters_default = (m) => {
	let h = c(21), { filters: g, filterConfig: _, onFiltersChange: v, isOpen: y } = m;
	if (!y) return null;
	let b;
	h[0] !== g || h[1] !== v ? (b = (e, u) => {
		let d = { ...g };
		u === "all" ? delete d[e] : d[e] = u, v?.(d);
	}, h[0] = g, h[1] = v, h[2] = b) : b = h[2];
	let x = b, S;
	h[3] === v ? S = h[4] : (S = () => {
		v?.({});
	}, h[3] = v, h[4] = S);
	let C = S, w;
	h[5] === g ? w = h[6] : (w = Object.entries(g).filter(_temp), h[5] = g, h[6] = w);
	let T = w, E;
	h[7] !== _ || h[8] !== g || h[9] !== x ? (E = Object.entries(_).map((e) => {
		let [u, p] = e;
		return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Select, {
			value: g[u] || "all",
			onValueChange: (e) => x(u, e),
			children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: `Select ${u}` }) }), /* @__PURE__ */ jsxs(SelectContent, { children: [/* @__PURE__ */ jsxs(SelectItem, {
				value: "all",
				children: ["All ", u]
			}), p.map(_temp2)] })]
		}) }, u);
	}), h[7] = _, h[8] = g, h[9] = x, h[10] = E) : E = h[10];
	let D;
	h[11] !== T || h[12] !== x ? (D = T.length > 0 && /* @__PURE__ */ jsx("div", {
		className: "flex flex-wrap gap-2",
		children: T.map((e) => {
			let [d, f] = e;
			return /* @__PURE__ */ jsxs(Badge, {
				variant: "secondary",
				className: "flex items-center gap-1",
				children: [
					d,
					": ",
					f,
					/* @__PURE__ */ jsx("button", {
						onClick: () => {
							x(d, "all");
						},
						children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3 cursor-pointer" })
					})
				]
			}, d);
		})
	}), h[11] = T, h[12] = x, h[13] = D) : D = h[13];
	let O;
	h[14] !== T.length || h[15] !== C ? (O = T.length > 0 && /* @__PURE__ */ jsx(Button, {
		variant: "outline",
		size: "sm",
		onClick: C,
		className: "ml-auto",
		children: "Clear All"
	}), h[14] = T.length, h[15] = C, h[16] = O) : O = h[16];
	let k;
	return h[17] !== E || h[18] !== D || h[19] !== O ? (k = /* @__PURE__ */ jsxs("div", {
		className: "flex flex-wrap gap-4",
		children: [
			E,
			D,
			O
		]
	}), h[17] = E, h[18] = D, h[19] = O, h[20] = k) : k = h[20], k;
};
function _temp(e) {
	let [, u] = e;
	return u;
}
function _temp2(e) {
	return /* @__PURE__ */ jsx(SelectItem, {
		value: e,
		children: e
	}, e);
}
export { DataTableFilters_default as default };
