import{u as F}from"./useOrderFormDropdown-CHNt9hBN.js";import{l as N}from"./fieldsStore-CQRN0FvQ.js";import{u as M}from"./translationsStore-D6vLzgNA.js";import{d as A,e as w,a as O,f as i,i as u,x as l,t as p,F as y,r as x,z as W}from"./vendor-vue-runtime-core-DwK6Ry68.js";import{t as z,r as E,u as s}from"./vendor-vue-reactivity-CheHbvBM.js";import{t as m}from"./vendor-vue-shared-DrzsEcag.js";import"./vendor-pinia-BSPefQhS.js";import"./settingsStore-8bwiLMEn.js";import"./convert-case-to-camel-case.utils-CK5dBN7n.js";import"./appStore-CFAkQG2b.js";import"./vendor-moment-Cv92BTSA.js";import"./vendor-bootstrap-CCU-90um.js";import"./vendor-jspdf-UFhKzYHA.js";import"./vendor-php-date-formatter-DSpPwBF8.js";import"./callbackStore-BhxBUA6V.js";const L={class:"ccb-dropdown multi-select"},P={key:0,class:"anchor ccb-heading-5 ccb-light-3 ccb-selected"},R=["onClick"],$={key:1,class:"anchor ccb-heading-5 ccb-light ccb-selected"},j={key:2,class:"anchor ccb-heading-5 ccb-light-3"},q={class:"ccb-order-dropdown__list"},G={class:"ccb-default-checkbox"},H=["for"],J=["id","name","checked","value","onChange"],K={class:"ccb-checkbox-label"},ue=A({__name:"MultiSelectDropDown",props:{field:{}},emits:["toggle"],setup(V,{emit:T}){const C=T,h=V,{field:e}=z(h),_=E(null),{toggleBody:b}=F(h,C,_),f=M(),S=n=>{var c;const o=((c=e.value.selectedIdx)==null?void 0:c.filter(t=>t!==n))||[];e.value.selectedIdx=o},a=w(()=>e.value.selectedIdx||[]),I=n=>{var v,g,k;let o=e.value.selectedIdx||[];a.value.includes(n)?o=((v=e.value.selectedIdx)==null?void 0:v.filter(d=>d!==n))||[]:o.push(n);let c=[];const t=((k=(g=e.value)==null?void 0:g.attributes)==null?void 0:k.options)||[];for(let d=0;d<t.length;d++){const D=t[d];o.includes(d)&&c.push(D.optionText||"")}const{updateValue:r}=N();e.value.value=c,r(e.value.id,e.value.value,o)},B=w(()=>Math.random().toString(36).substring(2,15));return O(()=>{var n;Array.isArray((n=e.value)==null?void 0:n.value)&&(e.value.value=e.value.value[0])}),(n,o)=>{var c;return u(),i("div",{class:"ccb-field__input-wrapper",ref_key:"dropdownWrapper",ref:_},[l("div",L,[l("div",{class:"ccb-order-dropdown__input",onClick:o[0]||(o[0]=(...t)=>s(b)&&s(b)(...t))},[o[1]||(o[1]=l("i",{class:"ccb-icon-Path-3485 ccb-select-arrow"},null,-1)),s(e).attributes&&s(e).attributes.options&&a.value.length>0?(u(),i("span",P,[a.value.length&&a.value.length<3?(u(!0),i(y,{key:0},x(a.value,(t,r)=>(u(),i("span",{class:"selected",key:r},[W(m(s(e).attributes.options[t].optionText)+" ",1),l("i",{class:"ccb-icon-close",onClick:v=>S(t)},null,8,R)]))),128)):p("",!0)])):p("",!0),a.value.length>=3?(u(),i("span",$,m(a.value.length)+" "+m(s(f).getTranslations.optionsSelected),1)):p("",!0),a.value.length===0?(u(),i("span",j,m(s(f).getTranslations.selectValues),1)):p("",!0)]),l("div",q,[l("ul",null,[(c=s(e).attributes)!=null&&c.options?(u(!0),i(y,{key:0},x(s(e).attributes.options,(t,r)=>(u(),i("li",{key:r},[l("div",G,[l("label",{for:s(e).id+"order_dropdown_checkbox_"+r},[l("input",{type:"checkbox",id:s(e).id+"order_dropdown_checkbox_"+r,name:B.value,checked:a.value.includes(r),value:t.optionText,onChange:()=>I(r)},null,40,J),l("span",K,m(t.optionText),1)],8,H)])]))),128)):p("",!0)])])])],512)}}});export{ue as default};
//# sourceMappingURL=MultiSelectDropDown-DQiZ7_Mt.js.map
