import{an as N,u as O,a as d,y as v,o as W,j as h,e as b,f as o,w as t,q as g,aN as k,aO as B,n as w,b as I,H as P,aa as y,l as m,t as V,aG as Q,g as x,a8 as j}from"./index-OSKNspXo.js";const R={__name:"deenovaWardSelector",props:{modelValue:{type:[Object,null],default:null},label:{type:String,default:"ui.selectbox.wards.label"},mustSelect:{type:Boolean,default:!1},preselection:{type:[String,null],default:null}},emits:["update:modelValue"],setup(i,{emit:S}){const r=i,_=N(),q=S,{t:p}=O(),s=d(r.modelValue),n=d([]),u=d([]),c=d(!1);v(s,e=>{q("update:modelValue",e)}),v(()=>r.modelValue,e=>{s.value=e});const C=async()=>{c.value=!0;try{const e=await _.send("get","services","",null,{});e.data&&(n.value=e.data,u.value=[...n.value])}catch(e){console.error("Error fetching wards:",e)}finally{c.value=!1}},L=(e,l)=>{if(e===""){l(()=>{u.value=n.value});return}l(()=>{const a=e.toLowerCase();u.value=n.value.filter(f=>f.name.toLowerCase().indexOf(a)>-1||f.id.toLowerCase().indexOf(a)>-1||f.code_et_name.toLowerCase().indexOf(a)>-1)})};return W(()=>{C().then(()=>{if(r.preselection){const e=n.value.find(l=>l.id===r.preselection);e&&(s.value=e)}})}),(e,l)=>(b(),h("div",null,[o(j,Q({modelValue:s.value,"onUpdate:modelValue":l[0]||(l[0]=a=>s.value=a),options:u.value,"option-label":"name","option-value":"id","input-debounce":"300",label:x(p)(i.label),"use-input":"","hide-selected":"","fill-input":"",loading:c.value,onFilter:L,clearable:"",class:"q-px-md q-mb-lg"},e.$attrs,{rules:i.mustSelect?[a=>!!a||x(p)("ui.selectbox.wards.required")]:[]}),{"no-option":t(()=>[o(g,null,{default:t(()=>[o(w,{class:"text-grey"},{default:t(()=>l[1]||(l[1]=[m(" No results found ")])),_:1})]),_:1})]),option:t(a=>[o(g,k(B(a.itemProps)),{default:t(()=>[o(w,null,{default:t(()=>[o(y,null,{default:t(()=>[m(V(a.opt.code_et_name),1)]),_:2},1024),a.opt.cle?(b(),I(y,{key:0,caption:""},{default:t(()=>[m(" Address: "+V(a.opt.cle),1)]),_:2},1024)):P("",!0)]),_:2},1024)]),_:2},1040)]),_:1},16,["modelValue","options","label","loading","rules"])]))}};export{R as _};
//# sourceMappingURL=deenovaWardSelector-3Q2kFL-4.js.map
