"use strict";exports.ids=["570"],exports.modules={63060:function(e,t,a){t.ImportPagesProcessPages=void 0;var i=a(15e3),r=a(49042);t.ImportPagesProcessPages=class{async execute(e){let{context:t,response:a,input:i,store:r,isAborted:s,isCloseToTimeout:o}=e,{identity:n,items:l,meta:d,category:g}=i,u=Array.from(i.pageIdList||[]),c=Array.from(i.done||[]),f=Array.from(i.failed||[]);for(let e of l){let l;if(!(c.includes(e.key)||f.includes(e.key))){if(s())return a.aborted();if(o())return a.continue({...i,pageIdList:u,done:c,failed:f});try{l=await this.importPage({context:t,identity:n,item:e,meta:d,category:g}),u.push(l.pid),c.push(e.key)}catch(t){console.error(t),await r.addErrorLog({error:t,message:`Could not import page: ${e.key}.`,data:{...e}}),f.push(e.key);continue}await r.addInfoLog({message:`Page "${l.title}" imported successfully.`,data:{id:l.id,title:l.title,version:l.version,status:l.status}})}}return a.done({done:c,failed:f,pageIdList:u})}async importPage(e){let{context:t,identity:a,item:s,category:o,meta:n}=e;(0,r.mockSecurity)(a,t);let l=await (0,i.importPage)({context:t,pageKey:s.key,fileUploadsData:{data:s.data,assets:s.assets}}),d=await t.pageBuilder.createPage(o,n);return(0,r.mockSecurity)(a,t),await t.pageBuilder.updatePage(d.id,{content:l.content,title:l.title,path:l.path,settings:l.settings})}}},15e3:function(e,t,a){var i=a(15755).default;Object.defineProperty(t,"__esModule",{value:!0}),t.importPage=c;var r=i(a(71017)),s=i(a(72774)),o=i(a(71670)),n=a(10890),l=a(95248),d=a(88829),g=a(31299),u=a(28277);async function c({pageKey:e,context:t,fileUploadsData:a}){let i=console.log,c=r.default.join(d.INSTALL_EXTRACT_DIR,e);(0,n.ensureDirSync)(c);let f=s.default.get(a,"data"),m=r.default.join(c,r.default.basename(f));i(`Downloading Page data file: ${f} at "${m}"`);let p=await g.s3Stream.readStream(f),y=(0,n.createWriteStream)(m);await new Promise((e,t)=>{p.on("error",t).pipe(y).on("finish",e).on("error",t)}),i(`Load file ${f}`);let{page:P,files:w}=await (0,o.default)(m);if(w&&Array.isArray(w)&&w.length>0){let e=await (0,u.uploadAssets)({context:t,files:w,fileUploadsData:a}),{srcPrefix:i=""}=await t.fileManager.getSettings()||{};(0,u.updateFilesInData)({data:P.content||{},fileIdToNewFileMap:e,srcPrefix:i}),P.settings=function(e){let{settings:t,fileIdToNewFileMap:a,srcPrefix:i}=e,r=t,o=i.endsWith("/")?i.slice(0,-1):i;if(s.default.get(r,"general.image.src")){let e=a.get(t.general?.image?.id||"");e&&(r=s.default.set(r,"general.image.src",`${o}/${e.key}`))}if(s.default.get(r,"social.image.src")){let e=a.get(t.social?.image?.id||"");e&&(r=s.default.set(r,"social.image.src",`${o}/${e.key}`))}return r}({settings:P.settings||{},fileIdToNewFileMap:e,srcPrefix:i})}return i("Removing Directory for page..."),await (0,l.deleteFile)(e),i("Remove page contents from S3..."),await (0,u.deleteS3Folder)(r.default.dirname(a.data)),P}}};
//# sourceMappingURL=ImportPagesProcessPages.16dad213.chunk.js.map