import{g as q,i as B,aH as H,u as K,k as L,a as z,j as l,_ as N,h as o,I as P,f as S,bG as y}from"./main-634.js";import{F as f}from"./bf-767-388.js";import{E as R}from"./bf-178-233.js";import{S as G}from"./bf-982-242.js";import{S as J}from"./bf-497-246.js";import"./bf-692-111.js";import"./bf-400-72.js";import"./bf-25-81.js";import"./bf-438-114.js";import"./bf-486-243.js";import"./bf-723-244.js";import"./bf-299-245.js";import"./bf-534-247.js";import"./bf-962-248.js";import"./bf-343-249.js";import"./bf-791-250.js";import"./bf-641-107.js";import"./bf-570-251.js";import"./bf-838-80.js";import"./bf-297-103.js";import"./bf-284-252.js";import"./bf-17-106.js";import"./bf-671-253.js";import"./bf-334-254.js";import"./bf-710-385.js";import"./bf-676-386.js";import"./bf-638-271.js";import"./bf-247-269.js";import"./bf-423-273.js";import"./bf-457-387.js";import"./bf-577-275.js";import"./bf-288-389.js";import"./bf-939-390.js";function je({className:I=""}){var w,b,j,v,_;const{fieldKey:n}=q(),[x,h]=B(H),g=K(L),{css:r}=z();if(!n)return null;const i=x[n],O=(b=(w=i==null?void 0:i.config)==null?void 0:w.multipleSelect)!=null?b:!1,d=(j=i==null?void 0:i.mn)!=null?j:0,u=(v=i==null?void 0:i.mx)!=null?v:0,M=(_=i==null?void 0:i.adminLbl)!=null?_:"",m=(g==null?void 0:g.err)||{},T=e=>{const{checked:a}=e.target,t=S(x,p=>{const c=p[n];c.config.multipleSelect=a,c.config.showChip=a,c.config.closeOnSelect=!a});h(t),y({event:`Multiple Select ${a?"On":"Off"}: ${i.lbl||M||n}`,type:"multipleSelect_change",state:{fields:t,fldKey:n}})},$=(e,a)=>{const t=isNaN(Number(a))?0:Number(a);if(t<0)return;const p=S(x,c=>{var F,A,k,C;const s=c[n];!s.err.mn&&e==="mn"&&(s.err.mn={show:!0}),!s.err.mx&&e==="mx"&&(s.err.mx={show:!0}),e==="mx"&&d&&t<d?(s.mn=t,s.err.mn.dflt=((F=m==null?void 0:m[s.typ])==null?void 0:F.mn)||`Minimum ${t} Option Required`):e==="mn"&&u&&t>u&&(s.mx=t,s.err.mx.dflt=((A=m==null?void 0:m[s.typ])==null?void 0:A.mx)||`Maximum ${t} Option can select.`),e==="mn"?s.err.mn.dflt=((k=m==null?void 0:m[s.typ])==null?void 0:k.mn)||`Minimum ${t} Option Required`:e==="mx"&&(s.err.mx.dflt=((C=m==null?void 0:m[s.typ])==null?void 0:C.mx)||`Maximum ${t} Option can select.`),s[e]=t});h(p),y({event:`${e==="mn"?"Minimum Option":"Maximum Option"} '${String(t||"Off").replace("true","On")}': ${i.lbl||n}`,type:`${e}_changed`,state:{fields:p,fldKey:n}})},V=e=>{if(!P)return;const{checked:a}=e.target,t=S(x,p=>{const c=p[n];a?c.valid.disableOnMax=!0:delete c.valid.disableOnMax});h(t),y({event:`Disable on max selected ${a?"on":"off"}: ${i.lbl||M||n}`,type:"set_disable_on_max",state:{fields:t,fldKey:n}})};return l.jsx(G,{id:"alw-mltpl-stng",title:N("Allow Multiple Select:"),toggleAction:T,toggleChecked:O,className:`${r(f.fieldSection,f.hover_tip)} ${I}`,switching:!0,tip:"By enabling this feature, you will enable to select Multiple Options",tipProps:{width:200,icnSize:17},open:O,disable:!O,isPro:!0,allowToggle:!0,proProperty:"minMaxOpt",children:l.jsxs("div",{className:r(o.ml1,o.mr1),children:[l.jsxs("div",{className:r(o.flxc),children:[l.jsx("span",{children:"Minimum Option"}),l.jsx("input",{"data-testid":"alw-mltpl-min-inp",className:r(f.input,o.w5,o.mt1),type:"number",value:d,onChange:e=>$("mn",e.target.value)})]}),!!d&&l.jsx(R,{className:r(o.mt0),id:"min-fil-err-msg",type:"mn",defaultMsg:`Minimum ${d} Option Required`,allowIcons:!1}),l.jsxs("div",{className:r(o.flxc,o.mt2),children:[l.jsx("span",{children:"Maximum Option"}),l.jsx("input",{"data-testid":"alw-mltpl-max-inp",className:r(f.input,o.w5,o.mt1),type:"number",value:u,onChange:e=>$("mx",e.target.value)})]}),!!u&&l.jsxs(l.Fragment,{children:[l.jsx(R,{className:r(o.mt0),id:"max-fil-err-msg",type:"mx",defaultMsg:`Maximum ${u} Option can select`,allowIcons:!1}),l.jsx(J,{id:"mxmm-slctd",title:N("Disable if maximum selected:"),action:V,isChecked:i.valid.disableOnMax,disabled:!P,className:"mt-3 mb-2"})]})]})})}export{je as default};
