import{a as N,g as $,i as E,aH as M,r as b,H as S,j as e,h as a,_ as l,E as P,R as v,t as C,M as F,b as g,f as w,bG as H}from"./main-634.js";import{s as O}from"./bf-486-243.js";import{F as T}from"./bf-767-388.js";import{d as R}from"./bf-25-81.js";import"./bf-497-246.js";function D(){var x,h;const{css:s}=N(),{fieldKey:t}=$(),[i,j]=E(M),[y,m]=b.useState(!1),p=b.useRef("");if(!t)return null;const r=S(i[t]),_=((r==null?void 0:r.config)||{}).emailTemplate||"",u=c=>{const n=w(i,d=>{d[t].config=d[t].config||{},d[t].config.emailTemplate=c});j(n),H({event:`OTP Email Template changed: ${t}`,type:"otp_email_template_changed",state:{fields:n,fldKey:t}})},o=()=>{var c,n;p.current=((n=(c=i[t])==null?void 0:c.config)==null?void 0:n.emailTemplate)||"",m(!0)},f=()=>{u(p.current),m(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:s(T.fieldSection),children:[e.jsxs("div",{className:s(a.flxcb),children:[e.jsx("span",{className:`title ${s(a.flxc)}`,children:l("Email Template")}),e.jsx("span",{role:"button",tabIndex:-1,className:s(a.mr2,a.cp),onClick:o,onKeyDown:o,children:e.jsx(P,{size:19})})]}),e.jsx("div",{role:"button",tabIndex:-1,className:`${s(T.input,a.px10,a.py5,O.childPmargin0,{h:"auto",fs:"12px !important"})} body`,onClick:o,onKeyDown:o,children:e.jsx(v,{html:C(_)})}),e.jsx("p",{className:s(a.helpText),children:l("Available placeholders: ${bf_otp_code}, ${bf_expiry_minutes}")}),e.jsxs("p",{className:s(a.helpText),children:[l("Note: To send OTP emails, SMTP must be configured on your site. You can set it up in Bit Form "),e.jsx("strong",{children:"App Settings > SMTP "}),l("section.")]})]}),e.jsxs(F,{md:!0,show:y,setModal:f,title:l("Edit OTP Email Template"),children:[e.jsx(R,{id:`otp-tmpl-${t}`,value:((h=(x=i[t])==null?void 0:x.config)==null?void 0:h.emailTemplate)||"",onChangeHandler:u}),e.jsx("p",{className:s({fs:"12px",c:"#888",mt:5}),children:l("Placeholders: ${bf_otp_code} — the OTP code, ${bf_expiry_minutes} — expiry time in minutes")}),e.jsxs("div",{className:"mt-2 f-right",children:[e.jsx("button",{type:"button",className:`${s(g.btn)} mr-2`,onClick:f,children:l("Cancel")}),e.jsx("button",{type:"button",className:`${s(g.btn)} blue`,onClick:()=>m(!1),children:l("Save")})]})]})]})}export{D as default};
