"use strict";exports.ids=["126"],exports.modules={10212:function(e,t,a){t.ExportPagesZipPages=void 0;var r=a(85714);t.ExportPagesZipPages=class{async execute(e){let{isAborted:t,response:a}=e;if(t())return a.aborted();let i=new r.ZipPages;return await i.execute(e)}}},13736:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.createExportPagesDataKey=t.EXPORT_PAGES_FOLDER_KEY=void 0;let a=t.EXPORT_PAGES_FOLDER_KEY="WEBINY_PB_EXPORT_PAGES";t.createExportPagesDataKey=e=>`${a}/${e}`},85714:function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0}),t.ZipPages=void 0;var r=a(90481),i=a(2654),o=a(10653),n=a(13736);t.ZipPages=class{async execute(e){let{response:t,input:a,isAborted:s,isCloseToTimeout:d,context:l,store:u}=e,g=u.getTask().parentId;if(!g)return t.error({message:"Could not find parent task ID."});let c=(0,n.createExportPagesDataKey)(g),f=new i.ZipPagesDataManager(a);if(!1===f.hasMore())return t.done("Task done.",{done:f.getDone(),failed:f.getFailed()});let p=(0,o.getPageFactory)(l,u,"published"===a.type);for(let e of a.queue){if(s())return t.aborted();if(d(300))return t.continue(f.getInput());let a=await p(e);if(!a){await u.addErrorLog({message:`Could not load page "${e}".`,error:{message:`Could not load page "${e}".`}}),f.addFailed(e);continue}try{let t=new r.PageExporter(l.fileManager),i=await t.execute(a,c);if(!i.Key)throw Error(`Failed to export page "${e}" into a zip file.`);f.addDone(e,i.Key)}catch(a){let t=a.message||`Failed to export page "${e}" into a zip file.`;try{await u.addErrorLog({message:t,error:a})}catch{console.error(`Failed to add error log: "${t}"`)}f.addFailed(e)}}return t.done("Task done.",{done:f.getDone(),failed:f.getFailed()})}}},2654:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ZipPagesDataManager=void 0,t.ZipPagesDataManager=class{constructor(e){this.input=e,this.queue=new Set(e.queue),this.done={...e.done},this.failed=new Set(e.failed||[])}hasMore(){return this.queue.size>0}addDone(e,t){this.queue.delete(e),this.failed.delete(e),this.done[e]=t}addFailed(e){this.queue.delete(e),this.failed.add(e),delete this.done[e]}getFailed(){return Array.from(this.failed)}getDone(){return this.done}getInput(){return{...this.input,queue:Array.from(this.queue),failed:Array.from(this.failed),done:this.done}}}},10653:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.getPageFactory=void 0,t.getPageFactory=(e,t,a)=>async r=>{if(a)try{return await e.pageBuilder.getPublishedPageById({id:r})}catch(e){}try{return await e.pageBuilder.getPage(r)}catch(a){let e=`There is no page with ID ${r}.`;try{await t.addErrorLog({message:e,error:a})}catch{console.error(`Failed to add error log: "${e}"`)}return null}}},90481:function(e,t,a){var r=a(15755).default;Object.defineProperty(t,"__esModule",{value:!0}),t.PageExporter=void 0;var i=r(a(72579)),o=r(a(49664)),n=a(80999);t.PageExporter=class{constructor(e){this.fileManager=e}async execute(e,t){let a=[...(0,n.extractFilesFromData)(e.content||{}),...[(0,i.default)(e,"settings.general.image"),(0,i.default)(e,"settings.social.image")].filter(e=>e&&e.src)].map(e=>e.id),r=[];if(a.length>0){let[e]=await this.fileManager.listFiles({where:{id_in:a},limit:1e4});r.push(...e)}let s={page:{content:e.content,title:e.title,path:e.path,version:e.version,status:e.status,settings:e.settings},files:r},d=Buffer.from(JSON.stringify(s));return new o.default({exportInfo:{files:r,name:e.title,dataBuffer:d},archiveFileKey:t}).process()}}}};
//# sourceMappingURL=ExportPagesZipPages.871cd0e3.chunk.js.map