"use strict";function initializePdfButton(d){let e=d.find("a").first(),i=e.data("element-id"),r=e.data("post-id"),l=e.data("queried-id"),c=e.data("converter"),s=e.data("ajax-url"),f=e.data("ajax-action"),u=e.data("nonce"),m=e.data("title"),w=e.data("preview")==="yes",p=e.data("new-tab")==="yes";if(c!=="html")return;const b=async function(){e.addClass("fetching-pdf");let t=new FormData;t.set("queried_id",l),t.set("post_id",r),t.set("element_id",i),t.set("action",f),t.set("nonce",u);let n;try{n=await fetch(s,{method:"POST",body:new URLSearchParams(t)})}catch(o){console.error("PDF Button: "+o.message);return}if(n.headers.get("Content-Type")!=="application/pdf"){const o=await n.json();console.error("PDF Button: "+o.data.message);return}let h=await n.blob(),a=document.createElement("a");a.href=window.URL.createObjectURL(h),w?p&&(a.target="_blank"):a.download=m,a.click(),e.removeClass("fetching-pdf")};e.on("click",()=>{b()})}jQuery(window).on("elementor/frontend/init",function(){elementorFrontend.isEditMode()||elementorFrontend.hooks.addAction("frontend/element_ready/dce_pdf_button.default",initializePdfButton)});