import{w as M,f as w,o as p,c as v,B as A,d as N,a as _,b3 as k,r as s,e as o}from"./vendor-BDR7yMJi.js";import{n as b,s as f}from"./index-BSaHX2oa.js";const B={class:"relative"},F={key:0,class:"block text-sm font-medium text-gray-700 mb-1"},R={__name:"MultiComboDynamique",props:{modelValue:{type:Array,default:()=>[]},table:{type:String,required:!0},condition1:{type:String,default:""},texteLabel:{type:String,default:""},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:""},maxLabels:{type:Number,default:2}},emits:["change","update:modelValue"],setup(a,{emit:h}){const c=h,e=a,n=s([]),r=s(!1),i=s({text:"Libelle",value:"Numéro"}),l=s([]),L=["unite","tva","depot","MoisEnLettres","Mois","situationFamiliale","MoisFiscalePeriode","devise","modep","Terminal"],u=o(()=>!L.includes(e.table)),d=o(()=>e.condition1?e.condition1:e.table==="MoisFiscalePeriode"?String(f.state.annee_fiscale):e.table==="tva"?`Annee = (SELECT ISNULL(MAX(Annee), 0) FROM tva t2 WHERE t2.Annee <= ${parseInt(f.state.annee_fiscale)||0})`:""),y=o(()=>e.placeholder?e.placeholder:e.texteLabel?`Choisir ${e.texteLabel.toLowerCase()}`:"Choisir"),g=o(()=>u.value?i.value.text:"text"),x=o(()=>u.value?i.value.value:"value"),C=async()=>{try{if(r.value=!0,u.value){const t=await b(e.table,"",d.value,9999,null,"autocomplete");n.value=t.dataSource||[],i.value=t.fields}else{const t=await b(e.table,"",d.value,9999,null,"list");Array.isArray(t)&&(n.value=t)}}catch{n.value=[]}finally{r.value=!1}},S=()=>{c("update:modelValue",l.value),c("change",l.value)};return M(()=>e.modelValue,t=>{l.value=t||[]},{immediate:!0}),w(async()=>{await C()}),(t,m)=>{const V=k;return p(),v("div",B,[a.texteLabel?(p(),v("label",F,A(a.texteLabel),1)):N("",!0),_(V,{size:"small",modelValue:l.value,"onUpdate:modelValue":m[0]||(m[0]=E=>l.value=E),options:n.value,optionLabel:g.value,optionValue:x.value,placeholder:y.value,filter:!0,showClear:!0,loading:r.value,disabled:a.disabled,maxSelectedLabels:a.maxLabels,selectedItemsLabel:"{0} sélectionnés",display:"chip",class:"w-full",onChange:S},null,8,["modelValue","options","optionLabel","optionValue","placeholder","loading","disabled","maxSelectedLabels"])])}}};export{R as _};
