var B=Object.defineProperty,U=Object.defineProperties;var G=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var j=(n,s,o)=>s in n?B(n,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[s]=o,c=(n,s)=>{for(var o in s||(s={}))W.call(s,o)&&j(n,o,s[o]);if(b)for(var o of b(s))Y.call(s,o)&&j(n,o,s[o]);return n},T=(n,s)=>U(n,G(s));import{i as J,r as K,a as Q,G as X,g as Z,aq as ee,u as $,q as te,_ as l,j as e,a1 as _,ao as se,E as ae,W as oe,d as le,U as ne,bg as ie,h as y,I as re,c8 as ce,f as g,aP as de,c9 as me,$ as pe,c as ue,A as w,z as fe,D as xe,F as x,bs as D,H as N,O as he}from"./main-343.js";import{F as v}from"./bf-90-70.js";import{L as be}from"./bf-241-329.js";import{S as je}from"./bf-175-330.js";import{t as C}from"./bf-974-82.js";import{g as P}from"./bf-649-79.js";import"./bf-594-113.js";function Te({formID:n}){const[s,o]=J(de),[a,p]=K.useState({show:!1}),{css:k}=Q(),E=X(),{formType:F}=Z(),A=ee(me),I=$(pe);let{pdf:u}=I.allFormSettings;u===void 0&&(u={direction:"ltr",font:{name:"DejaVuSansCondensed",fontFamily:"dejavusanscondensed"},fontColor:"#000000",fontFamily:"dejavusanscondensed",fontSize:10,orientation:"p",paperSize:"a4",pdfFileName:"",watermark:{}});const{pathname:h}=te(),S=t=>{const r=g(s,i=>{const{title:d,body:m,setting:V}=i[t],q=`${d} - Copy`;i.splice(t+1,0,{title:q,body:m,setting:V}),i.push({updateTem:1})});o(r)},z=(t,r)=>{if(r.original.id){const i=ue({formID:n,id:r.original.id},"bitforms_delete_pdf_template").then(d=>{if(d!==void 0&&d.success){const m=w(s);m.splice(t,1),o(m)}});fe.promise(i,{loading:"Deleting",success:"Successfully Deleted",error:"Error Occurred"})}else{const i=w(s);i.splice(t,1),o(i)}},f=()=>{a.show=!1,p(c({},a))},L=(t,r)=>{a.btnTxt=l("Delete"),a.body=l("Are you sure to delete this template"),a.btnClass="",a.action=()=>{z(t,r),f()},a.show=!0,p(c({},a))},M=t=>{a.btnTxt=l("Duplicate"),a.body=l("Are you sure to duplicate this template?"),a.btnClass="blue",a.action=()=>{S(t),f()},a.show=!0,p(c({},a))},O={title:"Untitled PDF Template",setting:T(c({},u),{password:{static:!0,pass:""}}),body:"${bf_all_data}"},R=()=>{if(!re){A(c({show:!0},ce.pdfProInstalledAlert));return}const t=s.length,r=g(s,i=>{i.push(O),i.push({updateTem:1})});o(r),E(`/form/settings/${F}/${n}/pdf-templates/${t}`)},H=[{Header:l("Template Name"),accessor:"title",Cell:t=>e.jsx(_,{to:`${h}/${t.row.index}`,children:e.jsx("b",{children:t.cell.value})})},{Header:l("Action"),accessor:"action",Cell:t=>e.jsxs(e.Fragment,{children:[e.jsx(P,{onClick:()=>M(t.row.index),className:"icn-btn mr-2 tooltip pos-rel",style:{"--tooltip-txt":`'${l("Duplicate")}'`},children:e.jsx(se,{size:"22"})}),e.jsx(_,{to:`${h}/${t.row.index}`,className:"icn-btn mr-2 flx flx-center tooltip pos-rel",style:{"--tooltip-txt":`'${l("Edit")}'`},children:e.jsx(ae,{size:"22"})}),e.jsx(P,{onClick:()=>L(t.row.index,t.row),className:"icn-btn tooltip pos-rel",style:{"--tooltip-txt":`'${l("Delete")}'`},children:e.jsx(oe,{size:"21"})})]})}];return e.jsxs("div",{className:"w-7",children:[e.jsx(le,{show:a.show,close:f,btnTxt:a.btnTxt,btnClass:a.btnClass,body:a.body,action:a.action}),e.jsx("h2",{children:l("PDF Templates")}),e.jsxs("h5",{className:"mt-3",children:[l("How to setup PDF Templates:"),e.jsx("a",{href:C.pdfTemplate.link,target:"_blank",rel:"noreferrer",className:"yt-txt ml-1 mr-1",children:l("YouTube")}),e.jsx("a",{href:C.pdfTemplateDoc.link,target:"_blank",rel:"noreferrer",className:"doc-txt",children:l("Documentation")})]}),e.jsxs("div",{className:"",children:[e.jsxs(ne,{size:"sm",onClick:R,children:[e.jsx(be,{size:"20"})," ",l("Add New Template")]}),s.length>0?e.jsx(ie,{height:"60vh",className:"btcd-neu-table mr-1",columns:H,data:s.sort((t,r)=>r.id-t.id)}):e.jsxs("div",{className:k(y.btcdEmpty,y.txCenter),children:[e.jsx(je,{size:"50"}),l("Empty")]})]})]})}const _e=D(()=>N(()=>import("./bf-918-331.js"),["./bf-918-331.js","./main-343.js","./main-343.css","./bf-649-79.js","./bf-899-409.css","./bf-529-105.js"],import.meta.url),{fallback:e.jsx(v,{})}),ye=D(()=>N(()=>import("./bf-590-332.js"),["./bf-590-332.js","./main-343.js","./main-343.css","./bf-649-79.js","./bf-899-409.css","./bf-529-105.js","./bf-90-70.js","./bf-594-113.js","./bf-558-408.css"],import.meta.url),{fallback:e.jsx(v,{})});function ke(){const n=$(he);return e.jsxs(xe,{children:[e.jsx(x,{index:!0,element:e.jsx(Te,{formID:n})}),e.jsx(x,{path:"/new",element:e.jsx(_e,{})}),e.jsx(x,{path:"/:id",element:e.jsx(ye,{})})]})}export{ke as default};
