var I=Object.defineProperty;var j=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var f=(i,a,o)=>a in i?I(i,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[a]=o,c=(i,a)=>{for(var o in a||(a={}))L.call(a,o)&&f(i,o,a[o]);if(j)for(var o of j(a))z.call(a,o)&&f(i,o,a[o]);return i};import{i as F,r as M,a as S,q as R,_ as l,j as e,a1 as T,am as V,E as B,Q as H,d as O,s as P,b as Q,bm as q,h as E,aQ as Y,f as G,c as J,H as y,V as K,u as U,z as W,A as X,B as u,bx as C,F as w,N as Z}from"./main-634.js";import{L as ee}from"./bf-29-403.js";import{S as te}from"./bf-504-404.js";import{t as _}from"./bf-275-83.js";import{B as N}from"./bf-25-81.js";import{F as k}from"./bf-400-72.js";import"./bf-438-114.js";function se({formID:i}){const[a,o]=F(Y),[t,m]=M.useState({show:!1}),{css:x}=S(),{pathname:d}=R(),D=s=>{const r=G(a,n=>{n.splice(s+1,0,{title:n[s].title,sub:n[s].sub,body:n[s].body}),n.push({updateTem:1})});o(r)},$=(s,r)=>{if(r.original.id){const n=J({formID:i,id:r.original.id},"bitforms_delete_mailtemplate").then(h=>{if(h!==void 0&&h.success){const b=y(a);b.splice(s,1),o(b)}});K.promise(n,{loading:"Deleting",success:"Successfully Deleted",error:"Error Occurred"})}else{const n=y(a);n.splice(s,1),o(n)}},p=()=>{t.show=!1,m(c({},t))},g=(s,r)=>{t.btnTxt=l("Delete"),t.body=l("Are you sure to delete this template"),t.btnClass="",t.action=()=>{$(s,r),p()},t.show=!0,m(c({},t))},v=s=>{t.btnTxt=l("Duplicate"),t.body=l("Are you sure to duplicate this template?"),t.btnClass="blue",t.action=()=>{D(s),p()},t.show=!0,m(c({},t))},A=[{Header:l("Template Name"),accessor:"title",Cell:s=>e.jsx(T,{to:`${d}/${s.row.index}`,children:e.jsx("b",{children:s.cell.value})})},{Header:l("Action"),accessor:"action",Cell:s=>e.jsxs(e.Fragment,{children:[e.jsx(N,{onClick:()=>v(s.row.index),className:"icn-btn mr-2 tooltip pos-rel",style:{"--tooltip-txt":`'${l("Duplicate")}'`},children:e.jsx(V,{size:"22"})}),e.jsx(T,{to:`${d}/${s.row.index}`,className:"icn-btn mr-2 flx flx-center tooltip pos-rel",style:{"--tooltip-txt":`'${l("Edit")}'`},children:e.jsx(B,{size:"22"})}),e.jsx(N,{onClick:()=>g(s.row.index,s.row),className:"icn-btn tooltip pos-rel",style:{"--tooltip-txt":`'${l("Delete")}'`},children:e.jsx(H,{size:"21"})})]})}];return e.jsxs("div",{className:"w-7",children:[e.jsx(O,{show:t.show,close:p,btnTxt:t.btnTxt,btnClass:t.btnClass,body:t.body,action:t.action}),e.jsx("h2",{children:l("Email Templates")}),e.jsxs("h5",{children:[l("How to setup Email Templates & Send Email Notification:")," ",e.jsx("a",{href:_.emailTemplates.link,target:"_blank",rel:"noreferrer",className:"yt-txt ml-1 mr-1",children:l("YouTube")}),e.jsx("a",{href:_.emailTemplatesDoc.link,target:"_blank",rel:"noreferrer",className:"doc-txt",children:l("Documentation")})]}),e.jsxs("div",{className:"",children:[e.jsxs(P,{to:`${d}/new`,className:`${x(Q.btn)} tertiary`,children:[e.jsx(ee,{size:"20"})," ",l("Add New Template")]}),a.length>0?e.jsx(q,{height:"60vh",className:"btcd-neu-table mr-1",columns:A,data:a}):e.jsxs("div",{className:x(E.btcdEmpty,E.txCenter),children:[e.jsx(te,{size:"50"}),l("Empty")]})]})]})}const ae=C(()=>w(()=>import("./bf-322-401.js"),["./bf-322-401.js","./main-634.js","./main-634.css","./bf-25-81.js","./bf-831-476.css"],import.meta.url),{fallback:e.jsx(k,{})}),le=C(()=>w(()=>import("./bf-465-402.js"),["./bf-465-402.js","./main-634.js","./main-634.css","./bf-25-81.js","./bf-831-476.css"],import.meta.url),{fallback:e.jsx(k,{})});function ue(){const i=U(Z);return e.jsx(W,{children:e.jsxs(X,{children:[e.jsx(u,{index:!0,element:e.jsx(se,{formID:i})}),e.jsx(u,{path:"/new",element:e.jsx(ae,{})}),e.jsx(u,{path:"/:id",element:e.jsx(le,{})})]})})}export{ue as default};
