"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unzip=unzip,exports.genZip=genZip,exports.archiveZip=archiveZip;const AdmZip=require("adm-zip"),fse=require("fs-extra"),archiver=require("archiver");async function unzip(e,r){return new Promise((i,t)=>{try{setTimeout(()=>{const n=new AdmZip(e),c=n.getEntries();for(const e of c){const r=e.entryName;/^\.\.(\\|\/)+/.test(r)&&t("illegal access"),/(\\|\/)+\.\.(\\|\/)+/.test(r)&&t("illegal access"),/(\\|\/)+\.\.$/.test(r)&&t("illegal access")}n.extractAllTo(r,!0),i({})},200)}catch(e){console.warn("@@@@@ [unzip] Fail. Error:",e),t(e)}})}function genZip(e,r){const i=new AdmZip;i.addLocalFolder(e),fse.writeFileSync(r,i.toBuffer())}function archiveZip(e,r){return new Promise((i,t)=>{const n=fse.createWriteStream(r),c=archiver("zip",{zlib:{level:9}});c.on("error",e=>{t(e)}),c.on("end",()=>{i({})}),c.pipe(n),c.directory(e,!1),c.finalize()})}