import{a as F,g as C,i as $,aH as N,aX as k,r as A,H as E,j as l,_ as g,I as H,f as j,bG as R}from"./main-634.js";import{F as m}from"./bf-767-388.js";import{S as w}from"./bf-982-242.js";import"./bf-25-81.js";import"./bf-497-246.js";import"./bf-641-107.js";import"./bf-400-72.js";import"./bf-438-114.js";function z(){const{css:r}=F(),{fieldKey:t}=C(),[i,B]=$(N),[D,S]=$(k),[o,b]=A.useState({});if(!t)return null;const n=E(i[t]),{btnTyp:f}=n,v=()=>Object.values(i).filter(e=>e.typ==="button"&&e.btnTyp==="submit").length>=1,d=[{name:"Reset",value:"reset",disabled:!1},{name:"Button",value:"button",disabled:!1}];H&&d.push({name:"Save Draft",value:"save-draft",disabled:!1}),(!v()||f==="submit")&&d.push({name:"Submit",value:"submit",disabled:!0});const _=s=>{const{value:e}=s.target;if(n.btnTyp=e,n.btnTyp==="submit"&&v()){b({btnTyp:g("Already have a submit button")}),setTimeout(()=>{b({btnTyp:""})},3e3);return}o.btnTyp&&b({btnTyp:""});let c="var(--btn-bg)",u="var(--btn-c)",y="var(--btn-bdr-clr)",h="var(--btn-bdr)",T="var(--btn-bdr-width)";e==="reset"&&(c="hsla(240, 12%, 94%, 100)",u="hsla(208, 46%, 25%, 100)"),e==="save-default"&&(c="hsla(0, 0%, 100%, 100)",u="var(--btn-bgc)",y="var(--btn-bgc)",h="solid",T="1px"),S(p=>j(p,a=>{a.fields[t].classes[`.${t}-btn`].background=c,a.fields[t].classes[`.${t}-btn`].color=u,e!=="save-draft"&&(a.fields[t].classes[`.${t}-btn`]["border-color"]=y,a.fields[t].classes[`.${t}-btn`]["border-style"]=h,a.fields[t].classes[`.${t}-btn`]["border-width"]=T,a.fields[t].classes[`.${t}-btn:hover`].color="var(--btn-c)")}));const x=j(i,p=>{p[t]=n});B(x),R({event:`Button Type updated to ${e}: ${n.txt}`,type:"set_btn_typ",state:{fields:x,fldKey:t}})};return l.jsxs(w,{id:"btn-typ",title:g("Button Type"),className:r(m.fieldSection),open:!0,children:[l.jsx("div",{className:r(m.placeholder),children:l.jsx("select",{"data-testid":"btn-typ-slct",className:r(m.input),value:f,onChange:_,children:d.map(s=>l.jsx("option",{value:s.value,children:s.name},`btcd-k-${s.name}`))})}),o.btnTyp&&l.jsx("span",{className:r({cr:"red",ml:10}),children:o.btnTyp})]})}export{z as default};
