let TBP_ExportFile;((t,e)=>{"use strict";TBP_ExportFile={getData:(e,o)=>t.fetch({action:"tbp_export",id:e,nonce:o.nonce}).then((t=>{if(!t||!t.success||!t.data)throw"error";return t})),init(o,i,n){return new Promise((async(a,s)=>{try{const c=[t.loadJs(t.url+"js/admin/notification",!!e.TF_Notification),t.loadJs("https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js",!!e.JSZip,"3.10.1")],r="tbp_theme"===i;r&&c.push(this.getData(o[0],n));const l=(await Promise.all(c))[2];if(r&&(!l||!l.success))throw"Error";let p,_,m=[],w=[];const f=t=>new Promise(((e,o)=>{setTimeout((()=>{this.getData(t,n).then(e).catch(o)}),500)})),u=async t=>{const e=Object.keys(t),o=n.export_templates.replaceAll("%to%",e.length),i=[];let a=1;for(let n of e){let e;await TF_Notification.show("info",o.replaceAll("%from%",a).replaceAll("%post%",t[n]));try{e=await f(n)}catch(t){try{e=await f(n)}catch(t){}}finally{e&&(e=e.data,e.gs&&(m.push(e.gs),delete e.gs),e.cf&&(w.push(e.cf),delete e.cf),i.push(e)),++a}}return i};if(r){const t=l.data;_=t.title,await TF_Notification.show("info",n.export_theme_name.replaceAll("%post%",_));const e=t.templates?await u(t.templates):[];p={content:[{title:_,screenshot:t.tbp_theme_screenshot||"",templates:e}]},_="pro_theme_"+_}else{const t=await u(o);p={content:t,import:"template"},_="pro_template_"+t[0].tbp_template_name}_=_.replaceAll(" –","-").replaceAll("- ","-").replaceAll("-","_").replaceAll(" ","_");const h=new JSZip,x=new Date,y=x.getFullYear()+"_"+x.getMonth()+"_"+x.getDate(),d=(t,e)=>{let o=document.createElement("a");o.download=e,o.rel="noopener",o.href=URL.createObjectURL(t),setTimeout((()=>{URL.revokeObjectURL(o.href),o=null}),12e3),o.click()};p=JSON.stringify(p),h.file("export_file.txt",p),m.length>0?(m=JSON.stringify(m),h.file("builder_gs_data_export.txt",m)):m=null,w.length>0?(w=JSON.stringify(w),h.file("custom-fonts.txt",w)):w=null;try{const t=await h.generateAsync({type:"blob"});d(t,_+"_"+y+".zip")}catch(t){try{d(new Blob([p],{type:"application/json"}),_+"_export_file_"+y+".txt"),m&&d(new Blob([m],{type:"application/json"}),_+"_builder_gs_data_export_"+y+".txt"),w&&d(new Blob([w],{type:"application/json"}),_+"_custom-fonts_"+y+".txt")}catch(t){s(t)}}a()}catch(t){s(t)}}))}}})(Themify,window);