"use strict";exports.id=952,exports.ids=[952],exports.modules={38100:(e,t,a)=>{t.ExportPagesZipPages=void 0;var r=a(8576);t.ExportPagesZipPages=class{async execute(e){const{isAborted:t,response:a}=e;if(t())return a.aborted();const o=new r.ZipPages;return await o.execute(e)}}},76474:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createExportPagesDataKey=t.EXPORT_PAGES_FOLDER_KEY=void 0;const a=t.EXPORT_PAGES_FOLDER_KEY="WEBINY_PB_EXPORT_PAGES";t.createExportPagesDataKey=e=>`${a}/${e}`},8576:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ZipPages=void 0;var r=a(86913),o=a(45197),i=a(29438),s=a(76474);t.ZipPages=class{async execute(e){const{response:t,input:a,isAborted:n,isCloseToTimeout:d,context:l,store:u}=e,g=u.getTask().parentId;if(!g)return t.error({message:"Could not find parent task ID."});const c=(0,s.createExportPagesDataKey)(g),p=new o.ZipPagesDataManager(a);if(!1===p.hasMore())return t.done("Task done.",{done:p.getDone(),failed:p.getFailed()});const f=(0,i.getPageFactory)(l,u,"published"===a.type);for(const e of a.queue){if(n())return t.aborted();if(d(300))return t.continue(p.getInput());const a=await f(e);if(a)try{const t=new r.PageExporter(l.fileManager),o=await t.execute(a,c);if(!o.Key)throw new Error(`Failed to export page "${e}" into a zip file.`);p.addDone(e,o.Key)}catch(t){const a=t.message||`Failed to export page "${e}" into a zip file.`;try{await u.addErrorLog({message:a,error:t})}catch{console.error(`Failed to add error log: "${a}"`)}p.addFailed(e)}else await u.addErrorLog({message:`Could not load page "${e}".`,error:{message:`Could not load page "${e}".`}}),p.addFailed(e)}return t.done("Task done.",{done:p.getDone(),failed:p.getFailed()})}}},45197:(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}}}},29438:(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(e){const a=`There is no page with ID ${r}.`;try{await t.addErrorLog({message:a,error:e})}catch{console.error(`Failed to add error log: "${a}"`)}return null}}},86913:(e,t,a)=>{var r=a(92120).default;Object.defineProperty(t,"__esModule",{value:!0}),t.PageExporter=void 0;var o=r(a(94304)),i=r(a(91900)),s=a(76709);t.PageExporter=class{constructor(e){this.fileManager=e}async execute(e,t){const a=[...(0,s.extractFilesFromData)(e.content||{}),...[(0,o.default)(e,"settings.general.image"),(0,o.default)(e,"settings.social.image")].filter((e=>e&&e.src))].map((e=>e.id)),r=[];if(a.length>0){const[e]=await this.fileManager.listFiles({where:{id_in:a},limit:1e4});r.push(...e)}const n={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(n));return new i.default({exportInfo:{files:r,name:e.title,dataBuffer:d},archiveFileKey:t}).process()}}}};
//# sourceMappingURL=ExportPagesZipPages.58113132.chunk.js.map