import{_ as S}from"./Brk5FU9k.js";import j from"./iZ-xiGRB.js";import{h as R}from"./CH1bAkoS.js";import{d as U,$ as _,j as d,L as x,k as P,b as k,w as B,G as O,g as V,o as C,a2 as i,e as l,a7 as A,a8 as T,f as p,n as E}from"./dVzHJMF1.js";import{b as h,m as L}from"./DaykkcNl.js";import{u as N}from"./D2P12BLM.js";import{u as q}from"./DTJCrQga.js";const z={class:"col-span-12 flex flex-wrap justify-between gap-2"},D={class:"flex flex-wrap justify-start gap-2"},G={class:"flex flex-wrap justify-end gap-2"},I=U({__name:"FilterForm",props:{schema:{},initialValues:{default:()=>{}},status:{default:()=>{}},partial:{type:Boolean,default:!0},classForm:{default:()=>{}},paginatedUrl:{type:Boolean,default:!1},defaultFilters:{default:()=>{}}},emits:["change"],setup(o,{emit:g}){const c=_(),F=g,f=d(o.paginatedUrl?void 0:{...o.initialValues,...h(o.schema)}),r=x("formRef");N(r),q(r,f);const y=d(R(o.partial?L(o.schema):o.schema));function b(e){if(!e.valid)return;const a=w(e.values);v(a),F("change",a)}function v(e){const a=u(c.query),t=u(e);a.toString()===t.toString()&&t.append("_refresh",new Date().getTime().toString()),E(window.location.pathname+"?"+t.toString(),{replace:!0})}function u(e){const a=new URLSearchParams;return Object.entries(e).forEach(([t,s])=>{s!=null&&(Array.isArray(s)?s.forEach(n=>{n!=null&&a.append(t,String(n))}):a.append(t,String(s)))}),a}function w(e){return Object.fromEntries(Object.entries(e).filter(([a,t])=>t!=null&&t!==""&&!(Array.isArray(t)&&t.length===0)))}function m(e){var a,t;for(const s of Object.keys(e)){const n=e[s];n&&typeof n=="object"&&n.hasOwnProperty("value")&&(e[s].value=(a=o.defaultFilters)!=null&&a[s]?(t=o.defaultFilters)==null?void 0:t[s]:null)}}return P(()=>c.query,()=>{o.paginatedUrl&&(f.value=h(o.schema))},{immediate:!0}),(e,a)=>{const t=S,s=j;return C(),k(s,{ref_key:"formRef",ref:r,resolver:V(y),class:O(["flex flex-col gap-5 mb-5",e.classForm]),onSubmit:b},{default:B(n=>[i(e.$slots,"default",A(T(n))),l("div",z,[l("div",D,[i(e.$slots,"left-actions")]),l("div",G,[i(e.$slots,"actions",{clearFilters:()=>m(n)},()=>[p(t,{mode:"clean",onClick:$=>m(n)},null,8,["onClick"]),p(t,{mode:"search",type:"submit",loading:e.status==="pending"},null,8,["loading"])])])])]),_:3},8,["resolver","class"])}}}),Y=Object.assign(I,{__name:"UiFilterForm"});export{Y as _};
