import{T as j,l as q,r as A,c as i,o as c,b as s,a as u,t as r,w as k,d as B,e as m,u as n,F as C,g as F,v as V,h as D,_ as M}from"./app-B4kV47qU.js";import{_ as N}from"./SpinnerBtn-B3fjBeDL.js";import{a as O}from"./UserLayout-DG2qUs8x.js";const P={class:"flex items-center justify-between gap-x-2"},T={class:"text-slate-500 dark:text-slate-400"},z={class:"w-72 !overflow-visible"},E={class:"dropdown-list space-y-2 p-4"},I={key:0,class:"flex flex-col"},L={class:"label mb-1 capitalize"},H={value:"",disabled:"",selected:""},K=["value"],Q={key:1,class:"flex flex-col"},R={class:"label mb-1"},G={class:"flex flex-col"},J={class:"label mb-1"},W=["value","selected"],X={class:"flex items-start gap-x-2"},Y=["disabled"],se={__name:"FilterDropdown",props:{action:{type:String,required:!1,default:""},options:{type:[Array,Object],required:!1,default:[{value:"id",label:"id",selected:!0}]},title:{type:String,required:!1,default:null}},setup(f){var y,v,_,g,x,w;const p=f,b=()=>{const e={},a=new URLSearchParams(window.location.search);for(const[o,d]of a)e.hasOwnProperty(o)?Array.isArray(e[o])?e[o].push(d):e[o]=[e[o],d]:e[o]=d;return e},l=j({search:((y=b())==null?void 0:y.search)??"",type:((v=b())==null?void 0:v.type)??((g=(_=p.options)==null?void 0:_.find(e=>e.selected))==null?void 0:g.value)??((w=(x=p.options)==null?void 0:x[0])==null?void 0:w.value)??""}),U=()=>{l.get(p.action)},$=()=>{M.get(location.pathname)},h=q(()=>p.options&&l.type?p.options.find(e=>e.value==l.type):!1);return(e,a)=>{var d,S;const o=A("Icon");return c(),i("div",P,[s("h5",T,r(f.title??((S=(d=e.$page.props)==null?void 0:d.pageHeader)==null?void 0:S.title)),1),u(O,{"btn-type":"slot",btnClass:"btn bg-white font-medium shadow-sm dark:bg-slate-800 flex items-center gap-1"},{btnContent:k(()=>[u(o,{class:"text-xl",icon:"material-symbols:filter-alt-outline-sharp"}),s("span",null,r(e.trans("Search")),1),u(o,{class:"text-xl",icon:"tdesign:chevron-down"})]),default:k(()=>[s("div",z,[s("form",{onSubmit:B(U,["prevent"])},[s("ul",E,[h.value&&h.value.options?(c(),i("li",I,[s("label",L,r(n(l).type),1),m(s("select",{class:"select","onUpdate:modelValue":a[0]||(a[0]=t=>n(l).search=t)},[s("option",H,r(e.trans("Select")),1),(c(!0),i(C,null,F(h.value.options,t=>(c(),i("option",{key:t.value,value:t.value},r(t.label),9,K))),128))],512),[[V,n(l).search]])])):(c(),i("li",Q,[s("label",R,r(e.trans("Search Keyword")),1),m(s("input",{type:"text","onUpdate:modelValue":a[1]||(a[1]=t=>n(l).search=t),class:"input",placeholder:"Search keyword"},null,512),[[D,n(l).search]])])),s("li",G,[s("label",J,r(e.trans("Search Type")),1),m(s("select",{class:"select",onChange:a[2]||(a[2]=t=>n(l).reset("search")),"onUpdate:modelValue":a[3]||(a[3]=t=>n(l).type=t)},[(c(!0),i(C,null,F(f.options,t=>(c(),i("option",{key:t.value,value:t.value,selected:t.selected},r(t.label),9,W))),128))],544),[[V,n(l).type]])]),s("li",X,[u(N,{disabled:!n(l).search,type:"submit",processing:n(l).processing,"btn-text":e.trans("Search"),class:"btn btn-primary w-full",icon:"fe:search"},null,8,["disabled","processing","btn-text"]),s("button",{onClick:$,class:"btn btn-soft-danger transition-all",disabled:!b().search,title:"clear filter",type:"button"},[u(o,{icon:"bx:x",class:"size-5"})],8,Y)])])],32)])]),_:1})])}}};export{se as _};
