var C=Object.defineProperty,_=Object.defineProperties;var I=Object.getOwnPropertyDescriptors;var u=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var g=(t,r,o)=>r in t?C(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,f=(t,r)=>{for(var o in r||(r={}))$.call(r,o)&&g(t,o,r[o]);if(u)for(var o of u(r))L.call(r,o)&&g(t,o,r[o]);return t},b=(t,r)=>_(t,I(r));import{g as k,i as F,aH as N,u as A,k as H,H as T,a as E,j as l,_ as B,I as q,h as R,e9 as K,f as c,bG as m,ba as M}from"./main-634.js";import{F as n}from"./bf-767-388.js";import{S as v}from"./bf-497-246.js";import{S as z}from"./bf-982-242.js";import{E as G}from"./bf-178-233.js";import"./bf-25-81.js";import"./bf-641-107.js";import"./bf-400-72.js";import"./bf-438-114.js";import"./bf-692-111.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-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 we(){const{fieldKey:t}=k(),[r,o]=F(N),O=A(H),e=T(r[t]),{css:a}=E(),d=e.adminLbl||"",y=s=>{var h;if(!q)return;s.target.checked?(e.addOtherOpt=!0,e.valid.otherOptReq=!0,e.err||(e.err={}),e.err.otherOptReq||(e.err.otherOptReq={}),e.err.otherOptReq.dflt=((h=O==null?void 0:O.err)==null?void 0:h.otherOptReq)||'<p style="margin:0">Custom Option Required</p>',e.err.otherOptReq.show=!0,K(t,"otherOptions")):(delete e.valid.otherOptReq,delete e.addOtherOpt);const i=s.target.checked?"Add":"Remove",p=c(r,j=>{j[t]=e});o(p),m({event:`${i} Other Option: ${e.lbl||d||t}`,type:`${i.toLowerCase()}_Other_Option`,state:{fields:p,fldKey:t}}),M(t)},x=s=>{s.target.checked?(e.valid.otherOptReq=!0,e.err||(e.err={}),e.err.otherOptReq||(e.err.otherOptReq={}),e.err.otherOptReq.dflt='<p style="margin:0">Custom Option Required</p>',e.err.otherOptReq.show=!0):delete e.valid.otherOptReq;const i=s.target.checked?"Requred":"Optional",p=c(r,h=>{h[t]=e});o(p),m({event:`${i} Required Other Option: ${e.lbl||d||t}`,type:`${i.toLowerCase()}_Other_Option`,state:{fields:p,fldKey:t}})},P=s=>{s.target.checked?(e.otherInpPh="Write Custom Option...",e.otherPhShow=!0):(e.otherPhShow=!1,delete e.otherInpPh);const i=s.target.checked?"Show":"Hide",p=c(r,h=>{h[t]=e});o(p),m({event:`${i} Placeholder: ${e.lbl||d||t}`,type:`${i.toLowerCase()}_placeholder`,state:{fields:p,fldKey:t}})},w=s=>{e.otherOptLbl=s.target.value;const i=c(r,p=>{p[t]=e});o(i),m({event:`Other Option Label updated: ${e.lbl||d||t}`,type:"change_other_option_label",state:{fields:i,fldKey:t}})};function S(s){s.target.value===""?delete e.otherInpPh:e.otherInpPh=s.target.value;const i=c(r,p=>{p[t]=e});o(i),m({event:`Other Input Placeholder updated: ${e.lbl||d||t}`,type:"change_placeholder",state:{fields:i,fldKey:t}})}return l.jsx(z,b(f({id:"other-opt-stng",title:B("Allow Other Option"),className:a(n.fieldSection,n.hover_tip),switching:!0,tip:"An option will be added as labelled 'Other...' to get custom input from the user",tipProps:{width:250,icnSize:17},toggleAction:y,toggleChecked:e==null?void 0:e.addOtherOpt,open:e==null?void 0:e.addOtherOpt},q&&{disable:!(e!=null&&e.addOtherOpt)}),{isPro:!0,proProperty:"otherOption",children:l.jsxs("div",{className:a(n.placeholder),children:[l.jsxs("div",{className:a({flx:"center-between",my:5}),children:[l.jsx("span",{className:a(n.title,{w:"150px",ml:0}),children:"Option Label"}),l.jsx("input",{"data-testid":"other-opt-inp","aria-label":"Other Option Label",placeholder:"Type Option Label here...",className:a(n.input,{mt:5}),type:"text",value:e.otherOptLbl||"",onChange:w})]}),l.jsxs("div",{className:a({flx:"center-between",my:5}),children:[l.jsx("span",{children:"Required Custom Input"}),l.jsx(v,{id:"req-other-opt",className:a(R.mr2),name:"req-other-opt",action:x,isChecked:!!e.valid.otherOptReq})]}),e.valid.otherOptReq&&l.jsx(G,{id:"other-opt-stng",type:"otherOptReq",title:"Error Message",tipTitle:"By enabling this feature, user will see the error message when input is empty"}),l.jsxs("div",{className:a({flx:"center-between",my:5}),children:[l.jsx("span",{children:"Input Placeholder"}),l.jsx(v,{id:"other-inp-ph",className:a(R.mr2),name:"other-inp-ph",action:P,isChecked:!!e.otherPhShow})]}),e.otherPhShow&&l.jsx("input",{"data-testid":"othep-ph-inp","aria-label":"Placeholer for Other Input",placeholder:"Type Placeholder here...",className:a(n.input),type:"text",value:e.otherInpPh||"",onChange:S})]})}))}export{we as default};
