import{w as c,T as U}from"./vendor-vue-runtime-dom-B2rky8vu.js";import{A as W,_ as h}from"./settings.consts-C6F6lZ8o.js";import{u as X}from"./admin-BM775jCq.js";import{d as Y,e as d,w as Z,f as o,i as a,F as b,t as v,x as n,j as x,k as ee,r as M,m as te}from"./vendor-vue-runtime-core-DwK6Ry68.js";import{t as le,r as A,u as k}from"./vendor-vue-reactivity-CheHbvBM.js";import{a as _,t as N}from"./vendor-vue-shared-DrzsEcag.js";const se={key:0,class:"ccb-total-multiselect__required"},ae={key:0},oe={class:"ccb-total-multiselect-chip__text"},ne=["onClick"],ie=["checked","disabled","onChange"],ue={class:"ccb-total-multiselect-option__box"},ce={key:0,class:"ccb-total-multiselect-option__checkmark"},re={class:"ccb-total-multiselect-option__label"},ke=Y({__name:"MultiSelect",props:{modelValue:{},label:{},items:{},name:{},required:{type:Boolean},placeholder:{},className:{},maxItemsShown:{},maxItemsSelected:{}},emits:["update:modelValue","change"],setup($,{emit:z}){const D=$,y=z,{items:p,modelValue:q,label:w,required:O,placeholder:F,name:L,className:j,maxItemsShown:C,maxItemsSelected:r}=le(D),E=X(),u=A(!1),s=A([]),R=d(()=>typeof C.value>"u"?(p.value||[]).length:C.value),G=d(()=>(p.value||[]).map(t=>({label:t.title||t.label||"",value:t.alias||t.value}))),g=t=>W(t,E.getTranslations),H=d(()=>g(w.value||"")),S=t=>t.alias||t.value,J=d(()=>`${s.value.length} ${g("option(s) selected")}`),K=d(()=>{const t=new Set(s.value);return(p.value||[]).filter(e=>t.has(S(e)))}),V=()=>{y("update:modelValue",[...s.value]),y("change",L.value||"",[...s.value])},P=t=>{s.value=s.value.filter(e=>String(e)!==String(t)),V()},I=()=>{u.value=!u.value},f=t=>s.value.some(e=>e===t),T=d(()=>typeof r.value>"u"?!1:s.value.length>=r.value),B=t=>typeof r.value>"u"||f(t)?!1:T.value,Q=(t,e)=>{const l=t.target;if(l.checked){if(f(e))return;if(T.value){l.checked=!1;return}s.value=[...s.value,e]}else s.value=s.value.filter(m=>m!==e);V()};return Z(()=>q.value,t=>{const e=Array.isArray(t)?t:[],l=new Set((p.value||[]).map(m=>m.alias||m.value));let i=e.filter(m=>l.has(m));typeof r.value<"u"&&i.length>r.value&&(i=i.slice(0,r.value)),s.value=i},{immediate:!0,deep:!0}),(t,e)=>(a(),o(b,null,[u.value?(a(),o("div",{key:0,class:"multiselect-overlay",onClick:e[0]||(e[0]=l=>u.value=!1)})):v("",!0),n("div",{class:_(["ccb-total-multiselect",{[k(j)||""]:!0,"ccb-multiselect-active":u.value}])},[k(w)?(a(),o("div",{key:0,class:"ccb-total-multiselect__label",onClick:I},[x(h,{text:H.value,size:"s",weight:"regular"},null,8,["text"]),k(O)?(a(),o("span",se,"*")):v("",!0)])):v("",!0),n("div",{class:"ccb-total-multiselect-input",onClick:I},[n("div",{class:_(["ccb-total-multiselect-input__chips",{"is-empty":s.value.length===0}])},[s.value.length?(a(),o(b,{key:0},[s.value.length>R.value?(a(),o("div",ae,[x(h,{text:J.value,size:"m",weight:"medium"},null,8,["text"])])):(a(!0),o(b,{key:1},M(K.value,l=>(a(),o("div",{key:l.alias,class:"ccb-total-multiselect-chip",onClick:e[1]||(e[1]=c(()=>{},["stop"]))},[e[8]||(e[8]=n("i",{class:"ccb-icon-ic_calculator"},null,-1)),n("span",oe,N(l.title||l.label||""),1),n("button",{type:"button",class:"ccb-total-multiselect-chip__remove",onClick:i=>P(S(l))},null,8,ne)]))),128))],64)):(a(),ee(h,{key:1,text:k(F)||"",size:"m",weight:"medium"},null,8,["text"]))],2),n("span",{class:_(["ccb-total-multiselect-input__icon",{"is-open":u.value}])},e[9]||(e[9]=[n("i",{class:"ccb-icon-ic_caret_down"},null,-1)]),2),x(U,{name:"dropdown"},{default:te(()=>[u.value?(a(),o("div",{key:0,class:"ccb-total-multiselect-options",onClick:e[6]||(e[6]=c(()=>{},["stop"])),onMousedown:e[7]||(e[7]=c(()=>{},["stop"]))},[n("div",{class:"ccb-total-multiselect-options__list",onClick:e[4]||(e[4]=c(()=>{},["stop"])),onMousedown:e[5]||(e[5]=c(()=>{},["stop"]))},[(a(!0),o(b,null,M(G.value,l=>(a(),o("label",{key:String(l.value),class:_(["ccb-total-multiselect-option",{"ccb-total-multiselect-option--disabled":B(l.value)}]),onClick:e[2]||(e[2]=c(()=>{},["stop"])),onMousedown:e[3]||(e[3]=c(()=>{},["stop"]))},[n("input",{type:"checkbox",class:"ccb-total-multiselect-option__input",checked:f(l.value),disabled:B(l.value),onChange:i=>Q(i,l.value)},null,40,ie),n("span",ue,[f(l.value)?(a(),o("span",ce)):v("",!0)]),n("span",re,N(g(l.label)),1)],34))),128))],32)],32)):v("",!0)]),_:1})])],2)],64))}});export{ke as _};
//# sourceMappingURL=MultiSelect.vue_vue_type_script_setup_true_lang-yDnKxHFg.js.map
