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