import{g as w,G as C,i as A,u as b,r as S,cc as k,a as E,j as e,dV as B,a1 as M,b as x,_ as i,aO as P,K as _,$ as G,A as c,f as j}from"./main-343.js";import{B as H,i as I,d as O}from"./bf-649-79.js";function D(){var h;const{formType:d,formID:n,id:s}=w(),g=C(),[l,m]=A(P),r=b(_),[o]=S.useState(()=>r.filter(a=>!k.includes(a.typ))),{css:p}=E(),$=b(G),{isPro:u}=$,y=a=>{const t=c(l);t[s].title=a.target.value,m(t)},v=a=>{const t=c(l);t[s].sub=a.target.value,m(t)},T=a=>{m(t=>j(t,F=>{F[s].body=a}))},f=a=>{const t=c(l);t[s].sub+=a.target.value,m(t)},N=()=>{const a=j(l,t=>{t.push({updateTem:1})});m(a),g(`/form/settings/${d}/${n}/email-templates`)};return l.length<1?e.jsx(B,{to:`/form/settings/edit/${n}/email-templates`,replace:!0}):e.jsxs("div",{style:{width:900},children:[e.jsxs(M,{to:`/form/settings/${d}/${n}/email-templates`,className:`${p(x.btn)} btcd-btn-o-gray`,children:[e.jsx(H,{className:"mr-1"}),i("Back")]}),e.jsx("button",{id:"secondary-update-btn",onClick:N,className:`${p(x.btn)} blue f-right`,type:"button",children:i("Update Template")}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx("b",{style:{width:102},children:i("Template Name:")}),e.jsx("input",{onChange:y,type:"text",className:"btcd-paper-inp w-9",placeholder:"Name",value:l[s].title})]}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx("b",{style:{width:100},children:i("Subject:")}),e.jsx("input",{onChange:v,type:"text",className:"btcd-paper-inp w-7",placeholder:i("Email Subject Here"),value:l[s].sub}),e.jsxs("select",{onChange:f,className:"btcd-paper-inp ml-2",style:{width:150},children:[e.jsx("option",{value:"",children:i("Add field")}),e.jsx("optgroup",{label:"Form Fields",children:o!==null&&o.map(a=>!a.type.match(/^(file-up|recaptcha)$/)&&e.jsx("option",{value:`\${${a.key}}`,children:a.name},a.key))}),e.jsx("optgroup",{label:`General Smart Codes ${u?"":"(PRO)"}`,children:u&&((h=I)==null?void 0:h.map(a=>e.jsx("option",{value:`\${${a.name}}`,children:a.label},`ff-rm-${a.name}`)))})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{children:e.jsx("b",{children:i("Body:")})}),e.jsx("label",{htmlFor:`t-m-e-${s}-${n}`,className:"mt-2 w-10",children:e.jsx(O,{id:`mail-tem-${n}`,formFields:r,value:l[s].body,onChangeHandler:T,width:"100%",mapAllFieldWithTable:!0,mapAllField:!0,height:"400"})})]})]})}export{D as default};
