var z=Object.defineProperty,A=Object.defineProperties;var I=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var v=(t,r,a)=>r in t?z(t,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[r]=a,c=(t,r)=>{for(var a in r||(r={}))O.call(r,a)&&v(t,a,r[a]);if(g)for(var a of g(r))P.call(r,a)&&v(t,a,r[a]);return t},o=(t,r)=>A(t,I(r));import{q as j,r as u,j as e,B as h,Z as f,I as $,_ as E,$ as F,a0 as S,a1 as M}from"./index-C7Y5J1TO.js";import{L as q}from"./label-CbvzEgFe.js";import{P as B,a as G,b as C}from"./popover-CtxAPxyq.js";/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const H=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],R=j("check",H);/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const X=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Z=j("funnel",X);/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],N=j("x",D);function V({filtersConfig:t,onFilterApply:r,onFilterClear:a,initialFilters:m={}}){const[i,d]=u.useState(()=>{const s=t.reduce((l,n)=>o(c({},l),{[n.key]:""}),{});return c(c({},s),m)}),[y,x]=u.useState(!1);u.useEffect(()=>{d(s=>c(c({},s),m))},[m]);function b(s){const{id:l,value:n}=s.target;d(T=>o(c({},T),{[l]:n}))}function k(){r(i),x(!1)}function w(){const s=t.reduce((l,n)=>o(c({},l),{[n.key]:""}),{});d(s),a==null||a(),x(!1)}function L(){const s=t.reduce((l,n)=>o(c({},l),{[n.key]:""}),{});d(s),a==null||a()}const p=Object.values(i).some(s=>s!==""),_=Object.values(i).filter(s=>s!=="").length;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(B,{open:y,onOpenChange:x,children:[e.jsx(G,{asChild:!0,children:e.jsxs(h,{size:"sm",variant:"outline",className:`flex items-center gap-2 px-4 ${p?"border-primary text-primary":""}`,children:[e.jsx(Z,{className:"h-4 w-4"}),p?"Filtros aplicados":"Filtros",p&&e.jsx("span",{className:"bg-primary text-primary-foreground ml-1 rounded-full px-2 py-0.5 text-xs",children:_})]})}),e.jsx(C,{className:"w-96",align:"start",side:"bottom",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"Selecciona la opción por la cual deseas filtrar"})}),e.jsx(f,{}),e.jsx("div",{className:"grid gap-4",children:t.map(s=>e.jsxs("div",{className:"grid gap-2",children:[e.jsx(q,{htmlFor:s.key,children:s.label}),e.jsx($,{id:s.key,value:i[s.key]||"",placeholder:`Filtrar por ${s.label.toLowerCase()}`,className:"h-8",onChange:b})]},s.key))}),e.jsx(f,{}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(h,{size:"sm",variant:"ghost",className:"bg-neutral-100 hover:bg-neutral-200",onClick:w,children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),"Limpiar filtros"]}),e.jsxs(h,{size:"sm",onClick:k,children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),"Aplicar filtros"]})]})]})})]}),p&&e.jsx(E,{children:e.jsxs(F,{children:[e.jsx(S,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"ghost",className:"h-6 w-6 rounded-full border border-neutral-200 bg-neutral-100 p-0 hover:bg-neutral-200",onClick:L,children:e.jsx(N,{className:"h-3 w-3 text-neutral-600"})})}),e.jsx(M,{children:e.jsx("p",{children:"Limpiar todos los filtros"})})]})})]})}export{V as G,N as X};
