jQuery(document).ready((function(t){"use strict";window.jsPDF=window.jspdf.jsPDF;let e=t("#wpbody");e&&e.append('<div class="mf-pdf-wrapper"><div class="mfContentToMakePdf"></div></div>');let a={export_btn:t(".metform-pdf-export-btn")};t.extend(a,{init:function(){this.getEntryData()},getEntryData:function(){let e=this;this.export_btn.on("click",(a=>{a.preventDefault(),a.stopPropagation(),a.target.dataset.nonce?(a.target.classList.add("loading"),jQuery.ajax({url:ajaxurl,type:"POST",data:{action:"metform_pdf_get_entry",entry_id:a.target.dataset.id,_wpnonce:a.target.dataset.nonce},success:function(n){let o=t(".mfContentToMakePdf");o&&o.html(n),e.makePdf(a,o[0])},error:function(t,e,a){console.error("Error: "+a)}})):alert("Please update Metform free plugin too!")}))},makePdf:function(e,a){html2canvas(a,{scale:2}).then((function(t){let a=t.toDataURL("image/jpeg"),n=new jsPDF({compress:!0}),o=300*t.height/t.width;n.addImage(a,"JPEG",20,20,300,o),n.save(`Entry#${e.target.dataset.id}.pdf`)})).then((()=>{e.target.classList.remove("loading");let a=t(".mfContentToMakePdf");a&&a.html("")}))}}).init()}));