import{d as X,bG as Z,u as H,bC as K,bI as Q,I as U,c as g,e as d,f as h,g as O,s as W,N as Y,j as _,w as u,a7 as k,bp as D,i as B,Z as I,k as C,B as F,t as M,ai as x,aB as q,h as t,ca as A,bJ as ee,n as le,m as ae}from"./index-CYs9MVUz.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},c=new i.Error().stack;c&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[c]="a84bd1b4-262d-42cf-9b17-64ec40fc6518",i._sentryDebugIdIdentifier="sentry-dbid-a84bd1b4-262d-42cf-9b17-64ec40fc6518")}catch{}})();const te=["data-field-error"],se={class:"field__inner"},re={key:0,class:"field__labels"},oe={class:"field__caret"},ne={key:0},ie={key:1},de={class:"field__caret title-3"},ue={key:0,class:"field__description text-xs"},T=X({__name:"FormMultiselect",props:{name:{},inline:{type:Boolean},rules:{default:void 0},modelValue:{default:void 0},error:{default:""},hideLabel:{type:Boolean},inlineLabels:{type:Boolean},options:{default:()=>[]},multiple:{type:Boolean},group:{type:Boolean},search:{type:Boolean},taggable:{type:Boolean},placeholder:{},isLoadingOptions:{type:Boolean},noInternalSearch:{type:Boolean},async:{type:Boolean},iconName:{default:"expand-more"},testId:{},label:{default:"name"},trackBy:{default:"id"}},emits:["update:modelValue","search-change"],setup(i,{emit:c}){const s=Z(),{t:a}=H(),l=i,b=c,{errorMessage:m,handleChange:y,value:v,meta:j,setTouched:L}=K(l.name||Q(),l.rules,{initialValue:l.modelValue,standalone:!l.name,syncVModel:!0});U(()=>l.modelValue,e=>{y(e)});const R=g(()=>l.rules?typeof l.rules=="string"?l.rules.includes("required"):Object.keys(l.rules).includes("required"):!1),V=g(()=>l.taggable?Array.isArray(v.value)?v.value.map(e=>({[l.trackBy]:e,[l.label]:e})):[]:[]),z=g(()=>{if(l.group){const e=[];return l.options.forEach(r=>{var o;(o=r.children)==null||o.forEach(n=>e.push(n))}),e}return l.options}),f=g({get(){const e=l.modelValue||v.value||[];return l.async?Array.isArray(e)?[...e]:[e]:[...z.value,...V.value.filter(o=>!z.value.find(n=>n[l.trackBy]===o[l.trackBy]))].filter(o=>e instanceof Object&&l.trackBy in e?(e==null?void 0:e[l.trackBy])===o[l.trackBy]:e.find(n=>n instanceof Object&&(n!=null&&n[l.trackBy])?n[l.trackBy]===o[l.trackBy]:n===o[l.trackBy]))},set(e){const r=e.map(o=>o[l.trackBy]);y(r),b("update:modelValue",r)}}),G=g(()=>z.value.find(e=>e[l.trackBy]===(l.modelValue||v.value)));function $(e){L(!0),l.multiple?f.value=[...f.value,e]:(y(e[l.trackBy]),b("update:modelValue",e[l.trackBy]))}function w(e){L(!0),l.multiple?f.value=f.value.filter(r=>r[l.trackBy]!==e[l.trackBy]):(y(null),b("update:modelValue",null))}function N(e,r=0){return V.value.find(o=>o[l.trackBy]===e)?N(e,r+1):r>0?`${e}_${r}`:e}function J(e){const r={[l.trackBy]:N(e),[l.label]:e};$(r)}function P(e){return`  ${e[l.label]}`}function S(e){b("search-change",e)}return(e,r)=>{var o,n;return d(),h("div",{"data-field-error":e.error||t(m)||void 0,class:le(["field",{"field--inline":e.inline,"field--inline-labels":e.inlineLabels,"field--disabled":((o=t(s))==null?void 0:o.disabled)||((n=t(s))==null?void 0:n.disabled)===""}])},[O("div",se,[e.$slots.default||e.$slots.help?(d(),h("div",re,[W(_(D,{required:R.value},{default:u(()=>[k(e.$slots,"default",{},void 0,!0)]),_:3},8,["required"]),[[Y,!e.hideLabel]]),e.$slots.help?(d(),B(D,{key:0,class:"field__help text-xs",type:"help"},{default:u(()=>[k(e.$slots,"help",{},void 0,!0)]),_:3})):I("",!0)])):I("",!0),e.multiple?(d(),B(t(A),q({key:1},t(s),{"custom-label":P,"model-value":f.value,multiple:"","close-on-select":!1,searchable:e.search||e.taggable,taggable:e.taggable,options:e.taggable&&!e.search?V.value:e.options,label:e.label,"track-by":e.trackBy,"group-values":e.group?"children":void 0,"group-label":e.group?e.label:void 0,"group-select":!1,"limit-text":p=>t(a)("limit_text",{count:p}),"select-label":t(a)("multiselect.select_label"),"tag-placeholder":t(a)("multiselect.tag_placeholder"),"selected-label":t(a)("multiselect.selected_label"),"select-group-label":t(a)("multiselect.select_group_label"),"deselect-label":t(a)("multiselect.deselect_label"),"deselect-group-label":t(a)("multiselect.deselect_group_label"),placeholder:e.placeholder||t(a)("multiselect.placeholder"),loading:e.isLoadingOptions,"internal-search":!e.noInternalSearch,"data-testId":e.testId,onSelect:$,onRemove:w,onTag:J,onSearchChange:S}),{noOptions:u(()=>[C(" ")]),caret:u(()=>[O("div",oe,[_(F,{name:e.iconName},null,8,["name"])])]),tag:u(({option:p})=>[_(x,{"data-multiselect-tag":"","data-testid":`selected-tag-${p["track-by"]}`,class:"mr-4 whitespace-nowrap","can-remove":"right",onRemove:ce=>w(p)},{default:u(()=>[C(M(p[e.label]),1)]),_:2},1032,["data-testid","onRemove"])]),_:1},16,["model-value","searchable","taggable","options","label","track-by","group-values","group-label","limit-text","select-label","tag-placeholder","selected-label","select-group-label","deselect-label","deselect-group-label","placeholder","loading","internal-search","data-testId"])):(d(),B(t(A),q({key:2},t(s),{"model-value":G.value,options:e.options,label:e.label,"track-by":e.trackBy,searchable:e.search,taggable:!1,"group-values":e.group?"children":void 0,"group-label":e.group?e.label:void 0,"group-select":!1,"limit-text":p=>t(a)("limit_text",{count:p},p),"select-label":t(a)("multiselect.select_label"),"selected-label":t(a)("multiselect.selected_label"),"select-group-label":t(a)("multiselect.select_group_label"),"deselect-label":t(a)("multiselect.deselect_label"),"deselect-group-label":t(a)("multiselect.deselect_group_label"),placeholder:e.placeholder||t(a)("multiselect.placeholder"),loading:e.isLoadingOptions,"internal-search":!e.noInternalSearch,"data-testId":e.testId,onSelect:$,onRemove:w,onSearchChange:S}),{noOptions:u(()=>[e.$slots.noOptions?(d(),h("div",ne,[k(e.$slots,"noOptions",{},void 0,!0)])):(d(),h("div",ie," "))]),caret:u(()=>[O("div",de,[_(F,{name:e.iconName},null,8,["name"])])]),_:3},16,["model-value","options","label","track-by","searchable","group-values","group-label","limit-text","select-label","selected-label","select-group-label","deselect-label","deselect-group-label","placeholder","loading","internal-search","data-testId"]))]),e.$slots.description?(d(),h("div",ue,[k(e.$slots,"description",{},void 0,!0)])):I("",!0),e.error||t(m)&&t(j).touched?(d(),B(ee,{key:1},{default:u(()=>[C(M(e.error||t(m)),1)]),_:1})):I("",!0)],10,te)}}});function E(i){const c=i;c.__i18n=c.__i18n||[],c.__i18n.push({locale:"",resource:{fr:{limit_text:s=>{const{normalize:a,interpolate:l,named:b,plural:m}=s;return m([a(["X"]),a(["et ",l(b("count"))," autre"]),a(["et ",l(b("count"))," autres"])])},multiselect:{selected_label:s=>{const{normalize:a}=s;return a([])},select_label:s=>{const{normalize:a}=s;return a([])},select_group_label:s=>{const{normalize:a}=s;return a([])},deselect_label:s=>{const{normalize:a}=s;return a([])},deselect_group_label:s=>{const{normalize:a}=s;return a([])},tag_placeholder:s=>{const{normalize:a}=s;return a([])},placeholder:s=>{const{normalize:a}=s;return a(["Choisir une option"])}}}}})}typeof E=="function"&&E(T);const be=ae(T,[["__scopeId","data-v-2eafe1eb"]]);export{be as F};
//# sourceMappingURL=FormMultiselect-DxFWLhwj.js.map