var A=Object.defineProperty,B=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var $=(t,s,l)=>s in t?A(t,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[s]=l,c=(t,s)=>{for(var l in s||(s={}))I.call(s,l)&&$(t,l,s[l]);if(T)for(var l of T(s))P.call(s,l)&&$(t,l,s[l]);return t},d=(t,s)=>B(t,_(s));import{r,i as G,u as g,cc as H,g as O,G as R,a as D,j as e,M as K,_ as n,a1 as L,b as f,aO as U,K as V,$ as W,f as N}from"./main-343.js";import{B as q,i as z,d as J}from"./bf-649-79.js";function Z(){var y;const[t,s]=r.useState({title:"Untitled Template",sub:"Email Subject",body:"${bf_all_data}"}),[l,v]=G(U),p=g(V),[u]=r.useState(()=>p.filter(a=>!H.includes(a.typ))),[w,F]=r.useState(!1),{formType:h,formID:m}=O(),S=R(),{css:b}=D(),M=g(W),{isPro:x}=M,C=a=>{s(i=>N(i,o=>{o.body=a}))},j=({target:{name:a,value:i}})=>{s(o=>d(c({},o),{[a]:i}))},E=()=>{const a=N(l,i=>{i.push(t),i.push({updateTem:1})});v(a),S(`/form/settings/${h}/${m}/email-templates`)},k=({target:{value:a}})=>{s(i=>d(c({},i),{sub:i.sub+a})),setTimeout(()=>{a=""},100)};return e.jsxs("div",{style:{width:900},children:[e.jsx(K,{show:w,setModal:F,title:n("Browse Template"),children:e.jsx("h4",{className:"txt-dp",children:n("Email Templates Coming soon")})}),e.jsxs(L,{to:`/form/settings/${h}/${m}/email-templates`,className:`${b(f.btn)} btcd-btn-o-gray`,children:[e.jsx(q,{className:"mr-1"}),n("Back")]}),e.jsx("button",{id:"secondary-update-btn",onClick:E,className:`${b(f.btn)} blue f-right`,type:"button",children:n("Save Template")}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsxs("b",{style:{width:103},children:[n("Template Name:")," "]}),e.jsx("input",{onChange:j,name:"title",type:"text",className:"btcd-paper-inp w-9",placeholder:"Name",value:t.title})]}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx("b",{style:{width:100},children:"Subject:"}),e.jsx("input",{onChange:j,name:"sub",type:"text",className:"btcd-paper-inp w-7",placeholder:"Email Subject Here",value:t.sub}),e.jsxs("select",{onChange:k,className:"btcd-paper-inp ml-2",style:{width:150},children:[e.jsx("option",{value:"",children:n("Add field")}),e.jsx("optgroup",{label:"Form Fields",children:u!==null&&u.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 ${x?"":"(PRO)"}`,children:x&&((y=z)==null?void 0:y.map(a=>e.jsx("option",{value:`\${${a.name}}`,children:a.label},`ff-rm-${a.name}`)))})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("b",{children:n("Body:")}),e.jsx("label",{htmlFor:`mail-tem-${m}`,className:"mt-2 w-10",children:e.jsx(J,{id:`mail-tem-${m}`,formFields:p,value:t.body,onChangeHandler:C,width:"100%",mapAllFieldWithTable:!0,mapAllField:!0})})]})]})}export{Z as default};
