"use client"
import{c as x}from"./chunk-IAZL6GWB.mjs";import{a as f}from"./chunk-F3BOX7XC.mjs";import{f as u,k as b}from"./chunk-NMLCUCWV.mjs";import{AnimatePresence as C,motion as h}from"framer-motion";import{X as L}from"lucide-react";import{isValidElement as A}from"react";import{Fragment as O,jsx as t,jsxs as i}from"react/jsx-runtime";function K({filters:p,activeFilters:a,onRemove:v,onRemoveAll:l,className:N}){return x("Escape",l,{priority:1}),t(f,{height:!0,className:"w-full",transition:{type:"tween",duration:.3},children:i("div",{className:b("flex w-full flex-wrap items-start gap-4 sm:flex-nowrap",N),children:[t("div",{className:"flex grow flex-wrap gap-x-4 gap-y-2",children:t(C,{children:a==null?void 0:a.map(({key:n,value:s})=>{if(n==="loader")return t(h.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},className:"h-9 w-48 animate-pulse rounded-md border border-gray-200 bg-white"},`loader-${s}`);let e=p.find(r=>r.key===n);if(!e)throw new Error("Filter.List received an activeFilter without a corresponding filter");return(e.multiple&&Array.isArray(s)?s:[s]).map(r=>{var c,y,g;let o=(c=e.options)==null?void 0:c.find(d=>typeof d.value=="string"&&typeof r=="string"?d.value.toLowerCase()===r.toLowerCase():d.value===r),m=(o==null?void 0:o.icon)??((y=e.getOptionIcon)==null?void 0:y.call(e,r,{key:e.key,option:o}))??e.icon,k=(o==null?void 0:o.label)??((g=e.getOptionLabel)==null?void 0:g.call(e,r,{key:e.key,option:o}))??r;return i(h.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},className:"flex items-center divide-x rounded-md border border-gray-200 bg-white text-sm text-black",children:[i("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[t("span",{className:"shrink-0 text-gray-600",children:w(e.icon)?e.icon:t(e.icon,{className:"h-4 w-4"})}),e.label]}),t("div",{className:"px-3 py-2 text-gray-500",children:"is"}),t("div",{className:"flex items-center gap-2.5 px-3 py-2",children:e.options?i(O,{children:[t("span",{className:"shrink-0 text-gray-600",children:w(m)?m:t(m,{className:"h-4 w-4"})}),u(k,30)]}):t("div",{className:"h-5 w-12 animate-pulse rounded-md bg-gray-200"})}),t("button",{type:"button",className:"h-full rounded-r-md p-2 text-gray-500 ring-inset ring-gray-500 hover:bg-gray-100 hover:text-gray-800 focus:outline-none focus-visible:ring-1",onClick:()=>v(n,r),children:t(L,{className:"h-3.5 w-3.5"})})]},n)})})})}),(a==null?void 0:a.length)!==0&&i("button",{type:"button",className:"group mt-px flex items-center gap-2 whitespace-nowrap rounded-lg border border-transparent px-3 py-2 text-sm text-gray-500 ring-inset ring-gray-500 transition-colors hover:border-gray-200 hover:bg-white hover:text-black focus:outline-none",onClick:l,children:["Clear Filters",t("kbd",{className:"rounded-md border border-gray-200 px-1.5 py-0.5 text-xs text-gray-950 group-hover:bg-gray-50",children:"ESC"})]})]})})}var w=p=>A(p);export{K as a};
