@checksum-ai/runtime 4.13.1 → 4.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +1 -1
- package/checksum-progress-reporter.js +3 -3
- package/cli.js +145 -140
- package/index.js +105 -105
- package/package.json +1 -1
- package/test-run-monitor.js +12 -7
package/package.json
CHANGED
package/test-run-monitor.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
"use strict";var wr=Object.create;var ce=Object.defineProperty;var Nr=Object.getOwnPropertyDescriptor;var xr=Object.getOwnPropertyNames;var Dr=Object.getPrototypeOf,Lr=Object.prototype.hasOwnProperty;var a=(t,e)=>ce(t,"name",{value:e,configurable:!0});var W=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Or=(t,e)=>{for(var r in e)ce(t,r,{get:e[r],enumerable:!0})},st=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of xr(e))!Lr.call(t,o)&&o!==r&&ce(t,o,{get:()=>e[o],enumerable:!(n=Nr(e,o))||n.enumerable});return t};var le=(t,e,r)=>(r=t!=null?wr(Dr(t)):{},st(e||!t||!t.__esModule?ce(r,"default",{value:t,enumerable:!0}):r,t)),Mr=t=>st(ce({},"__esModule",{value:!0}),t);var Le=W((yo,dt)=>{dt.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var he=W(ut=>{var pt={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Ur(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,n)=>e[n]||"")),new Error("ADM-ZIP: "+t)}}a(Ur,"E");for(let t of Object.keys(pt))ut[t]=Ur(pt[t])});var yt=W((Io,ht)=>{var Pr=require("fs"),U=require("path"),ft=Le(),Fr=he(),Br=typeof process=="object"&&process.platform==="win32",gt=a(t=>typeof t=="object"&&t!==null,"is_Obj"),mt=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function L(t){this.sep=U.sep,this.fs=Pr,gt(t)&>(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}a(L,"Utils");ht.exports=L;L.prototype.makeDir=function(t){let e=this;function r(n){let o=n.split(e.sep)[0];n.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var s;try{s=e.fs.statSync(o)}catch(l){if(l.message&&l.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw l}if(s&&s.isFile())throw Fr.FILE_IN_THE_WAY(`"${o}"`)}})}a(r,"mkdirSync"),r(t)};L.prototype.writeFileTo=function(t,e,r,n){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var s=U.dirname(t);o.fs.existsSync(s)||o.makeDir(s);var l;try{l=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),l=o.fs.openSync(t,"w",438)}if(l)try{o.fs.writeSync(l,e,0,e.length,0)}finally{o.fs.closeSync(l)}return o.fs.chmodSync(t,n||438),!0};L.prototype.writeFileToAsync=function(t,e,r,n,o){typeof n=="function"&&(o=n,n=void 0);let c=this;c.fs.exists(t,function(s){if(s&&!r)return o(!1);c.fs.stat(t,function(l,u){if(s&&u&&u.isDirectory())return o(!1);var g=U.dirname(t);c.fs.exists(g,function(y){if(!y)try{c.makeDir(g)}catch{return o(!1)}let T=a(function(v){c.fs.write(v,e,0,e.length,0,function(A){c.fs.close(v,function(){if(A)return o(!1);c.fs.chmod(t,n||438,function(){o(!0)})})})},"writeToFd");c.fs.open(t,"w",438,function(v,A){v?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(d,f){if(d||!f)return o(!1);T(f)})}):A?T(A):o(!1)})})})})};L.prototype.findFiles=function(t){let e=this;function r(n,o,c,s){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(n).forEach(function(u){let g=U.join(n,u),y=e.fs.statSync(g);if((!o||o.test(g))&&l.push(U.normalize(g)+(y.isDirectory()?e.sep:"")),y.isDirectory()&&c){let T=e.fs.realpathSync(g);s.has(T)||(s.add(T),l=l.concat(r(g,o,c,s)))}}),l}return a(r,"findSync"),r(t,void 0,!0,new Set([e.fs.realpathSync(t)]))};L.prototype.findFilesAsync=function(t,e){let r=this,n=[],o=!1,c=a(function(l){o||(o=!0,e(l,l?void 0:n))},"finish"),s=a(function(l,u,g){r.fs.readdir(l,function(y,T){if(y)return g(y);let v=T.length;if(!v)return g();T.forEach(function(A){let d=U.join(l,A);r.fs.stat(d,function(f,p){if(f)return g(f);if(!p){--v||g();return}if(n.push(U.normalize(d)+(p.isDirectory()?r.sep:"")),!p.isDirectory()){--v||g();return}r.fs.realpath(d,function(h,E){if(h)return g(h);if(u.has(E)){--v||g();return}u.add(E),s(d,u,function(i){if(i)return g(i);--v||g()})})})})})},"walk");r.fs.realpath(t,function(l,u){if(l)return c(l);s(t,new Set([u]),c)})};L.prototype.getAttributes=function(){};L.prototype.setAttributes=function(){};L.crc32update=function(t,e){return mt[(t^e)&255]^t>>>8};L.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let n=0;n<e;)r=L.crc32update(r,t[n++]);return~r>>>0};L.methodToString=function(t){switch(t){case ft.STORED:return"STORED ("+t+")";case ft.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};L.canonical=function(t){if(!t)return"";let e=U.posix.normalize("/"+t.split("\\").join("/"));return U.join(".",e)};L.zipnamefix=function(t){if(!t)return"";let e=U.posix.normalize("/"+t.split("\\").join("/"));return U.posix.join(".",e)};L.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let n=r-1;n>=0;n--)if(e(t[n],n,t))return t[n]};L.sanitize=function(t,e){t=U.resolve(U.normalize(t));for(var r=e.split("/"),n=0,o=r.length;n<o;n++){var c=U.normalize(U.join(t,r.slice(n,o).join(U.sep)));if(c===t||c.startsWith(t+U.sep))return c}return U.normalize(U.join(t,U.basename(e)))};L.toBuffer=a(function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)},"toBuffer");L.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};L.writeBigUInt64LE=function(t,e,r){let n=e>>>0,o=Math.floor(e/4294967296)>>>0;t.writeUInt32LE(n,r),t.writeUInt32LE(o,r+4)};L.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};L.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};L.isWin=Br;L.crcTable=mt});var Tt=W((Ro,Et)=>{var Hr=require("path");Et.exports=function(t,{fs:e}){var r=t||"",n=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return a(c,"newAttr"),r&&e.existsSync(r)?(o=e.statSync(r),n.directory=o.isDirectory(),n.mtime=o.mtime,n.atime=o.atime,n.executable=(73&o.mode)!==0,n.readonly=(128&o.mode)===0,n.hidden=Hr.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return n.directory},get readOnly(){return n.readonly},get hidden(){return n.hidden},get mtime(){return n.mtime},get atime(){return n.atime},get executable(){return n.executable},decodeAttributes:a(function(){},"decodeAttributes"),encodeAttributes:a(function(){},"encodeAttributes"),toJSON:a(function(){return{path:r,isDirectory:n.directory,isReadOnly:n.readonly,isHidden:n.hidden,isExecutable:n.executable,mTime:n.mtime,aTime:n.atime}},"toJSON"),toString:a(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var _t=W((Co,It)=>{It.exports={efs:!0,encode:a(t=>Buffer.from(t,"utf8"),"encode"),decode:a(t=>t.toString("utf8"),"decode")}});var ne=W((vo,re)=>{re.exports=yt();re.exports.Constants=Le();re.exports.Errors=he();re.exports.FileAttr=Tt();re.exports.decoder=_t()});var St=W((bo,Rt)=>{var q=ne(),I=q.Constants;Rt.exports=function(){var t=20,e=10,r=0,n=0,o=0,c=0,s=0,l=0,u=0,g=0,y=0,T=0,v=0,A=0,d=0;t|=q.isWin?2560:768,r|=I.FLG_EFS;let f={extraLen:0},p=a(i=>Math.max(0,i)>>>0,"uint32"),h=a(i=>Math.max(0,i)&65535,"uint16"),E=a(i=>Math.max(0,i)&255,"uint8");return o=q.fromDate2DOS(new Date),{get made(){return t},set made(i){t=i},get version(){return e},set version(i){e=i},get flags(){return r},set flags(i){r=i},get flags_efs(){return(r&I.FLG_EFS)>0},set flags_efs(i){i?r|=I.FLG_EFS:r&=~I.FLG_EFS},get flags_desc(){return(r&I.FLG_DESC)>0},set flags_desc(i){i?r|=I.FLG_DESC:r&=~I.FLG_DESC},get method(){return n},set method(i){switch(i){case I.STORED:this.version=10;break;case I.DEFLATED:default:this.version=20}n=i},get time(){return q.fromDOS2Date(this.timeval)},set time(i){i=new Date(i),this.timeval=q.fromDate2DOS(i)},get timeval(){return o},set timeval(i){o=p(i)},get timeHighByte(){return E(o>>>8)},get crc(){return c},set crc(i){c=p(i)},get compressedSize(){return s},set compressedSize(i){s=p(i)},get size(){return l},set size(i){l=p(i)},get fileNameLength(){return u},set fileNameLength(i){u=i},get extraLength(){return g},set extraLength(i){g=i},get extraLocalLength(){return f.extraLen},set extraLocalLength(i){f.extraLen=i},get commentLength(){return y},set commentLength(i){y=i},get diskNumStart(){return T},set diskNumStart(i){T=p(i)},get inAttr(){return v},set inAttr(i){v=p(i)},get attr(){return A},set attr(i){A=p(i)},get fileAttr(){return(A||0)>>16&4095},get offset(){return d},set offset(i){d=p(i)},get encrypted(){return(r&I.FLG_ENC)===I.FLG_ENC},get centralHeaderSize(){return I.CENHDR+u+g+y},get realDataOffset(){return d+I.LOCHDR+f.fnameLen+f.extraLen},get localHeader(){return f},loadLocalHeaderFromBinary:a(function(i){var m=i.slice(d,d+I.LOCHDR);if(m.readUInt32LE(0)!==I.LOCSIG)throw q.Errors.INVALID_LOC();f.version=m.readUInt16LE(I.LOCVER),f.flags=m.readUInt16LE(I.LOCFLG),f.flags_desc=(f.flags&I.FLG_DESC)>0,f.method=m.readUInt16LE(I.LOCHOW),f.time=m.readUInt32LE(I.LOCTIM),f.crc=m.readUInt32LE(I.LOCCRC),f.compressedSize=m.readUInt32LE(I.LOCSIZ),f.size=m.readUInt32LE(I.LOCLEN),f.fnameLen=m.readUInt16LE(I.LOCNAM),f.extraLen=m.readUInt16LE(I.LOCEXT);let R=d+I.LOCHDR+f.fnameLen,S=R+f.extraLen;return i.slice(R,S)},"loadLocalHeaderFromBinary"),loadFromBinary:a(function(i){if(i.length!==I.CENHDR||i.readUInt32LE(0)!==I.CENSIG)throw q.Errors.INVALID_CEN();t=i.readUInt16LE(I.CENVEM),e=i.readUInt16LE(I.CENVER),r=i.readUInt16LE(I.CENFLG),n=i.readUInt16LE(I.CENHOW),o=i.readUInt32LE(I.CENTIM),c=i.readUInt32LE(I.CENCRC),s=i.readUInt32LE(I.CENSIZ),l=i.readUInt32LE(I.CENLEN),u=i.readUInt16LE(I.CENNAM),g=i.readUInt16LE(I.CENEXT),y=i.readUInt16LE(I.CENCOM),T=i.readUInt16LE(I.CENDSK),v=i.readUInt16LE(I.CENATT),A=i.readUInt32LE(I.CENATX),d=i.readUInt32LE(I.CENOFF)},"loadFromBinary"),localHeaderToBinary:a(function(){var i=Buffer.alloc(I.LOCHDR);return i.writeUInt32LE(I.LOCSIG,0),i.writeUInt16LE(e,I.LOCVER),i.writeUInt16LE(r&~I.FLG_DESC,I.LOCFLG),i.writeUInt16LE(n,I.LOCHOW),i.writeUInt32LE(o,I.LOCTIM),i.writeUInt32LE(c,I.LOCCRC),i.writeUInt32LE(s,I.LOCSIZ),i.writeUInt32LE(l,I.LOCLEN),i.writeUInt16LE(u,I.LOCNAM),i.writeUInt16LE(f.extraLen,I.LOCEXT),i},"localHeaderToBinary"),centralHeaderToBinary:a(function(){var i=Buffer.alloc(I.CENHDR+u+g+y);return i.writeUInt32LE(I.CENSIG,0),i.writeUInt16LE(t,I.CENVEM),i.writeUInt16LE(e,I.CENVER),i.writeUInt16LE(r&~I.FLG_DESC,I.CENFLG),i.writeUInt16LE(n,I.CENHOW),i.writeUInt32LE(o,I.CENTIM),i.writeUInt32LE(c,I.CENCRC),i.writeUInt32LE(s,I.CENSIZ),i.writeUInt32LE(l,I.CENLEN),i.writeUInt16LE(u,I.CENNAM),i.writeUInt16LE(g,I.CENEXT),i.writeUInt16LE(y,I.CENCOM),i.writeUInt16LE(T,I.CENDSK),i.writeUInt16LE(v,I.CENATT),i.writeUInt32LE(A,I.CENATX),i.writeUInt32LE(d,I.CENOFF),i},"centralHeaderToBinary"),toJSON:a(function(){let i=a(function(m){return m+" bytes"},"bytes");return{made:t,version:e,flags:r,method:q.methodToString(n),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:i(s),size:i(l),fileNameLength:i(u),extraLength:i(g),commentLength:i(y),diskNumStart:T,inAttr:v,attr:A,offset:d,centralHeaderSize:i(I.CENHDR+u+g+y)}},"toJSON"),toString:a(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var At=W((No,Ct)=>{var K=ne(),C=K.Constants;Ct.exports=function(){var t=0,e=0,r=0,n=0,o=0;let c=a(()=>t>C.EF_ZIP64_OR_16||e>C.EF_ZIP64_OR_16||r>C.EF_ZIP64_OR_32||n>C.EF_ZIP64_OR_32,"needsZip64");return{get diskEntries(){return t},set diskEntries(s){t=e=s},get totalEntries(){return e},set totalEntries(s){e=t=s},get size(){return r},set size(s){r=s},get offset(){return n},set offset(s){n=s},get commentLength(){return o},set commentLength(s){o=s},get mainHeaderSize(){return(c()?C.ZIP64HDR+C.END64HDR:0)+C.ENDHDR+o},loadFromBinary:a(function(s){if((s.length!==C.ENDHDR||s.readUInt32LE(0)!==C.ENDSIG)&&(s.length<C.ZIP64HDR||s.readUInt32LE(0)!==C.ZIP64SIG))throw K.Errors.INVALID_END();s.readUInt32LE(0)===C.ENDSIG?(t=s.readUInt16LE(C.ENDSUB),e=s.readUInt16LE(C.ENDTOT),r=s.readUInt32LE(C.ENDSIZ),n=s.readUInt32LE(C.ENDOFF),o=s.readUInt16LE(C.ENDCOM)):(t=K.readBigUInt64LE(s,C.ZIP64SUB),e=K.readBigUInt64LE(s,C.ZIP64TOT),r=K.readBigUInt64LE(s,C.ZIP64SIZB),n=K.readBigUInt64LE(s,C.ZIP64OFF),o=0)},"loadFromBinary"),toBinary:a(function(){if(!c()){var s=Buffer.alloc(C.ENDHDR+o);return s.writeUInt32LE(C.ENDSIG,0),s.writeUInt32LE(0,4),s.writeUInt16LE(t,C.ENDSUB),s.writeUInt16LE(e,C.ENDTOT),s.writeUInt32LE(r,C.ENDSIZ),s.writeUInt32LE(n,C.ENDOFF),s.writeUInt16LE(o,C.ENDCOM),s.fill(" ",C.ENDHDR),s}var s=Buffer.alloc(this.mainHeaderSize);let l=0;s.writeUInt32LE(C.ZIP64SIG,l),K.writeBigUInt64LE(s,C.ZIP64HDR-C.ZIP64LEAD,l+C.ZIP64SIZE),s.writeUInt16LE(45,l+C.ZIP64VEM),s.writeUInt16LE(45,l+C.ZIP64VER),s.writeUInt32LE(0,l+C.ZIP64DSK),s.writeUInt32LE(0,l+C.ZIP64DSKDIR),K.writeBigUInt64LE(s,t,l+C.ZIP64SUB),K.writeBigUInt64LE(s,e,l+C.ZIP64TOT),K.writeBigUInt64LE(s,r,l+C.ZIP64SIZB),K.writeBigUInt64LE(s,n,l+C.ZIP64OFF);let u=n+r;return l+=C.ZIP64HDR,s.writeUInt32LE(C.END64SIG,l),s.writeUInt32LE(0,l+C.END64START),K.writeBigUInt64LE(s,u,l+C.END64OFF),s.writeUInt32LE(1,l+C.END64NUMDISKS),l+=C.END64HDR,s.writeUInt32LE(C.ENDSIG,l),s.writeUInt32LE(0,l+4),s.writeUInt16LE(Math.min(t,C.EF_ZIP64_OR_16),l+C.ENDSUB),s.writeUInt16LE(Math.min(e,C.EF_ZIP64_OR_16),l+C.ENDTOT),s.writeUInt32LE(Math.min(r,C.EF_ZIP64_OR_32),l+C.ENDSIZ),s.writeUInt32LE(Math.min(n,C.EF_ZIP64_OR_32),l+C.ENDOFF),s.writeUInt16LE(o,l+C.ENDCOM),s.fill(" ",l+C.ENDHDR),s},"toBinary"),toJSON:a(function(){let s=a(function(l,u){let g=l.toString(16).toUpperCase();for(;g.length<u;)g="0"+g;return"0x"+g},"offset");return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:s(n,4),commentLength:o}},"toJSON"),toString:a(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var Me=W(Oe=>{Oe.EntryHeader=St();Oe.MainHeader=At()});var bt=W((Lo,vt)=>{vt.exports=function(t){var e=require("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:a(function(){return e.deflateRawSync(t,r)},"deflate"),deflateAsync:a(function(n){var o=e.createDeflateRaw(r),c=[],s=0;o.on("data",function(l){c.push(l),s+=l.length}),o.on("end",function(){var l=Buffer.alloc(s),u=0;l.fill(0);for(var g=0;g<c.length;g++){var y=c[g];y.copy(l,u),u+=y.length}n&&n(l)}),o.end(t)},"deflateAsync")}}});var xt=W((Mo,Nt)=>{var wt,Wr=+(((wt=process==null?void 0:process.versions)==null?void 0:wt.node)??"").split(".")[0]||0;Nt.exports=function(t,e){var r=require("zlib");let n=Wr>=15&&e>0?{maxOutputLength:e}:{};return{inflate:a(function(){return r.inflateRawSync(t,n)},"inflate"),inflateAsync:a(function(o){var c=r.createInflateRaw(n),s=[],l=0;c.on("data",function(u){s.push(u),l+=u.length}),c.on("end",function(){var u=Buffer.alloc(l),g=0;u.fill(0);for(var y=0;y<s.length;y++){var T=s[y];T.copy(u,g),g+=T.length}o&&o(u)}),c.end(t)},"inflateAsync")}}});var kt=W((Uo,Mt)=>{"use strict";var{randomFillSync:Dt}=require("crypto"),$r=he(),Gr=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Ot=a((t,e)=>Math.imul(t,e)>>>0,"uMul"),Lt=a((t,e)=>Gr[(t^e)&255]^t>>>8,"crc32update"),de=a(()=>typeof Dt=="function"?Dt(Buffer.alloc(12)):de.node(),"genSalt");de.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var ye={genSalt:de};function Ee(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}a(Ee,"Initkeys");Ee.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Lt(e[0],t),e[1]+=e[0]&255,e[1]=Ot(e[1],134775813)+1,e[2]=Lt(e[2],e[1]>>>24),t};Ee.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Ot(t,t^1)>>8&255};function Zr(t){let e=new Ee(t);return function(r){let n=Buffer.alloc(r.length),o=0;for(let c of r)n[o++]=e.updateKeys(c^e.next());return n}}a(Zr,"make_decrypter");function Vr(t){let e=new Ee(t);return function(r,n,o=0){n||(n=Buffer.alloc(r.length));for(let c of r){let s=e.next();n[o++]=c^s,e.updateKeys(c)}return n}}a(Vr,"make_encrypter");function jr(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let n=Zr(r),o=n(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw $r.WRONG_PASSWORD();return n(t.slice(12))}a(jr,"decrypt");function Kr(t){Buffer.isBuffer(t)&&t.length>=12?ye.genSalt=function(){return t.slice(0,12)}:t==="node"?ye.genSalt=de.node:ye.genSalt=de}a(Kr,"_salter");function zr(t,e,r,n=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Vr(r),c=ye.genSalt();c[11]=e.crc>>>24&255,n&&(c[10]=e.crc>>>16&255);let s=Buffer.alloc(t.length+12);return o(c,s),o(t,s,12)}a(zr,"encrypt");Mt.exports={decrypt:jr,encrypt:zr,_salter:Kr}});var Ut=W(Te=>{Te.Deflater=bt();Te.Inflater=xt();Te.ZipCrypto=kt()});var Ue=W((Bo,Pt)=>{var D=ne(),Jr=Me(),j=D.Constants,ke=Ut();Pt.exports=function(t,e){var r=new Jr.EntryHeader,n=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,s=null,l=Buffer.alloc(0),u=Buffer.alloc(0),g=!0;let y=t,T=typeof y.decoder=="object"?y.decoder:D.decoder;g=T.hasOwnProperty("efs")?T.efs:!1;function v(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(u=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}a(v,"getCompressedDataFromZip");function A(i){let m=r.flags_desc||r.localHeader.flags_desc?r.crc:r.localHeader.crc;return D.crc32(i)===m}a(A,"crc32OK");function d(i,m,R){if(typeof m>"u"&&typeof i=="string"&&(R=i,i=void 0),c)return i&&m&&m(Buffer.alloc(0),D.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var S=v();if(S.length===0)return i&&m&&m(S),S;if(r.encrypted){if(typeof R!="string"&&!Buffer.isBuffer(R))throw D.Errors.INVALID_PASS_PARAM();S=ke.ZipCrypto.decrypt(S,r,R)}var _;switch(r.method){case D.Constants.STORED:if(_=Buffer.alloc(S.length),S.copy(_),A(_))return i&&m&&m(_),_;throw i&&m&&m(_,D.Errors.BAD_CRC()),D.Errors.BAD_CRC();case D.Constants.DEFLATED:var b=new ke.Inflater(S,r.size);if(i)b.inflateAsync(function(w){m&&(A(w)?m(w):m(w,D.Errors.BAD_CRC()))});else{if(_=b.inflate(),!A(_))throw D.Errors.BAD_CRC(`"${T.decode(n)}"`);return _}break;default:throw i&&m&&m(Buffer.alloc(0),D.Errors.UNKNOWN_METHOD()),D.Errors.UNKNOWN_METHOD()}}a(d,"decompress");function f(i,m){if((!s||!s.length)&&Buffer.isBuffer(e))return i&&m&&m(v()),v();if(s.length&&!c){var R;switch(r.method){case D.Constants.STORED:return r.compressedSize=r.size,R=Buffer.alloc(s.length),s.copy(R),i&&m&&m(R),R;default:case D.Constants.DEFLATED:var S=new ke.Deflater(s);if(i)S.deflateAsync(function(b){R=Buffer.alloc(b.length),r.compressedSize=b.length,b.copy(R),m&&m(R)});else{var _=S.deflate();return r.compressedSize=_.length,_}S=null;break}}else if(i&&m)m(Buffer.alloc(0));else return Buffer.alloc(0)}a(f,"compress");function p(i,m){return D.readBigUInt64LE(i,m)}a(p,"readUInt64LE");function h(i){try{for(var m=0,R,S,_;m+4<i.length;)R=i.readUInt16LE(m),m+=2,S=i.readUInt16LE(m),m+=2,_=i.slice(m,m+S),m+=S,j.ID_ZIP64===R&&E(_)}catch{throw D.Errors.EXTRA_FIELD_PARSE_ERROR()}}a(h,"parseExtra");function E(i){var m,R,S,_;i.length>=j.EF_ZIP64_SCOMP&&(m=p(i,j.EF_ZIP64_SUNCOMP),r.size===j.EF_ZIP64_OR_32&&(r.size=m)),i.length>=j.EF_ZIP64_RHO&&(R=p(i,j.EF_ZIP64_SCOMP),r.compressedSize===j.EF_ZIP64_OR_32&&(r.compressedSize=R)),i.length>=j.EF_ZIP64_DSN&&(S=p(i,j.EF_ZIP64_RHO),r.offset===j.EF_ZIP64_OR_32&&(r.offset=S)),i.length>=j.EF_ZIP64_DSN+4&&(_=i.readUInt32LE(j.EF_ZIP64_DSN),r.diskNumStart===j.EF_ZIP64_OR_16&&(r.diskNumStart=_))}return a(E,"parseZip64ExtendedInformation"),{get entryName(){return T.decode(n)},get rawEntryName(){return n},set entryName(i){n=D.toBuffer(i,T.encode);var m=n[n.length-1];c=m===47||m===92,r.fileNameLength=n.length},get efs(){return typeof g=="function"?g(this.entryName):g},get extra(){return l},set extra(i){l=i,r.extraLength=i.length,h(i)},get comment(){return T.decode(o)},set comment(i){if(o=D.toBuffer(i,T.encode),r.commentLength=o.length,o.length>65535)throw D.Errors.COMMENT_TOO_LONG()},get name(){let i=T.decode(n);return c?i.replace(/[/\\]$/,"").split("/").pop():i.split("/").pop()},get isDirectory(){return c},getCompressedData:a(function(){return f(!1,null)},"getCompressedData"),getCompressedDataAsync:a(function(i){f(!0,i)},"getCompressedDataAsync"),setData:a(function(i){s=D.toBuffer(i,D.decoder.encode),!c&&s.length?(r.size=s.length,r.method=D.Constants.DEFLATED,r.crc=D.crc32(i),r.changed=!0):r.method=D.Constants.STORED},"setData"),getData:a(function(i){return r.changed?s:d(!1,null,i)},"getData"),getDataAsync:a(function(i,m){r.changed?i(s):d(!0,i,m)},"getDataAsync"),set attr(i){r.attr=i},get attr(){return r.attr},set header(i){r.loadFromBinary(i)},get header(){return r},packCentralHeader:a(function(){r.flags_efs=this.efs,r.extraLength=l.length;var i=r.centralHeaderToBinary(),m=D.Constants.CENHDR;return n.copy(i,m),m+=n.length,l.copy(i,m),m+=r.extraLength,o.copy(i,m),i},"packCentralHeader"),packLocalHeader:a(function(){let i=0;r.flags_efs=this.efs,r.extraLocalLength=u.length;let m=r.localHeaderToBinary(),R=Buffer.alloc(m.length+n.length+r.extraLocalLength);return m.copy(R,i),i+=m.length,n.copy(R,i),i+=n.length,u.copy(R,i),i+=u.length,R},"packLocalHeader"),toJSON:a(function(){let i=a(function(m){return"<"+(m&&m.length+" bytes buffer"||"null")+">"},"bytes");return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:i(e),data:i(s)}},"toJSON"),toString:a(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var Ht=W((Wo,Bt)=>{var Ft=Ue(),Yr=Me(),G=ne();Bt.exports=function(t,e){var r=[],n=Object.create(null),o=Buffer.alloc(0),c=new Yr.MainHeader,s=!1,l=null;let u=new Set,g=e,{noSort:y,decoder:T}=g;t?d(g.readEntries):s=!0;function v(){let p=new Set;for(let h of Object.keys(n)){let E=h.split("/");if(E.pop(),!!E.length)for(let i=0;i<E.length;i++){let m=E.slice(0,i+1).join("/")+"/";p.add(m)}}for(let h of p)if(!(h in n)){let E=new Ft(g);E.entryName=h,E.attr=16,E.temporary=!0,r.push(E),n[E.entryName]=E,u.add(E)}}a(v,"makeTemporaryFolders");function A(){if(s=!0,n=Object.create(null),c.diskEntries>(t.length-c.offset)/G.Constants.CENHDR)throw G.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var p=c.offset,h=0;h<r.length;h++){var E=p,i=new Ft(g,t);i.header=t.slice(E,E+=G.Constants.CENHDR),i.entryName=t.slice(E,E+=i.header.fileNameLength),i.header.extraLength&&(i.extra=t.slice(E,E+=i.header.extraLength)),i.header.commentLength&&(i.comment=t.slice(E,E+i.header.commentLength)),p+=i.header.centralHeaderSize,r[h]=i,n[i.entryName]=i}u.clear(),v()}a(A,"readEntries");function d(p){var h=t.length-G.Constants.ENDHDR,E=Math.max(0,h-65535),i=E,m=t.length,R=-1,S=0;for(typeof g.trailingSpace=="boolean"&&g.trailingSpace&&(E=0),h;h>=i;h--)if(t[h]===80){if(t.readUInt32LE(h)===G.Constants.ENDSIG){R=h,S=h,m=h+G.Constants.ENDHDR,i=h-G.Constants.END64HDR;continue}if(t.readUInt32LE(h)===G.Constants.END64SIG){i=E;continue}if(t.readUInt32LE(h)===G.Constants.ZIP64SIG){R=h,m=h+G.readBigUInt64LE(t,h+G.Constants.ZIP64SIZE)+G.Constants.ZIP64LEAD;break}}if(R==-1)throw G.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(R,m)),c.commentLength&&(o=t.slice(S+G.Constants.ENDHDR)),p&&A()}a(d,"readMainHeader");function f(){r.length>1&&!y&&(r=r.map(p=>({entry:p,key:p.entryName.toLowerCase()})).sort((p,h)=>p.key.localeCompare(h.key)).map(p=>p.entry))}return a(f,"sortEntries"),{get entries(){return s||A(),r.filter(p=>!u.has(p))},get comment(){return T.decode(o)},set comment(p){o=G.toBuffer(p,T.encode),c.commentLength=o.length},getEntryCount:a(function(){return s?r.length:c.diskEntries},"getEntryCount"),forEach:a(function(p){this.entries.forEach(p)},"forEach"),getEntry:a(function(p){return s||A(),n[p]||null},"getEntry"),setEntry:a(function(p){s||A(),r.push(p),n[p.entryName]=p,c.totalEntries=r.length},"setEntry"),deleteFile:a(function(p,h=!0){s||A();let E=n[p];this.getEntryChildren(E,h).map(m=>m.entryName).forEach(this.deleteEntry)},"deleteFile"),deleteEntry:a(function(p){s||A();let h=n[p],E=r.indexOf(h);E>=0&&(r.splice(E,1),delete n[p],c.totalEntries=r.length)},"deleteEntry"),getEntryChildren:a(function(p,h=!0){if(s||A(),typeof p=="object")if(p.isDirectory&&h){let E=[],i=p.entryName;for(let m of r)m.entryName.startsWith(i)&&E.push(m);return E}else return[p];return[]},"getEntryChildren"),getChildCount:a(function(p){if(p&&p.isDirectory){let h=this.getEntryChildren(p);return h.includes(p)?h.length-1:h.length}return 0},"getChildCount"),compressToBuffer:a(function(){s||A(),f();let p=[],h=[],E=0,i=0;c.size=0,c.offset=0;let m=0;for(let _ of this.entries){let b=_.getCompressedData();_.header.offset=i;let w=_.packLocalHeader(),N=w.length+b.length;i+=N,p.push(w),p.push(b);let x=_.packCentralHeader();h.push(x),c.size+=x.length,E+=N+x.length,m++}E+=c.mainHeaderSize,c.offset=i,c.totalEntries=m,i=0;let R=Buffer.alloc(E);for(let _ of p)_.copy(R,i),i+=_.length;for(let _ of h)_.copy(R,i),i+=_.length;let S=c.toBinary();return o&&o.copy(S,S.length-o.length),S.copy(R,i),t=R,s=!1,R},"compressToBuffer"),toAsyncBuffer:a(function(p,h,E,i){try{s||A(),f();let m=[],R=[],S=0,_=0,b=0;c.size=0,c.offset=0;let w=a(function(N){if(N.length>0){let x=N.shift(),H=x.entryName+x.extra.toString();E&&E(H),x.getCompressedDataAsync(function($){i&&i(H),x.header.offset=_;let X=x.packLocalHeader(),me=X.length+$.length;_+=me,m.push(X),m.push($);let ae=x.packCentralHeader();R.push(ae),c.size+=ae.length,S+=me+ae.length,b++,w(N)})}else{S+=c.mainHeaderSize,c.offset=_,c.totalEntries=b,_=0;let x=Buffer.alloc(S);m.forEach(function($){$.copy(x,_),_+=$.length}),R.forEach(function($){$.copy(x,_),_+=$.length});let H=c.toBinary();o&&o.copy(H,H.length-o.length),H.copy(x,_),t=x,s=!1,p(x)}},"compress2Buffer");w(Array.from(this.entries))}catch(m){h(m)}},"toAsyncBuffer")}}});var Gt=W((Go,$t)=>{var M=ne(),O=require("path"),qr=Ue(),Xr=Ht(),Q=a((...t)=>M.findLast(t,e=>typeof e=="boolean"),"get_Bool"),Wt=a((...t)=>M.findLast(t,e=>typeof e=="string"),"get_Str"),Qr=a((...t)=>M.findLast(t,e=>typeof e=="function"),"get_Fun"),en={noSort:!1,readEntries:!1,method:M.Constants.NONE,fs:null};$t.exports=function(t,e){let r=null,n=Object.assign(Object.create(null),en);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(n,t),t=n.input?n.input:void 0,n.input&&delete n.input),Buffer.isBuffer(t)&&(r=t,n.method=M.Constants.BUFFER,t=void 0)),Object.assign(n,e);let o=new M(n),c=a(d=>{d.filter(f=>f.attr).sort((f,p)=>p.path.length-f.path.length).forEach(f=>o.fs.chmodSync(f.path,f.attr))},"applyDirAttributes");if((typeof n.decoder!="object"||typeof n.decoder.encode!="function"||typeof n.decoder.decode!="function")&&(n.decoder=M.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))n.method=M.Constants.FILE,n.filename=t,r=o.fs.readFileSync(t);else throw M.Errors.INVALID_FILENAME();let s=new Xr(r,n),{canonical:l,sanitize:u,zipnamefix:g}=M;function y(d){if(d&&s){var f;if(typeof d=="string"&&(f=s.getEntry(O.posix.normalize(d))),typeof d=="object"&&typeof d.entryName<"u"&&typeof d.header<"u"&&(f=s.getEntry(d.entryName)),f)return f}return null}a(y,"getEntry");function T(d){let{join:f,normalize:p,sep:h}=O.posix;return f(O.isAbsolute(d)?"/":".",p(h+d.split("\\").join(h)+h))}a(T,"fixPath");function v(d){return d instanceof RegExp?(function(f){return function(p){return f.test(p)}})(d):typeof d!="function"?()=>!0:d}a(v,"filenameFilter");let A=a((d,f)=>{let p=f.slice(-1);return p=p===o.sep?o.sep:"",O.relative(d,f)+p},"relativePath");return{readFile:a(function(d,f){var p=y(d);return p&&p.getData(f)||null},"readFile"),childCount:a(function(d){let f=y(d);if(f)return s.getChildCount(f)},"childCount"),readFileAsync:a(function(d,f){var p=y(d);p?p.getDataAsync(f):f(null,"getEntry failed for:"+d)},"readFileAsync"),readAsText:a(function(d,f){var p=y(d);if(p){var h=p.getData();if(h&&h.length)return h.toString(f||"utf8")}return""},"readAsText"),readAsTextAsync:a(function(d,f,p){var h=y(d);h?h.getDataAsync(function(E,i){if(i){f(E,i);return}E&&E.length?f(E.toString(p||"utf8")):f("")}):f("")},"readAsTextAsync"),deleteFile:a(function(d,f=!0){var p=y(d);p&&s.deleteFile(p.entryName,f)},"deleteFile"),deleteEntry:a(function(d){var f=y(d);f&&s.deleteEntry(f.entryName)},"deleteEntry"),addZipComment:a(function(d){s.comment=d},"addZipComment"),getZipComment:a(function(){return s.comment||""},"getZipComment"),addZipEntryComment:a(function(d,f){var p=y(d);p&&(p.comment=f)},"addZipEntryComment"),getZipEntryComment:a(function(d){var f=y(d);return f&&f.comment||""},"getZipEntryComment"),updateFile:a(function(d,f){var p=y(d);p&&p.setData(f)},"updateFile"),addLocalFile:a(function(d,f,p,h){if(o.fs.existsSync(d)){f=f?T(f):"";let E=O.win32.basename(O.win32.normalize(d));f+=p||E;let i=o.fs.statSync(d),m=i.isFile()?o.fs.readFileSync(d):Buffer.alloc(0);i.isDirectory()&&(f+=o.sep),this.addFile(f,m,h,i)}else throw M.Errors.FILE_NOT_FOUND(d)},"addLocalFile"),addLocalFileAsync:a(function(d,f){d=typeof d=="object"?d:{localPath:d};let p=O.resolve(d.localPath),{comment:h}=d,{zipPath:E,zipName:i}=d,m=this;o.fs.stat(p,function(R,S){if(R)return f(R,!1);E=E?T(E):"";let _=O.win32.basename(O.win32.normalize(p));if(E+=i||_,S.isFile())o.fs.readFile(p,function(b,w){return b?f(b,!1):(m.addFile(E,w,h,S),setImmediate(f,void 0,!0))});else if(S.isDirectory())return E+=o.sep,m.addFile(E,Buffer.alloc(0),h,S),setImmediate(f,void 0,!0)})},"addLocalFileAsync"),addLocalFolder:a(function(d,f,p){if(p=v(p),f=f?T(f):"",d=O.normalize(d),o.fs.existsSync(d)){let h=o.findFiles(d),E=this;if(h.length)for(let i of h){let m=O.join(f,A(d,i));p(m)&&E.addLocalFile(i,O.dirname(m))}}else throw M.Errors.FILE_NOT_FOUND(d)},"addLocalFolder"),addLocalFolderAsync:a(function(d,f,p,h){h=v(h),p=p?T(p):"",d=O.normalize(d);var E=this;o.fs.open(d,"r",function(i){if(i&&i.code==="ENOENT")f(void 0,M.Errors.FILE_NOT_FOUND(d));else if(i)f(void 0,i);else{var m=o.findFiles(d),R=-1,S=a(function(){if(R+=1,R<m.length){var _=m[R],b=A(d,_).split("\\").join("/");b=b.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),h(b)?o.fs.stat(_,function(w,N){w&&f(void 0,w),N.isFile()?o.fs.readFile(_,function(x,H){x?f(void 0,x):(E.addFile(p+b,H,"",N),S())}):(E.addFile(p+b+"/",Buffer.alloc(0),"",N),S())}):process.nextTick(()=>{S()})}else f(!0,void 0)},"next");S()}})},"addLocalFolderAsync"),addLocalFolderAsync2:a(function(d,f){let p=this;d=typeof d=="object"?d:{localPath:d};let h=O.resolve(T(d.localPath)),{zipPath:E,filter:i,namefix:m}=d;i instanceof RegExp?i=(function(_){return function(b){return _.test(b)}})(i):typeof i!="function"&&(i=a(function(){return!0},"filter")),E=E?T(E):"",m==="latin1"&&(m=a(_=>_.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),"namefix")),typeof m!="function"&&(m=a(_=>_,"namefix"));let R=a(_=>O.join(E,m(A(h,_))),"relPathFix"),S=a(_=>O.win32.basename(O.win32.normalize(m(_))),"fileNameFix");o.fs.open(h,"r",function(_){_&&_.code==="ENOENT"?f(void 0,M.Errors.FILE_NOT_FOUND(h)):_?f(void 0,_):o.findFilesAsync(h,function(b,w){if(b)return f(b);w=w.filter(N=>i(R(N))),w.length||f(void 0,!1),setImmediate(w.reverse().reduce(function(N,x){return function(H,$){if(H||$===!1)return setImmediate(N,H,!1);p.addLocalFileAsync({localPath:x,zipPath:O.dirname(R(x)),zipName:S(x)},N)}},f))})})},"addLocalFolderAsync2"),addLocalFolderPromise:a(function(d,f){return new Promise((p,h)=>{this.addLocalFolderAsync2(Object.assign({localPath:d},f),(E,i)=>{E&&h(E),i&&p(this)})})},"addLocalFolderPromise"),addFile:a(function(d,f,p,h){d=g(d);let E=y(d),i=E!=null;i||(E=new qr(n),E.entryName=d),E.comment=p||"";let m=typeof h=="object"&&h instanceof o.fs.Stats;m&&(E.header.time=h.mtime);var R=E.isDirectory?16:0;let S=E.isDirectory?16384:32768;return m?S|=4095&h.mode:typeof h=="number"?S|=4095&h:S|=E.isDirectory?493:420,R=(R|S<<16)>>>0,E.attr=R,E.setData(f),i||s.setEntry(E),E},"addFile"),getEntries:a(function(d){return s.password=d,s?s.entries:[]},"getEntries"),getEntry:a(function(d){return y(d)},"getEntry"),getEntryCount:a(function(){return s.getEntryCount()},"getEntryCount"),forEach:a(function(d){return s.forEach(d)},"forEach"),extractEntryTo:a(function(d,f,p,h,E,i){h=Q(!1,h),E=Q(!1,E),p=Q(!0,p),i=Wt(E,i);var m=y(d);if(!m)throw M.Errors.NO_ENTRY();var R=l(m.entryName),S=u(f,i&&!m.isDirectory?l(i):p?R:O.basename(R));if(m.isDirectory){var _=s.getEntryChildren(m);return _.forEach(function(N){if(N.isDirectory)return;var x=N.getData();if(!x)throw M.Errors.CANT_EXTRACT_FILE();var H=l(p?N.entryName:N.entryName.substring(m.entryName.length)),$=u(f,H);let X=E?N.header.fileAttr:void 0;o.writeFileTo($,x,h,X)}),!0}var b=m.getData(s.password);if(!b)throw M.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(S)&&!h)throw M.Errors.CANT_OVERRIDE();let w=E?d.header.fileAttr:void 0;return o.writeFileTo(S,b,h,w),!0},"extractEntryTo"),test:a(function(d){if(!s)return!1;for(var f of s.entries)try{if(f.isDirectory)continue;var p=f.getData(d);if(!p)return!1}catch{return!1}return!0},"test"),extractAllTo:a(function(d,f,p,h){if(p=Q(!1,p),h=Wt(p,h),f=Q(!1,f),!s)throw M.Errors.NO_ZIP();let E=[];s.entries.forEach(function(i){var m=u(d,l(i.entryName));if(i.isDirectory){o.makeDir(m),p&&E.push({path:m,attr:i.header.fileAttr});return}var R=i.getData(h);if(!R)throw M.Errors.CANT_EXTRACT_FILE();let S=p?i.header.fileAttr:void 0;o.writeFileTo(m,R,f,S);try{o.fs.utimesSync(m,i.header.time,i.header.time)}catch{}}),c(E)},"extractAllTo"),extractAllToAsync:a(function(d,f,p,h){if(h=Qr(f,p,h),p=Q(!1,p),f=Q(!1,f),!h)return new Promise((b,w)=>{this.extractAllToAsync(d,f,p,function(N){N?w(N):b(this)})});if(!s){h(M.Errors.NO_ZIP());return}d=O.resolve(d);let E=a(b=>u(d,O.normalize(l(b.entryName))),"getPath"),i=a((b,w)=>new Error(b+': "'+w+'"'),"getError"),m=[],R=[];s.entries.forEach(b=>{b.isDirectory?m.push(b):R.push(b)});let S=[];for(let b of m){let w=E(b),N=p?b.header.fileAttr:void 0;try{o.makeDir(w)}catch{h(i("Unable to create folder",w));continue}N&&S.push({path:w,attr:N});try{o.fs.utimesSync(w,b.header.time,b.header.time)}catch{}}let _=a(b=>{if(!b)try{c(S)}catch(w){return h(i("Unable to set folder permissions",w.path||""))}h(b)},"done");R.reverse().reduce(function(b,w){return function(N){if(N)b(N);else{let x=O.normalize(l(w.entryName)),H=u(d,x);w.getDataAsync(function($,X){if(X)b(X);else if(!$)b(M.Errors.CANT_EXTRACT_FILE());else{let me=p?w.header.fileAttr:void 0;o.writeFileToAsync(H,$,f,me,function(ae){if(!ae)return b(i("Unable to write file",H));o.fs.utimes(H,w.header.time,w.header.time,function(){b()})})}})}}},_)()},"extractAllToAsync"),writeZip:a(function(d,f){if(arguments.length===1&&typeof d=="function"&&(f=d,d=""),!d&&n.filename&&(d=n.filename),!!d){var p=s.compressToBuffer();if(p){var h=o.writeFileTo(d,p,!0);typeof f=="function"&&f(h?null:new Error("failed"),"")}}},"writeZip"),writeZipPromise:a(function(d,f){let{overwrite:p,perm:h}=Object.assign({overwrite:!0},f);return new Promise((E,i)=>{!d&&n.filename&&(d=n.filename),d||i("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(m=>{let R=a(S=>S?E(S):i("ADM-ZIP: Wasn't able to write zip file"),"ret");o.writeFileToAsync(d,m,p,h,R)},i)})},"writeZipPromise"),toBufferPromise:a(function(){return new Promise((d,f)=>{s.toAsyncBuffer(d,f)})},"toBufferPromise"),toBuffer:a(function(d,f,p,h){return typeof d=="function"?(s.toAsyncBuffer(d,f,p,h),null):s.compressToBuffer()},"toBuffer")}}});var Yt=W((Ko,z)=>{var Fe=require("fs"),_e=require("path"),rn=require("os"),nn=require("crypto"),Vt=["\u25C8 encrypted .env [www.dotenvx.com]","\u25C8 secrets for agents [www.dotenvx.com]","\u2301 auth for agents [www.vestauth.com]","\u2318 custom filepath { path: '/custom/path/.env' }","\u2318 enable debugging { debug: true }","\u2318 override existing { override: true }","\u2318 suppress logs { quiet: true }","\u2318 multiple files { path: ['.env.local', '.env'] }"];function on(){return Vt[Math.floor(Math.random()*Vt.length)]}a(on,"_getRandomTip");function oe(t){return typeof t=="string"?!["false","0","no","off",""].includes(t.toLowerCase()):!!t}a(oe,"parseBoolean");function sn(){return process.stdout.isTTY}a(sn,"supportsAnsi");function an(t){return sn()?`\x1B[2m${t}\x1B[0m`:t}a(an,"dim");var cn=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function ln(t){let e={},r=t.toString();r=r.replace(/\r\n?/mg,`
|
|
2
|
-
`);let n;for(;(n=
|
|
3
|
-
`),c=c.replace(/\\r/g,"\r")),e[o]=c}return e}a(ln,"parse");function dn(t){t=t||{};let e=Jt(t);t.path=e;let r=P.configDotenv(t);if(!r.parsed){let s=new Error(`MISSING_DATA: Cannot parse ${e} for an unknown reason`);throw s.code="MISSING_DATA",s}let n=zt(t).split(","),o=n.length,c;for(let s=0;s<o;s++)try{let l=n[s].trim(),u=un(r,l);c=P.decrypt(u.ciphertext,u.key);break}catch(l){if(s+1>=o)throw l}return P.parse(c)}a(dn,"_parseVault");function pn(t){console.error(`\u26A0 ${t}`)}a(pn,"_warn");function pe(t){console.log(`\u2506 ${t}`)}a(pe,"_debug");function Kt(t){console.log(`\u25C7 ${t}`)}a(Kt,"_log");function zt(t){return t&&t.DOTENV_KEY&&t.DOTENV_KEY.length>0?t.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}a(zt,"_dotenvKey");function un(t,e){let r;try{r=new URL(e)}catch(l){if(l.code==="ERR_INVALID_URL"){let u=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw u.code="INVALID_DOTENV_KEY",u}throw l}let n=r.password;if(!n){let l=new Error("INVALID_DOTENV_KEY: Missing key part");throw l.code="INVALID_DOTENV_KEY",l}let o=r.searchParams.get("environment");if(!o){let l=new Error("INVALID_DOTENV_KEY: Missing environment part");throw l.code="INVALID_DOTENV_KEY",l}let c=`DOTENV_VAULT_${o.toUpperCase()}`,s=t.parsed[c];if(!s){let l=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${c} in your .env.vault file.`);throw l.code="NOT_FOUND_DOTENV_ENVIRONMENT",l}return{ciphertext:s,key:n}}a(un,"_instructions");function Jt(t){let e=null;if(t&&t.path&&t.path.length>0)if(Array.isArray(t.path))for(let r of t.path)Fe.existsSync(r)&&(e=r.endsWith(".vault")?r:`${r}.vault`);else e=t.path.endsWith(".vault")?t.path:`${t.path}.vault`;else e=_e.resolve(process.cwd(),".env.vault");return Fe.existsSync(e)?e:null}a(Jt,"_vaultPath");function jt(t){return t[0]==="~"?_e.join(rn.homedir(),t.slice(1)):t}a(jt,"_resolveHome");function fn(t){let e=oe(process.env.DOTENV_CONFIG_DEBUG||t&&t.debug),r=oe(process.env.DOTENV_CONFIG_QUIET||t&&t.quiet);(e||!r)&&Kt("loading env from encrypted .env.vault");let n=P._parseVault(t),o=process.env;return t&&t.processEnv!=null&&(o=t.processEnv),P.populate(o,n,t),{parsed:n}}a(fn,"_configVault");function gn(t){let e=_e.resolve(process.cwd(),".env"),r="utf8",n=process.env;t&&t.processEnv!=null&&(n=t.processEnv);let o=oe(n.DOTENV_CONFIG_DEBUG||t&&t.debug),c=oe(n.DOTENV_CONFIG_QUIET||t&&t.quiet);t&&t.encoding?r=t.encoding:o&&pe("no encoding is specified (UTF-8 is used by default)");let s=[e];if(t&&t.path)if(!Array.isArray(t.path))s=[jt(t.path)];else{s=[];for(let y of t.path)s.push(jt(y))}let l,u={};for(let y of s)try{let T=P.parse(Fe.readFileSync(y,{encoding:r}));P.populate(u,T,t)}catch(T){o&&pe(`failed to load ${y} ${T.message}`),l=T}let g=P.populate(n,u,t);if(o=oe(n.DOTENV_CONFIG_DEBUG||o),c=oe(n.DOTENV_CONFIG_QUIET||c),o||!c){let y=Object.keys(g).length,T=[];for(let v of s)try{let A=_e.relative(process.cwd(),v);T.push(A)}catch(A){o&&pe(`failed to load ${v} ${A.message}`),l=A}Kt(`injected env (${y}) from ${T.join(",")} ${an(`// tip: ${on()}`)}`)}return l?{parsed:u,error:l}:{parsed:u}}a(gn,"configDotenv");function mn(t){if(zt(t).length===0)return P.configDotenv(t);let e=Jt(t);return e?P._configVault(t):(pn(`you set DOTENV_KEY but you are missing a .env.vault file at ${e}`),P.configDotenv(t))}a(mn,"config");function hn(t,e){let r=Buffer.from(e.slice(-64),"hex"),n=Buffer.from(t,"base64"),o=n.subarray(0,12),c=n.subarray(-16);n=n.subarray(12,-16);try{let s=nn.createDecipheriv("aes-256-gcm",r,o);return s.setAuthTag(c),`${s.update(n)}${s.final()}`}catch(s){let l=s instanceof RangeError,u=s.message==="Invalid key length",g=s.message==="Unsupported state or unable to authenticate data";if(l||u){let y=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw y.code="INVALID_DOTENV_KEY",y}else if(g){let y=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw y.code="DECRYPTION_FAILED",y}else throw s}}a(hn,"decrypt");function yn(t,e,r={}){let n=!!(r&&r.debug),o=!!(r&&r.override),c={};if(typeof e!="object"){let s=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw s.code="OBJECT_REQUIRED",s}for(let s of Object.keys(e))Object.prototype.hasOwnProperty.call(t,s)?(o===!0&&(t[s]=e[s],c[s]=e[s]),n&&pe(o===!0?`"${s}" is already defined and WAS overwritten`:`"${s}" is already defined and was NOT overwritten`)):(t[s]=e[s],c[s]=e[s]);return c}a(yn,"populate");var P={configDotenv:gn,_configVault:fn,_parseVault:dn,config:mn,decrypt:hn,parse:ln,populate:yn};z.exports.configDotenv=P.configDotenv;z.exports._configVault=P._configVault;z.exports._parseVault=P._parseVault;z.exports.config=P.config;z.exports.decrypt=P.decrypt;z.exports.parse=P.parse;z.exports.populate=P.populate;z.exports=P});var Qn={};Or(Qn,{TestRunMonitor:()=>xe});module.exports=Mr(Qn);var De=a(t=>new Promise(e=>setTimeout(e,t)),"awaitSleep");var _r=require("child_process"),ge=require("crypto"),k=require("fs"),Rr=require("fs/promises"),Sr=require("stream/promises"),Cr=require("http"),Ar=le(require("net")),vr=require("os"),V=require("path");var at=["script","template"],ct='<script id="playwrightReportBase64" type="application/zip">',lt="</script>";var sr=require("htmlparser2"),ir=le(Gt()),B=require("fs"),te=require("path"),ar=require("os"),cr=require("crypto");var J=le(require("path")),He=require("fs");var Pe=require("path"),Ie=require("fs");function tn(t,e,r=10){let n=t;for(let o=0;o<r;o++){let c=(0,Pe.join)(n,"package.json");if((0,Ie.existsSync)(c))try{if(JSON.parse((0,Ie.readFileSync)(c,"utf8")).name===e)return n}catch{}n=(0,Pe.join)(n,"..")}}a(tn,"findRepositoryRoot");function Zt(t,e=10){return tn(t,"checksum-customer-engineering-workspace",e)}a(Zt,"findCustomerEngineeringRoot");var We=le(Yt());var Z=a((t,e)=>{if(t==null||t==="")return(e==null?void 0:e.default)??!1;let r=t.toLowerCase().trim();return r==="true"?!0:r==="false"?!1:(e==null?void 0:e.default)??!1},"parseBoolean");function qt(t){if(t===void 0||t.trim()==="")return 5e7;let e=Number(t);return!Number.isInteger(e)||e<0?5e7:e}a(qt,"resolveMaxRRwebBytes");var En=__dirname,Xt=J.join(__dirname,".."),er=(0,He.existsSync)(Xt)?Xt:En;(0,We.config)({path:J.resolve(er,".env")});var Qt=Z(process.env.CHECKSUM_RUNTIME_DEV_MODE);function Tn(){let t=__dirname;for(;!(0,He.existsSync)(J.join(t,"package.json"));)t=J.join(t,"..");return t}a(Tn,"findRoot");var ue=Tn(),In=Zt(ue,10);(0,We.config)({path:[er,In].filter(t=>!!t).map(t=>J.resolve(t,".env")),override:!1});var Be=Z(process.env.CHECKSUM_RUNTIME_REPO_MODE),_n=Be?J.join(ue,"package","pw-report-template.html"):J.join(ue,"pw-report-template.html"),Rn=Z(process.env.CHECKSUM_DEBUG_ANALYTICS),Sn=Z(process.env.CHECKSUM_LOG_ANALYTICS_TO_CONSOLE),Cn=qt(process.env.CHECKSUM_RUNTIME_RRWEB_MAX_BYTES),Re={isDevMode:Qt,isRepoMode:Be,CI:!!process.env.CI,checksumRootFolderBypass:Be&&process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS_FOR_REPO_MODE?process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS_FOR_REPO_MODE:process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS,logLevel:process.env.CHECKSUM_RUNTIME_LOG_LEVEL??"warnings",checksumScript:{source:process.env.CHECKSUM_RUNTIME_SCRIPT_SOURCE??(Qt?"url":"file"),url:process.env.CHECKSUM_RUNTIME_SCRIPT_URL,path:ue+"/checksumlib.js"},runtimeRoot:ue,playwrightReporter:{htmlReportTemplatePath:_n},bypassProxyForLocalhost:Z(process.env.CHECKSUM_RUNTIME_BYPASS_PROXY_FOR_LOCALHOST),useCLIDebug:Z(process.env.CHECKSUM_RUNTIME_USE_CLI_DEBUG),useRemoteDebugging:{enabled:Z(process.env.CHECKSUM_RUNTIME_USE_REMOTE_DEBUGGING),port:parseInt(process.env.CHECKSUM_AGENT_RUNTIME_REMOTE_DEBUGGING_PORT??"9500")},testRun:{timeMachine:{active:!0,headless:!Z(process.env.CHECKSUM_RUNTIME_SHOW_RUNTIME_TIME_MACHINE),recordRRwebEventsToFile:Z(process.env.CHECKSUM_RUNTIME_RECORD_RRWEB_EVENTS_TO_FILE,{default:!0}),maxRRwebBytes:Cn},monitoring:{debugAnalytics:Rn,logToConsole:Sn,segment:{writeKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_WRITE_KEY??"TMuP8uorDj4QzJfNs0gEHDO7kHozVBOo",devWriteKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_DEV_WRITE_KEY??"gofHHwvdNHJNmb7KqACUmypZclVHEQ2l"}},autoRecovery:{verboseConsoleLog:Z(process.env.CHECKSUM_RUNTIME_AUTO_RECOVERY_CONSOLE_LOG,{default:!1}),sessionTimeout:18e4},disableAutoRecovery:Z(process.env.CHECKSUM_RUNTIME_DISABLE_AUTO_RECOVERY),disableHostReports:Z(process.env.CHECKSUM_RUNTIME_DISABLE_HOST_REPORTS),disableTimeMachine:Z(process.env.CHECKSUM_RUNTIME_DISABLE_TIME_MACHINE),disableRrwebRecording:Z(process.env.CHECKSUM_RUNTIME_DISABLE_RRWEB_RECORDING),request:{userEmail:process.env.CHECKSUM_RUNTIME_REQUEST_USER_EMAIL,reason:process.env.CHECKSUM_RUNTIME_REQUEST_REASON},platform:{name:process.env.CHECKSUM_RUNTIME_PLATFORM_NAME,jobURL:process.env.CHECKSUM_RUNTIME_PLATFORM_JOB_URL,jobName:process.env.CHECKSUM_RUNTIME_PLATFORM_JOB_NAME},runType:process.env.CHECKSUM_RUNTIME_RUN_TYPE},buildTime:process.env.CHECKSUM_RUNTIME_BUILD_TIME??"unknown"};var Rs=require("@playwright/test/reporter");var se=require("path");var $e=a((t,e,r)=>`v2:${An(t)}::${JSON.stringify([...e,r])}`,"computeVariantKey"),An=a(t=>(t??"").replace(/\\/g,"/"),"normalizeFilePath");var Se=require("fs"),F=le(require("typescript"));var vn=/^[0-9a-zA-Z]+$/,bn=5;function tr(t){return t?t.length===bn&&vn.test(t):!1}a(tr,"isValidChecksumTestId");var je=class je{extract(e,r){if(!e)return;let n=e.split("/"),o=n[n.length-1];if(!o||!o.endsWith(".checksum.spec.ts"))return;let s=o.replace(".checksum.spec.ts","").split(" - ").pop();return tr(s)?s:void 0}};a(je,"FileNameExtractionStrategy");var Ge=je,Ke=class Ke{extract(e,r){if(!(!e||!(0,Se.existsSync)(e)))try{let n=(0,Se.readFileSync)(e,"utf-8"),o=F.createSourceFile(e,n,F.ScriptTarget.Latest,!0),c=new Map,s=a(l=>{if(F.isCallExpression(l)){let u=l;if(this.isTestCall(u.expression)){let g=u.arguments[0];if(g&&F.isCallExpression(g)&&F.isIdentifier(g.expression)&&g.expression.text==="defineChecksumTest"){let y=this.extractDefineChecksumTestArgs(g);y&&tr(y.checksumTestId)&&c.set(y.testTitle,y.checksumTestId)}}}F.forEachChild(l,s)},"visit");return s(o),r&&c.has(r)?c.get(r):c.size>0?Array.from(c.values())[0]:void 0}catch{return}}isTestCall(e){return F.isIdentifier(e)&&e.text==="test"?!0:F.isPropertyAccessExpression(e)?F.isIdentifier(e.expression)&&e.expression.text==="test":!1}extractDefineChecksumTestArgs(e){let r=e.arguments;if(r.length<2)return;let n=r[0],o=r[1];if(!n||!o)return;let c=this.extractStringLiteral(n),s=this.extractStringLiteral(o);if(c&&s)return{testTitle:c,checksumTestId:s}}extractStringLiteral(e){if(F.isStringLiteral(e)||F.isNoSubstitutionTemplateLiteral(e))return e.text}};a(Ke,"FileContentExtractionStrategy");var Ze=Ke,ze=class ze{constructor(e){this.strategies=e??[new Ze,new Ge]}extract(e,r){for(let n of this.strategies){let o=n.extract(e,r);if(o)return o}}};a(ze,"ChecksumTestIdExtractor");var Ve=ze;var rr=new Ve;function Ce(t,e){return e.pwTestIdToChecksumTestId[t.playwrightTestId]||(t.filePath!==void 0?rr.extract(t.filePath,t.title):void 0)}a(Ce,"resolveChecksumTestId");var Ye=a((t,e)=>Object.values(e[t]??{}).some(r=>{var n,o;return(o=(n=r.autoRecoveryMetadata)==null?void 0:n.data)==null?void 0:o.autoRecovered}),"isAutoRecovered"),Je=a(t=>typeof t=="number"&&!isNaN(t)?t:0,"getStat");function qe(t,e,r){let n=[],o=0,c=0,s=Je(e.expected)+Je(e.flaky),l=Je(e.unexpected);for(let u of t){let g=wn(u,r);n.push(g),g.recovered&&c++,g.bug&&(o++,g.outcome==="expected"||g.outcome==="flaky"?s--:g.outcome==="unexpected"&&l--)}return{passed:s,failed:l,bug:o,recovered:c,tests:n}}a(qe,"computeReportStats");function wn(t,e){let r=Ce({playwrightTestId:t.playwrightTestId,filePath:t.filePath,title:t.title},e),n=Nn(t),o=xn(t.annotations),c=Ye(t.playwrightTestId,e.playwrightIdToMetadata),s=Dn(r,t,e),l=e.toRelativeFilePath(t.filePath);return{checksumTestId:r,playwrightTestId:t.playwrightTestId,success:t.ok,recovered:c,bug:n,annotations:o,tags:t.tags,outcome:t.outcome,variantKey:$e(t.filePath,t.titlePath,t.title),...t.filePath!==void 0?{filePath:t.filePath}:{},...l!==void 0?{relativeFilePath:l}:{},...t.projectName?{project:t.projectName}:{},...s!==void 0?{usingChecksumTestIdPlaceholder:s}:{}}}a(wn,"rowToTestWithMetadata");function nr(t,e){let r=t.files,n=a(l=>{let g=Ce({playwrightTestId:l.testId,filePath:l.location.file,title:l.title},e)??`${l.location.file}::${l.title}`,y=$e(l.location.file,l.path??[],l.title);return`${g}::${l.projectName}::${y}`},"keyFor"),o=new Map;for(let l of r)for(let u of l.tests)o.set(n(u),u);let c=new Set(o.values()),s={total:0,expected:0,unexpected:0,flaky:0,skipped:0};for(let l of r){l.tests=l.tests.filter(u=>c.has(u));for(let u of l.tests)s.total++,u.outcome==="expected"?s.expected++:u.outcome==="unexpected"?s.unexpected++:u.outcome==="flaky"?s.flaky++:s.skipped++}t.files=r.filter(l=>l.tests.length>0),t.stats={...t.stats,...s}}a(nr,"dedupeReportByChecksumTestId");var Nn=a(t=>t.tags.includes("bug")||t.annotations.some(e=>e.type==="bug")||t.title.includes("@bug"),"detectBug"),xn=a(t=>t.filter(e=>!!(e!=null&&e.type)).map(e=>({type:e.type,description:e.description||""})),"normalizeAnnotations"),Dn=a((t,e,r)=>{if(r.checksumTestIdToUsingPlaceholder)return r.pwTestIdToChecksumTestId[e.playwrightTestId]&&r.checksumTestIdToUsingPlaceholder[t]||!1},"computeUsingPlaceholder");var or=a((t,e,r)=>{if(!t)return;let n=r||e,o;if((0,se.isAbsolute)(t))o=t;else{let c=(0,se.dirname)(e);o=(0,se.resolve)(c,t)}return o.replace(n+"/","")},"toRelativeFilePath");var Ln=a(t=>t.files.flatMap(e=>e.tests.map(r=>{var n;return{playwrightTestId:r.testId,ok:!!r.ok,outcome:r.outcome,title:r.title,titlePath:r.path??[],filePath:(n=r.location)==null?void 0:n.file,...r.projectName?{projectName:r.projectName}:{},tags:r.tags??[],annotations:r.annotations??[]}})),"htmlReportToRows"),ee=class ee{constructor(e,r,n,o={},c={},s,l,u,g={}){this.reportHTMLFilePath=e;this.testRunUUID=r;this.pwTestIdToChecksumTestId=n;this.playwrightIdToMetadata=o;this.channel=s;this.checksumTestIdToUsingPlaceholder=g;this.supportVideo=!1;this.config={hosted:!0,assetsBaseURL:"https://api.checksum.ai/api/test-runs"};this.config={...this.config,...c},this.checksumRoot=l||(0,te.dirname)((0,te.dirname)(e)),this.projectRoot=u||this.checksumRoot}async process(){var c;let e=0;try{e=((c=(0,B.statSync)(this.reportHTMLFilePath))==null?void 0:c.size)||0,this.channel.debug(`Report HTML file size approximately ${e} bytes`)}catch(s){this.channel.debug(`Failed to retrieve file size for ${this.reportHTMLFilePath}`,s)}let r=(0,te.join)((0,ar.tmpdir)(),`pw-report-${(0,cr.randomUUID)()}.zip`),n=a(()=>{try{(0,B.existsSync)(r)&&(0,B.unlinkSync)(r)}catch{}},"cleanupFile"),o={sigterm:a(()=>{n(),process.exit(143)},"sigterm"),sigint:a(()=>{n(),process.exit(130)},"sigint"),exit:n};process.once("SIGTERM",o.sigterm),process.once("SIGINT",o.sigint),process.once("exit",o.exit);try{this.channel.debug("Extracting base64 to temp ZIP file...");let s=Date.now();await this.extractBase64ToFile(r);let l=Date.now()-s;this.channel.debug("Modifying ZIP file...");let u=Date.now(),g=this.modifyZipFile(r),y=Date.now()-u;this.channel.debug("Writing output HTML...");let T=Date.now();await this.writeOutputWithStreamedZip(r);let v=Date.now()-T;return{report_html_bytes:e,extract_ms:l,modify_ms:y,write_ms:v,entry_count:g.entryCount,json_entry_count:g.jsonEntryCount,largest_entry_bytes:g.largestEntryBytes,largest_entry_name:g.largestEntryName}}finally{process.removeListener("SIGTERM",o.sigterm),process.removeListener("SIGINT",o.sigint),process.removeListener("exit",o.exit);try{(0,B.existsSync)(r)&&(0,B.unlinkSync)(r)}catch{this.channel.debug(`Failed to cleanup temp file: ${r}`)}}}async extractBase64ToFile(e){return new Promise((r,n)=>{let o=!1,c=!1,s=!1,l=[],u=0,g=(0,B.createWriteStream)(e);g.on("error",d=>{if(!c){c=!0;try{A.destroyed||A.destroy(),v.end()}catch{}n(d)}});let y=a(()=>{if(u<4)return;let d=l.join("");l.length=0,s||(d=d.replace("data:application/zip;base64,",""),s=!0);let f=Math.floor(d.length/4)*4,p=d.slice(0,f),h=d.slice(f);if(h.length>0?(l.push(h),u=h.length):u=0,p.length>0){let E=Buffer.from(p,"base64");g.write(E)}},"flushBuffer"),T=a(d=>at.includes(d),"isPayloadTag"),v=new sr.Parser({onopentag:a((d,f)=>{T(d)&&f.id==="playwrightReportBase64"&&(o=!0)},"onopentag"),ontext:a(d=>{o&&(l.push(d),u+=d.length,u>1024*1024&&y())},"ontext"),onclosetag:a(d=>{if(T(d)&&o&&!c){if(c=!0,u>0){let f=l.join("");if(s||(f=f.replace("data:application/zip;base64,","")),f.length>0){let p=Buffer.from(f,"base64");g.write(p)}}try{A.destroyed||A.destroy()}catch{}g.end(()=>r())}},"onclosetag"),onerror:a(d=>{if(!c){c=!0;try{v.end(),A.destroyed||A.destroy(),g.destroyed||g.destroy()}catch{}n(d)}},"onerror")}),A=(0,B.createReadStream)(this.reportHTMLFilePath,{encoding:"utf8"});A.on("data",d=>v.write(d.toString())),A.on("end",()=>{if(v.end(),!c){c=!0;try{g.destroyed||g.destroy()}catch{}n(new Error("Could not find playwrightReportBase64 in HTML"))}}),A.on("error",d=>{if(!c){c=!0;try{v.end(),g.destroyed||g.destroy()}catch{}n(d)}})})}modifyZipFile(e){let r=new ir.default(e),n=r.getEntries(),o=!1,c=0,s=0,l="";for(let u of n){if(u.isDirectory||!u.entryName.endsWith(".json"))continue;let g=u.getData().toString("utf8");if(c+=1,g.length>s&&(s=g.length,l=u.entryName),u.entryName==="report.json"){let y=JSON.parse(g);this.config.dedupeByChecksumTestId&&nr(y,{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId}),this.handleReportJSON(y),this.report=y,this.extractStats(y),u.setData(Buffer.from(JSON.stringify(y),"utf8")),o=!0}else u.setData(Buffer.from(this.replaceAttachmentPaths(g),"utf8"))}if(!o)throw new Error("report.json not found in ZIP file");return r.writeZip(e),{entryCount:n.length,jsonEntryCount:c,largestEntryBytes:s,largestEntryName:l}}replaceAttachmentPaths(e){return e.replace(/"path"\s*:\s*"([^"]+)"/g,(r,n)=>n.startsWith("http://")||n.startsWith("https://")?r:`"path":"${this.makeAttachmentPath(n)}"`)}async writeOutputWithStreamedZip(e){let r=this.getTemplate(),n=this.getProcessedFilePath(),o=n.replace(".html",".backup.html");(0,B.copyFileSync)(n,o);let c=(0,B.createWriteStream)(n);await new Promise((s,l)=>{c.on("error",l),c.write(r),c.write(ct+"data:application/zip;base64,");let u=(0,B.createReadStream)(e,{highWaterMark:3*1024*1024});u.on("data",g=>{let T=(typeof g=="string"?Buffer.from(g):g).toString("base64");c.write(T)||u.pause()}),c.on("drain",()=>{u.resume()}),u.on("end",()=>{c.write(lt),c.end(()=>s())}),u.on("error",g=>{try{c.destroyed||c.destroy()}catch{}l(g)}),c.on("error",g=>{try{u.destroyed||u.destroy()}catch{}l(g)})})}testHasTrace(e,r){try{if(!this.report)return!0;let n=Object.keys(this.pwTestIdToChecksumTestId??{}).find(c=>this.pwTestIdToChecksumTestId[c]===e);if(!n)return!0;let o=a(c=>c.some(s=>{var l;return(l=s.attachments)==null?void 0:l.some(u=>u.name==="trace")}),"hasTrace");for(let c of this.report.files)for(let s of c.tests)if(s.testId===n&&s.projectName===r&&o(s.results))return!0;return!1}catch(n){return this.channel.debug("Failed to check if test has trace, assuming trace exists",n),!0}}getProcessedFilePath(){return this.reportHTMLFilePath}getTemplate(){return ee.templateCache||(ee.templateCache=(0,B.readFileSync)(Re.playwrightReporter.htmlReportTemplatePath,"utf-8")),ee.templateCache}getReportsStats(){return this.stats}extractStats(e){e.stats&&(this.stats=qe(Ln(e),e.stats,{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId,playwrightIdToMetadata:this.playwrightIdToMetadata,checksumTestIdToUsingPlaceholder:this.checksumTestIdToUsingPlaceholder,toRelativeFilePath:a(r=>or(r,this.checksumRoot,this.projectRoot),"toRelativeFilePath")}))}makeAttachmentPath(e){return this.config.hosted?`${this.config.assetsBaseURL}/${this.testRunUUID}/report-data-file-url?fileName=${(0,te.basename)(e)}`:e}handleReportJSON(e){let r={},n=a(o=>{var u;let c=o.testId,s=this.playwrightIdToMetadata[c];s&&(r[c]=s);let l=Ce({playwrightTestId:o.testId,filePath:(u=o.location)==null?void 0:u.file,title:o.title},{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId});l!==void 0&&(o.checksumTestId=l),o.results.forEach(g=>{this.processAttachments(g.attachments)})},"getChecksumMetadataForPWTestId");e.files.forEach(o=>{o.tests.forEach(n)}),e.checksumMetadata=r}processAttachments(e){if(e.forEach(r=>this.updateAttachment(r)),!this.supportVideo){let r=e.findIndex(n=>n.name==="video");r!==-1&&e.splice(r,1)}}updateAttachment(e){e.path&&(e.path=this.makeAttachmentPath(e.path))}};a(ee,"PlaywrightReportProcessor"),ee.templateCache=null;var Ae=ee;var lr={trace:"application/zip","trace-backup-file":"application/zip",har:"application/zip",report:"text/html","rrweb-recording":"application/json"},On={click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",upload_files:"upload_files",wait:"wait",get_more_items:"get_more_items",reset:void 0,save:void 0,fail:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0,logout_and_login:"logout_and_login",canvas_click:"canvas_click",native_accept:"native_accept",native_dismiss:"native_dismiss",hard_assertion:void 0,soft_assertion:void 0,recovery:void 0,scroll:void 0},Ps=Object.fromEntries(Object.entries(On).map(t=>t.reverse())),Mn={goto:"navigation",click:"click",dblclick:"double_click",dragTo:"drag_and_drop",check:"check",uncheck:"uncheck",fill:"input",hover:"hover",selectOption:"selectoption",waitForTimeout:"wait","keyboard.press":"keystroke",setInputFiles:"upload_files",getPage:"switch_tab",reauthenticate:"logout_and_login",canvasClick:"canvas_click"},Fs=Object.fromEntries(Object.entries(Mn).map(t=>t.reverse()));var Bs={input:[1,2],selectoption:[1,2],keystroke:[1,2],wait:[1,2],navigation:[1,2],click:[0,1],double_click:[0,1],drag_and_drop:[1,2],upload_files:[1,2],canvas_click:[1,2],logout_and_login:[1],login:[1,2],click_and_type:[1,2],clear_and_type:[1,2],check:[0,1],uncheck:[0,1],hover:[0,1]},Hs={input:1,selectoption:1,keystroke:1,wait:-1,navigation:1,click:0,double_click:0,drag_and_drop:1,upload_files:1,canvas_click:-1,logout_and_login:-1,login:1,click_and_type:0,clear_and_type:0,check:0,uncheck:0,hover:0,native_accept:-1,native_dismiss:-1};var Ne=require("fs"),yr=require("path"),Er=require("stream");var dr=a(t=>{if(t.error!=null)return"ERROR";let e=t.status_code;if(typeof e=="number"&&e>=500)return"ERROR";let r=t.exit_code;return typeof r=="number"&&r!==0?"ERROR":"INFO"},"severityFor");var Xe=require("fs");var pr="\x1B[31m",kn="\x1B[33m",Un="\x1B[32m",Pn="\x1B[36m",Fn="\x1B[2m",Bn="\x1B[1m",fe="\x1B[0m",Hn=a(()=>{let t=process.env.WIDE_EVENT_PRETTY;return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:process.stdout.isTTY?!0:process.env.APP_ENV==="local"},"shouldPretty"),Wn=new Set(["severity","message","kind","timestamp","_startedAtMs"]),$n=a(t=>{let e=new WeakSet;return JSON.stringify(t,(r,n)=>{if(typeof n=="bigint")return n.toString();if(typeof n=="object"&&n!==null){if(e.has(n))return"[Circular]";e.add(n)}return n})},"safeStringify"),Gn=a(t=>t==="ERROR"||t==="CRITICAL"?pr:t==="WARNING"?kn:Un,"colorForSeverity"),Zn=a(t=>{let e=String(t.severity??"INFO"),r=`${Gn(e)}${e.padEnd(5)}${fe}`,n=t.kind?`${Pn}${t.kind}${fe}`:"",o=String(t.message??""),c=t.error&&typeof t.error=="object"?(()=>{let y=t.error;return` ${pr}${y.type??"Error"}: ${y.message??""}${fe}`})():"",s=["outcome","test_suite_run_id","status"],l=Object.entries(t).filter(([y,T])=>!Wn.has(y)&&T!=null&&y!=="error"&&typeof T!="object"),u=a(y=>{let T=s.indexOf(y);return T===-1?s.length:T},"rank"),g=l.sort(([y],[T])=>u(y)-u(T)).slice(0,8).map(([y,T])=>`${Fn}${y}=${fe}${T}`).join(" ");return[r,Bn+n+fe,o,g,c].filter(y=>y&&y.trim()!=="").join(" ")},"formatPretty"),Vn=a(t=>{let e=t.trace_id;if(typeof e!="string"||e==="")return t;let r=process.env.GCP_PROJECT_ID||process.env.GOOGLE_CLOUD_PROJECT;return r?{...t,"logging.googleapis.com/trace":`projects/${r}/traces/${e}`}:t},"withGcpTraceField"),ur=a(t=>{let e=Hn()?Zn(t):$n(Vn(t));(0,Xe.writeSync)(1,e+`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`)}{/trm}`)}event(e,r){return new Promise(n=>{let o=r?`${e}=${r}`:e;setTimeout(()=>{this.sendToCLI(`monitor:${o}`),n(!0)},100)})}trace(e,r){let n=r?`${e}=${JSON.stringify(r)}`:e;setTimeout(()=>{this.sendToCLI(`trace:${n}`)},100)}log(e){return this.event("log",e)}debug(...e){this.sendToCLI(e)}wideEvent(e){let r=Buffer.from(JSON.stringify(e),"utf-8").toString("base64");this.sendToCLI(`wideevent:${r}`)}};a(nt,"CLIChannel");var rt=nt,ot=class ot{constructor(e,r=!1){this.config=e;this.isolationMode=r;this.MAX_UPLOADS=15;this.MONITOR_INTERVAL=2500;this.UPLOAD_TIMEOUT=600*1e3;this.UPLOAD_STALL_TIMEOUT=600*1e3;this.WATCH_TIMEOUT=120*1e3;this.assets=[];this.watchAssets=[];this.processingPaths=new Set;this.reportComplete=!1;this.processingInProgress=!1;this.pwTestIdToChecksumTestId={};this.checksumTestIdToUsingPlaceholder={};this.progressFlushInFlight=!1;this.stallEventEmitted=!1;this.channel=new rt,et(n=>this.channel.wideEvent(n)),this.testAssetUploader=new we(e.apiURL,e.apiKey,this.UPLOAD_TIMEOUT,()=>`client-api/test-runs/${this.config.sessionId}/get-upload-url`,this.isolationMode,{start:a(n=>this.channel.trace("Upload Start",{filename:n}),"start"),complete:a(n=>{if(!this.reportAsset||n!==this.reportAsset.info.path)try{(0,k.unlinkSync)(n),this.channel.debug(`[TestAssetUploader] Deleted file after successful upload: ${n}`)}catch(o){this.channel.debug(`[TestAssetUploader] Failed to delete file after upload: ${n}`,o)}this.channel.trace("Upload Complete",{filename:n})},"complete"),error:a((n,o)=>this.channel.trace("Upload Failed",{filename:n,error:o}),"error")},e.sessionId),setInterval(this.monitorUploads.bind(this),this.MONITOR_INTERVAL),this.listenForMessages(),this.startServer()}listenForMessages(){process.stdin.on("data",e=>{(async()=>{let r=e.toString().trim();if(!r.startsWith("cli:"))return;let[n,o]=r.substring(4).split("=");switch(this.channel.debug("Received message from CLI "+n+" "+o),n){case"report":if(this.testRunEndTime=Date.now(),o!=="false")try{let c=Buffer.from(o??"","base64").toString("utf-8"),s=JSON.parse(c);await this.handleReport(s)}catch(c){this.channel.debug("Error JSON parsing report payload, continue without report. Error: "+this.stringify(c)),this.reportComplete=!0}else this.reportComplete=!0;this.monitorUploadsCompletion();break;case"shutdown":this.shutdown();break}})()})}async readMetadataFile(e){try{let r=await(0,Rr.readFile)(e,"utf-8");return JSON.parse(r)}catch(r){return this.channel.trace("Runtime Error",`Error reading checksum metadata file ${e}: ${r.message}`),{}}}async serveReport(e){try{let r=(0,V.dirname)(e);await this.channel.log("Serving report in browser: "+r);let n=Re.isRepoMode?`yarn playwright show-report ${r}`:`npx playwright show-report ${r}`;(0,_r.execSync)(n,{encoding:"utf8",stdio:"pipe"}),await this.channel.log("Success: Report opened in browser")}catch(r){await this.channel.log(`Error serving report in browser: ${r.message}`),r.stderr&&await this.channel.log(r.stderr.toString())}}async handleReport(e){let{reportPath:r,pathToChecksumMetadata:n,didFail:o,openReportCriteria:c,checksumRoot:s,projectRoot:l,isUploadReport:u,dedupeByChecksumTestId:g}=e;this.channel.debug(`Handling report ${this.isolationMode?"(isolation mode)":""}`+r),this.uploadReportData((0,V.dirname)(r),u);let y=ie("report_processing",{test_suite_run_id:this.config.sessionId,report_path:r,isolation_mode:this.isolationMode,is_upload_report:!!u});try{let T=await this.readMetadataFile(n),v=new Ae(r,this.config.sessionId,this.pwTestIdToChecksumTestId,T,{hosted:!this.isolationMode,...g?{dedupeByChecksumTestId:g}:{}},this.channel,s,l,this.checksumTestIdToUsingPlaceholder),A=this.initAsset({type:"report",path:""});this.reportAsset=A;try{let p=await v.process();A.info.path=v.getProcessedFilePath(),y.set({processed_path:A.info.path,...p}),this.uploadAsset(A)}catch(p){this.channel.debug("Error processing report, "+p.message),A.error=!0,y.set({error:Y(p)})}let d=v.getReportsStats();this.stats=d,y.emit({outcome:A.error?"error":"success",stats:d}),this.channel.debug("Checking watch assets");let f=this.watchAssets.filter(p=>!(p.type!=="trace"||v.testHasTrace(p.testId??"",p.project??"")));f.length>0&&(this.channel.debug("Removed watch assets - "),this.channel.debug(JSON.stringify(f.map(p=>p.path)))),this.watchAssets=this.watchAssets.filter(p=>p.type!=="trace"||v.testHasTrace(p.testId??"",p.project??""))}catch(T){this.channel.debug("Error processing report, "+this.stringify(T)),this.reportAsset&&(this.reportAsset.error=!0),y.emit({outcome:"error",error:Y(T)})}finally{if((c==="always"||c==="on-failure"&&o)&&await this.serveReport(r),n&&(0,k.existsSync)(n))try{(0,k.unlinkSync)(n)}catch(v){console.error(`Error deleting checksum metadata file ${n}: ${v.message}`)}}}async uploadReportData(e,r){let n=(0,V.join)(e,"data");try{let o=(0,k.readdirSync)(n),c=r?[".webm"]:[".zip",".webm"],s=o.filter(l=>!c.includes((0,V.extname)(l)));this.channel.debug("Preparing to upload report data files,"+s);for(let l of s)this.channel.debug("Uploading report data file,"+l),this.addAsset({type:"report-data-file",fileName:l,path:`${n}/${l}`})}catch(o){this.channel.debug(`Error reading/adding report data files from dir ${n}`+o.message)}}shutdown(){this.channel.debug("Received shutdown message from CLI"),this.server.close(),process.exit(0)}async monitorUploadsCompletion(){var e;if(!this.reportComplete&&this.reportAsset&&(this.reportAsset.complete||this.reportAsset.error)){this.reportComplete=!0;let r="";try{let n=JSON.stringify(this.stats),o=`checksum-stats-${(0,ge.randomBytes)(8).toString("hex")}.json`;r=(0,V.join)((0,vr.tmpdir)(),o),(0,k.writeFileSync)(r,n,"utf-8"),this.channel.debug(`Stats written to temporary file: ${r}`)}catch(n){this.channel.debug("Error writing stats to file"),this.channel.log(`[monitorUploadsCompletion] Error writing stats to file: ${n.message}`)}this.channel.event("report-complete",`${(e=this.reportAsset)!=null&&e.complete?"true":"false"}:${r}`)}if(!this.processingInProgress&&this.reportComplete&&(this.assets.filter(r=>r.complete||r.error).length===this.assets.length||this.isUploadStalled())&&(this.watchAssets.length===0||this.testRunEndTime&&Date.now()-this.testRunEndTime>this.WATCH_TIMEOUT)){let r=Date.now(),n=this.assets.filter(l=>!l.complete&&!l.error);this.assets.forEach(l=>{!l.complete&&!l.error&&(l.error=!0)});let o=this.assets.find(l=>l.error)?"uploads-complete-with-errors":"uploads-complete",c=this.assets.filter(l=>l.error);ve("uploads_completion",{test_suite_run_id:this.config.sessionId,outcome:c.length>0?"error":"success",decision:o,total_assets:this.assets.length,completed:this.assets.filter(l=>l.complete).length,errored:c.length,stalled:n.length>0,stalled_count:n.length,watch_remaining:this.watchAssets.length,report_complete:this.reportComplete,upload_finalize_ms:this.testRunEndTime?r-this.testRunEndTime:void 0,errored_assets:c.map(l=>this.assetSnapshot(l,r))});let s=o==="uploads-complete"?{}:{uploadErrors:this.assets.filter(l=>l.error).map(l=>{try{return JSON.stringify(l)}catch{return l.info.path}}),watchAssets:this.watchAssets,testRunEndTime:this.testRunEndTime,now:Date.now()};try{this.cleanUp()}catch(l){this.channel.debug("cleanUp failed (ignored): "+(l==null?void 0:l.message))}this.channel.event(o,JSON.stringify(s));return}await De(1e3),this.monitorUploadsCompletion()}assetSnapshot(e,r){return{file_name:e.info.fileName??(0,V.basename)(e.info.path),asset_type:e.info.type,test_id:e.info.testId,loaded_bytes:e.loadedBytes,size_bytes:e.sizeBytes,last_progress_age_ms:e.lastProgress?r-e.lastProgress:void 0}}cleanUp(){let e;for(let r of this.assets)if(r.info.type==="rrweb-recording"){e=(0,V.dirname)(r.info.path);break}e&&(0,k.rmSync)(e,{recursive:!0,force:!0})}isUploadStalled(){let e=Tr(this.assets,this.UPLOAD_STALL_TIMEOUT);if(e&&(this.channel.log("Uploads are stalled"),!this.stallEventEmitted)){this.stallEventEmitted=!0;let r=Date.now(),n=this.assets.filter(o=>!o.complete&&!o.error);ve("upload_stall_detected",{test_suite_run_id:this.config.sessionId,outcome:"error",timeout_ms:this.UPLOAD_STALL_TIMEOUT,total_assets:this.assets.length,pending_count:n.length,pending_assets:n.map(o=>this.assetSnapshot(o,r))})}return e}async startServer(){let e=await this.acquirePortNumber();this.channel.event("port",e.toString()),this.server=(0,Cr.createServer)((r,n)=>{let o=a(s=>{n.writeHead(400,{"Content-Type":"text/plain"}),n.end(s)},"returnErrorWithMessage");if(r.method!=="POST"){n.writeHead(404,{"Content-Type":"text/plain"}),n.end("Method not allowed");return}let c="";r.on("data",s=>{c+=s.toString()}),r.on("end",()=>{let s;try{s=JSON.parse(c)}catch{o("Invalid body");return}let{type:l,payload:u,watch:g}=s;switch(this.channel.debug(`Server received message, ${l}, ${this.stringify(u)}`),l){case"asset":if(!u.path||!u.type){o("Missing arguments");return}g?this.watchAsset(u):this.processAsset(u);break;case"testInfo":if(!u.pwTestId||!u.checksumTestId){o("Missing arguments");return}this.pwTestIdToChecksumTestId[u.pwTestId]=u.checksumTestId,u.usingChecksumTestIdPlaceholder!==void 0&&(this.checksumTestIdToUsingPlaceholder[u.checksumTestId]=u.usingChecksumTestIdPlaceholder);break;case"checksumTestMetadata":{let y=u;if(!y.checksumTestId||!u.data){o("Missing arguments");return}this.channel.event("checksumTestMetadata",JSON.stringify({...y}));break}case"testStats":break;case"playwrightConfig":this.channel.event("playwrightConfig",JSON.stringify(u));break;case"runProgress":this.forwardProgress(u);break;default:o("Invalid message type");return}n.writeHead(200,{"Content-Type":"text/plain"}),n.end("OK")})}),this.server.listen(e)}forwardProgress(e){this.latestProgress=e,!this.progressFlushInFlight&&this.flushProgress()}async flushProgress(){this.progressFlushInFlight=!0;try{for(;this.latestProgress;){let e=this.latestProgress;this.latestProgress=void 0,await this.patchProgress(e)}}finally{this.progressFlushInFlight=!1}}async patchProgress(e){if(this.isolationMode)return;let r=new AbortController,n=setTimeout(()=>r.abort(),3e4);try{await fetch(`${this.config.apiURL}/client-api/test-runs/${this.config.sessionId}/progress`,{method:"PATCH",headers:{Accept:"application/json","Content-Type":"application/json",ChecksumAppCode:this.config.apiKey},body:JSON.stringify({progress:e}),signal:r.signal})}catch(o){this.channel.debug("Failed to send run progress: "+(o==null?void 0:o.message))}finally{clearTimeout(n)}}stringify(e){try{return JSON.stringify(e)}catch{return"message"in e?e.message:e}}monitorUploads(){let{totalSizeBytes:e,totalUploadedBytes:r}=this.calculateUploadProgress();if(e>0&&!this.isolationMode){let c=(r/e*100).toFixed(2);this.channel.event("upload-progress",c)}let n=this.assets.filter(c=>!c.uploadStarted);if(n.length===0)return;let o=a(()=>this.assets.filter(c=>c.uploadStarted&&!c.complete&&!c.error).length,"getNumOfActiveUploads");if(!(o()>=this.MAX_UPLOADS))for(;n.length>0&&o()<this.MAX_UPLOADS;){let c=n.pop();if(c===void 0)break;this.uploadAsset(c)}}calculateUploadProgress(){let e=this.assets.reduce((n,{sizeBytes:o})=>n+(o??0),0),r=Math.min(e,this.assets.reduce((n,{loadedBytes:o})=>n+(o??0),0));return{totalSizeBytes:e,totalUploadedBytes:r}}getUploadLogMessage(e){switch(e.info.type){case"report":return"Uploading report";case"har":return`Uploading har file for test ${e.info.testId}`;case"trace":return`Uploading trace file for test ${e.info.testId}`;case"esra":return`Uploading metadata file for test ${e.info.testId}`;case"test-files":return`Uploading auto-healed test code for file ${e.info.path}`;default:return}}async uploadAsset(e){try{e.uploadStarted=!0;let r=this.getUploadLogMessage(e);r&&!this.isolationMode&&this.channel.event("log",r),await this.testAssetUploader.uploadAsset(e)}catch(r){e.error=!0,this.channel.debug("Error uploading asset"+this.stringify(r)),this.channel.trace("Upload Failed",{asset:e.info.fileName,error:String(r)})}}async getSignedURLForUpload(e){try{let{apiKey:r,sessionId:n,apiURL:o}=this.config,c=e.info,s=await fetch(`${o}/client-api/test-runs/${n}/get-upload-url`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",ChecksumAppCode:r},body:JSON.stringify(c)}),{url:l}=await be(s,{resource:"get-upload-url",requiredFields:["url"]});e.uploadURL=l}catch(r){this.channel.debug("Error getting signed URL for artifact"+this.stringify(r))}}watchAsset(e){if(this.watchAssets.some(n=>n.path===e.path)){this.channel.debug(`Already watching file ${e.path}, skipping duplicate`);return}this.channel.debug("Watching file "+e.path),this.watchAssets.push({...e,addedAt:Date.now()});let r=a(async()=>{await this.waitForFileComplete(e.path)&&(this.processAsset(e),this.watchAssets=this.watchAssets.filter(o=>o.path!==e.path))},"waitForCompletion");if((0,k.existsSync)(e.path))r();else{let n=(0,V.dirname)(e.path),o=(0,V.basename)(e.path),c=!1,s=(0,k.watch)(n,(l,u)=>{(async()=>{if(!(u!==o||c))try{this.channel.debug("Watched file changed "+e.path),c=!0,await r()}finally{s.close()}})()})}}waitForFileComplete(e,r=1e3,n=6e4,o=1){return new Promise(c=>{let s=Date.now(),l=0,u=a(()=>{if(!(0,k.existsSync)(e)){this.channel.debug(`Asset required for upload doesn't exist anymore ${e}`),c(!1);return}let g=(0,k.statSync)(e).size;if(g===l){if(o>0){this.channel.debug(`File size has not changed, verifying stabilization, ${e}, size: ${g}, equalSizeValidationCountLeft: ${o}`),o--,setTimeout(u,r);return}this.channel.debug(`File size has not changed, stabilization verified, ${e}, size: ${g}`),c(!0);return}if(this.channel.debug(`File size changed, waiting for stabilization, ${e}, previous size: ${l}, current size: ${g}`),Date.now()-s>n){this.channel.debug(`Asset required for upload is taking over ${n} ms to write to disk ${e}`),c(!0);return}l=g,setTimeout(u,r)},"checkFile");u()})}processAsset(e){switch(e.type){case"trace":return this.processTrace(e.path,e.testId);case"har":return this.processHar();case"rrweb-recording":case"esra":case"test-files":return this.addAsset(e);default:return}}async processHar(){}async calculateFileSha1Streaming(e){let r=(0,ge.createHash)("sha1"),n=(0,k.createReadStream)(e);return await(0,Sr.pipeline)(n,r),r.digest("hex")}async processTrace(e,r){if(this.processingPaths.has(e)){this.channel.debug(`Trace file ${e} already being processed, skipping`);return}this.processingPaths.add(e);let n;try{this.processingInProgress=!0,await De(1e3),n=ie("trace_processing",{test_suite_run_id:this.config.sessionId,test_id:r});let o=e;if(!this.isolationMode){this.channel.debug(`Preparing trace for upload (testId: ${r})...`),o=e.replace(".zip",".actual.zip"),(0,k.renameSync)(e,o);let l="checksum-playwright-trace:"+Date.now().toString()+(0,ge.randomBytes)(1024).toString("hex");(0,k.writeFileSync)(e,l)}let s=await a(async()=>await this.calculateFileSha1Streaming(e)+(0,V.extname)(e),"makePlaywrightHTMLReporterName")();this.channel.debug(`Trace file for test ${r} has been manipulated with file name ${s}, sending for upload...`),this.addAsset({type:"report-data-file",path:o,...r!==void 0?{testId:r}:{},fileName:s}),n==null||n.emit({outcome:"success",file_name:s})}catch(o){let c=String(o);this.channel.debug("Error processing trace file"+c),this.channel.trace("Trace Processing Error",{error:c}),n==null||n.emit({outcome:"error",error:Y(o)})}finally{this.processingPaths.delete(e),this.processingInProgress=!1}}addAsset(e){this.channel.debug("Adding file "+e.path);let r=this.initAsset(e);return this.assets.push(r),r}initAsset(e){return{complete:!1,error:!1,info:e,removeAfterUpload:e.type==="rrweb-recording"}}async acquirePortNumber(){return new Promise((e,r)=>{let n=Ar.createServer();n.unref(),n.on("error",r),n.listen(0,()=>{let o=n.address().port;n.close(()=>{e(o)})})})}};a(ot,"TestRunMonitor");var xe=ot,br;try{br=JSON.parse(process.argv[2]??"")}catch(t){console.log("Error starting test run monitor",t),process.exit(1)}var Ir;new xe(br,((Ir=process.argv)==null?void 0:Ir[3])==="isolated");0&&(module.exports={TestRunMonitor});
|
|
1
|
+
"use strict";var Fr=Object.create;var le=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Hr=Object.getOwnPropertyNames;var Wr=Object.getPrototypeOf,$r=Object.prototype.hasOwnProperty;var i=(e,t)=>le(e,"name",{value:t,configurable:!0});var W=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Gr=(e,t)=>{for(var r in t)le(e,r,{get:t[r],enumerable:!0})},st=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Hr(t))!$r.call(e,o)&&o!==r&&le(e,o,{get:()=>t[o],enumerable:!(n=Br(t,o))||n.enumerable});return e};var de=(e,t,r)=>(r=e!=null?Fr(Wr(e)):{},st(t||!e||!e.__esModule?le(r,"default",{value:e,enumerable:!0}):r,e)),jr=e=>st(le({},"__esModule",{value:!0}),e);var Pe=W((jo,ut)=>{ut.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Ee=W(ft=>{var pt={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Kr(e){return function(...t){return t.length&&(e=e.replace(/\{(\d)\}/g,(r,n)=>t[n]||"")),new Error("ADM-ZIP: "+e)}}i(Kr,"E");for(let e of Object.keys(pt))ft[e]=Kr(pt[e])});var Et=W((Ko,yt)=>{var Zr=require("fs"),P=require("path"),gt=Pe(),Jr=Ee(),Yr=typeof process=="object"&&process.platform==="win32",mt=i(e=>typeof e=="object"&&e!==null,"is_Obj"),ht=new Uint32Array(256).map((e,t)=>{for(let r=0;r<8;r++)(t&1)!==0?t=3988292384^t>>>1:t>>>=1;return t>>>0});function L(e){this.sep=P.sep,this.fs=Zr,mt(e)&&mt(e.fs)&&typeof e.fs.statSync=="function"&&(this.fs=e.fs)}i(L,"Utils");yt.exports=L;L.prototype.makeDir=function(e){let t=this;function r(n){let o=n.split(t.sep)[0];n.split(t.sep).forEach(function(a){if(!(!a||a.substr(-1,1)===":")){o+=t.sep+a;var s;try{s=t.fs.statSync(o)}catch(l){if(l.message&&l.message.startsWith("ENOENT"))t.fs.mkdirSync(o);else throw l}if(s&&s.isFile())throw Jr.FILE_IN_THE_WAY(`"${o}"`)}})}i(r,"mkdirSync"),r(e)};L.prototype.writeFileTo=function(e,t,r,n){let o=this;if(o.fs.existsSync(e)){if(!r)return!1;var a=o.fs.statSync(e);if(a.isDirectory())return!1}var s=P.dirname(e);o.fs.existsSync(s)||o.makeDir(s);var l;try{l=o.fs.openSync(e,"w",438)}catch{o.fs.chmodSync(e,438),l=o.fs.openSync(e,"w",438)}if(l)try{o.fs.writeSync(l,t,0,t.length,0)}finally{o.fs.closeSync(l)}return o.fs.chmodSync(e,n||438),!0};L.prototype.writeFileToAsync=function(e,t,r,n,o){typeof n=="function"&&(o=n,n=void 0);let a=this;a.fs.exists(e,function(s){if(s&&!r)return o(!1);a.fs.stat(e,function(l,p){if(s&&p&&p.isDirectory())return o(!1);var m=P.dirname(e);a.fs.exists(m,function(y){if(!y)try{a.makeDir(m)}catch{return o(!1)}let T=i(function(S){a.fs.write(S,t,0,t.length,0,function(C){a.fs.close(S,function(){if(C)return o(!1);a.fs.chmod(e,n||438,function(){o(!0)})})})},"writeToFd");a.fs.open(e,"w",438,function(S,C){S?a.fs.chmod(e,438,function(){a.fs.open(e,"w",438,function(u,f){if(u||!f)return o(!1);T(f)})}):C?T(C):o(!1)})})})})};L.prototype.findFiles=function(e){let t=this;function r(n,o,a,s){typeof o=="boolean"&&(a=o,o=void 0);let l=[];return t.fs.readdirSync(n).forEach(function(p){let m=P.join(n,p),y=t.fs.statSync(m);if((!o||o.test(m))&&l.push(P.normalize(m)+(y.isDirectory()?t.sep:"")),y.isDirectory()&&a){let T=t.fs.realpathSync(m);s.has(T)||(s.add(T),l=l.concat(r(m,o,a,s)))}}),l}return i(r,"findSync"),r(e,void 0,!0,new Set([t.fs.realpathSync(e)]))};L.prototype.findFilesAsync=function(e,t){let r=this,n=[],o=!1,a=i(function(l){o||(o=!0,t(l,l?void 0:n))},"finish"),s=i(function(l,p,m){r.fs.readdir(l,function(y,T){if(y)return m(y);let S=T.length;if(!S)return m();T.forEach(function(C){let u=P.join(l,C);r.fs.stat(u,function(f,d){if(f)return m(f);if(!d){--S||m();return}if(n.push(P.normalize(u)+(d.isDirectory()?r.sep:"")),!d.isDirectory()){--S||m();return}r.fs.realpath(u,function(h,E){if(h)return m(h);if(p.has(E)){--S||m();return}p.add(E),s(u,p,function(c){if(c)return m(c);--S||m()})})})})})},"walk");r.fs.realpath(e,function(l,p){if(l)return a(l);s(e,new Set([p]),a)})};L.prototype.getAttributes=function(){};L.prototype.setAttributes=function(){};L.crc32update=function(e,t){return ht[(e^t)&255]^e>>>8};L.crc32=function(e){typeof e=="string"&&(e=Buffer.from(e,"utf8"));let t=e.length,r=-1;for(let n=0;n<t;)r=L.crc32update(r,e[n++]);return~r>>>0};L.methodToString=function(e){switch(e){case gt.STORED:return"STORED ("+e+")";case gt.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}};L.canonical=function(e){if(!e)return"";let t=P.posix.normalize("/"+e.split("\\").join("/"));return P.join(".",t)};L.zipnamefix=function(e){if(!e)return"";let t=P.posix.normalize("/"+e.split("\\").join("/"));return P.posix.join(".",t)};L.findLast=function(e,t){if(!Array.isArray(e))throw new TypeError("arr is not array");let r=e.length>>>0;for(let n=r-1;n>=0;n--)if(t(e[n],n,e))return e[n]};L.sanitize=function(e,t){e=P.resolve(P.normalize(e));for(var r=t.split("/"),n=0,o=r.length;n<o;n++){var a=P.normalize(P.join(e,r.slice(n,o).join(P.sep)));if(a===e||a.startsWith(e+P.sep))return a}return P.normalize(P.join(e,P.basename(t)))};L.toBuffer=i(function(t,r){return Buffer.isBuffer(t)?t:t instanceof Uint8Array?Buffer.from(t):typeof t=="string"?r(t):Buffer.alloc(0)},"toBuffer");L.readBigUInt64LE=function(e,t){let r=e.readUInt32LE(t);return e.readUInt32LE(t+4)*4294967296+r};L.writeBigUInt64LE=function(e,t,r){let n=t>>>0,o=Math.floor(t/4294967296)>>>0;e.writeUInt32LE(n,r),e.writeUInt32LE(o,r+4)};L.fromDOS2Date=function(e){return new Date((e>>25&127)+1980,Math.max((e>>21&15)-1,0),Math.max(e>>16&31,1),e>>11&31,e>>5&63,(e&31)<<1)};L.fromDate2DOS=function(e){let t=0,r=0;return e.getFullYear()>1979&&(t=(e.getFullYear()-1980&127)<<9|e.getMonth()+1<<5|e.getDate(),r=e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1),t<<16|r};L.isWin=Yr;L.crcTable=ht});var _t=W((Jo,Tt)=>{var qr=require("path");Tt.exports=function(e,{fs:t}){var r=e||"",n=a(),o=null;function a(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return i(a,"newAttr"),r&&t.existsSync(r)?(o=t.statSync(r),n.directory=o.isDirectory(),n.mtime=o.mtime,n.atime=o.atime,n.executable=(73&o.mode)!==0,n.readonly=(128&o.mode)===0,n.hidden=qr.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return n.directory},get readOnly(){return n.readonly},get hidden(){return n.hidden},get mtime(){return n.mtime},get atime(){return n.atime},get executable(){return n.executable},decodeAttributes:i(function(){},"decodeAttributes"),encodeAttributes:i(function(){},"encodeAttributes"),toJSON:i(function(){return{path:r,isDirectory:n.directory,isReadOnly:n.readonly,isHidden:n.hidden,isExecutable:n.executable,mTime:n.mtime,aTime:n.atime}},"toJSON"),toString:i(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var Rt=W((qo,It)=>{It.exports={efs:!0,encode:i(e=>Buffer.from(e,"utf8"),"encode"),decode:i(e=>e.toString("utf8"),"decode")}});var re=W((Qo,te)=>{te.exports=Et();te.exports.Constants=Pe();te.exports.Errors=Ee();te.exports.FileAttr=_t();te.exports.decoder=Rt()});var Ct=W((es,St)=>{var q=re(),_=q.Constants;St.exports=function(){var e=20,t=10,r=0,n=0,o=0,a=0,s=0,l=0,p=0,m=0,y=0,T=0,S=0,C=0,u=0;e|=q.isWin?2560:768,r|=_.FLG_EFS;let f={extraLen:0},d=i(c=>Math.max(0,c)>>>0,"uint32"),h=i(c=>Math.max(0,c)&65535,"uint16"),E=i(c=>Math.max(0,c)&255,"uint8");return o=q.fromDate2DOS(new Date),{get made(){return e},set made(c){e=c},get version(){return t},set version(c){t=c},get flags(){return r},set flags(c){r=c},get flags_efs(){return(r&_.FLG_EFS)>0},set flags_efs(c){c?r|=_.FLG_EFS:r&=~_.FLG_EFS},get flags_desc(){return(r&_.FLG_DESC)>0},set flags_desc(c){c?r|=_.FLG_DESC:r&=~_.FLG_DESC},get method(){return n},set method(c){switch(c){case _.STORED:this.version=10;break;case _.DEFLATED:default:this.version=20}n=c},get time(){return q.fromDOS2Date(this.timeval)},set time(c){c=new Date(c),this.timeval=q.fromDate2DOS(c)},get timeval(){return o},set timeval(c){o=d(c)},get timeHighByte(){return E(o>>>8)},get crc(){return a},set crc(c){a=d(c)},get compressedSize(){return s},set compressedSize(c){s=d(c)},get size(){return l},set size(c){l=d(c)},get fileNameLength(){return p},set fileNameLength(c){p=c},get extraLength(){return m},set extraLength(c){m=c},get extraLocalLength(){return f.extraLen},set extraLocalLength(c){f.extraLen=c},get commentLength(){return y},set commentLength(c){y=c},get diskNumStart(){return T},set diskNumStart(c){T=d(c)},get inAttr(){return S},set inAttr(c){S=d(c)},get attr(){return C},set attr(c){C=d(c)},get fileAttr(){return(C||0)>>16&4095},get offset(){return u},set offset(c){u=d(c)},get encrypted(){return(r&_.FLG_ENC)===_.FLG_ENC},get centralHeaderSize(){return _.CENHDR+p+m+y},get realDataOffset(){return u+_.LOCHDR+f.fnameLen+f.extraLen},get localHeader(){return f},loadLocalHeaderFromBinary:i(function(c){var g=c.slice(u,u+_.LOCHDR);if(g.readUInt32LE(0)!==_.LOCSIG)throw q.Errors.INVALID_LOC();f.version=g.readUInt16LE(_.LOCVER),f.flags=g.readUInt16LE(_.LOCFLG),f.flags_desc=(f.flags&_.FLG_DESC)>0,f.method=g.readUInt16LE(_.LOCHOW),f.time=g.readUInt32LE(_.LOCTIM),f.crc=g.readUInt32LE(_.LOCCRC),f.compressedSize=g.readUInt32LE(_.LOCSIZ),f.size=g.readUInt32LE(_.LOCLEN),f.fnameLen=g.readUInt16LE(_.LOCNAM),f.extraLen=g.readUInt16LE(_.LOCEXT);let R=u+_.LOCHDR+f.fnameLen,A=R+f.extraLen;return c.slice(R,A)},"loadLocalHeaderFromBinary"),loadFromBinary:i(function(c){if(c.length!==_.CENHDR||c.readUInt32LE(0)!==_.CENSIG)throw q.Errors.INVALID_CEN();e=c.readUInt16LE(_.CENVEM),t=c.readUInt16LE(_.CENVER),r=c.readUInt16LE(_.CENFLG),n=c.readUInt16LE(_.CENHOW),o=c.readUInt32LE(_.CENTIM),a=c.readUInt32LE(_.CENCRC),s=c.readUInt32LE(_.CENSIZ),l=c.readUInt32LE(_.CENLEN),p=c.readUInt16LE(_.CENNAM),m=c.readUInt16LE(_.CENEXT),y=c.readUInt16LE(_.CENCOM),T=c.readUInt16LE(_.CENDSK),S=c.readUInt16LE(_.CENATT),C=c.readUInt32LE(_.CENATX),u=c.readUInt32LE(_.CENOFF)},"loadFromBinary"),localHeaderToBinary:i(function(){var c=Buffer.alloc(_.LOCHDR);return c.writeUInt32LE(_.LOCSIG,0),c.writeUInt16LE(t,_.LOCVER),c.writeUInt16LE(r&~_.FLG_DESC,_.LOCFLG),c.writeUInt16LE(n,_.LOCHOW),c.writeUInt32LE(o,_.LOCTIM),c.writeUInt32LE(a,_.LOCCRC),c.writeUInt32LE(s,_.LOCSIZ),c.writeUInt32LE(l,_.LOCLEN),c.writeUInt16LE(p,_.LOCNAM),c.writeUInt16LE(f.extraLen,_.LOCEXT),c},"localHeaderToBinary"),centralHeaderToBinary:i(function(){var c=Buffer.alloc(_.CENHDR+p+m+y);return c.writeUInt32LE(_.CENSIG,0),c.writeUInt16LE(e,_.CENVEM),c.writeUInt16LE(t,_.CENVER),c.writeUInt16LE(r&~_.FLG_DESC,_.CENFLG),c.writeUInt16LE(n,_.CENHOW),c.writeUInt32LE(o,_.CENTIM),c.writeUInt32LE(a,_.CENCRC),c.writeUInt32LE(s,_.CENSIZ),c.writeUInt32LE(l,_.CENLEN),c.writeUInt16LE(p,_.CENNAM),c.writeUInt16LE(m,_.CENEXT),c.writeUInt16LE(y,_.CENCOM),c.writeUInt16LE(T,_.CENDSK),c.writeUInt16LE(S,_.CENATT),c.writeUInt32LE(C,_.CENATX),c.writeUInt32LE(u,_.CENOFF),c},"centralHeaderToBinary"),toJSON:i(function(){let c=i(function(g){return g+" bytes"},"bytes");return{made:e,version:t,flags:r,method:q.methodToString(n),time:this.time,crc:"0x"+a.toString(16).toUpperCase(),compressedSize:c(s),size:c(l),fileNameLength:c(p),extraLength:c(m),commentLength:c(y),diskNumStart:T,inAttr:S,attr:C,offset:u,centralHeaderSize:c(_.CENHDR+p+m+y)}},"toJSON"),toString:i(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var bt=W((rs,At)=>{var K=re(),b=K.Constants;At.exports=function(){var e=0,t=0,r=0,n=0,o=0;let a=i(()=>e>b.EF_ZIP64_OR_16||t>b.EF_ZIP64_OR_16||r>b.EF_ZIP64_OR_32||n>b.EF_ZIP64_OR_32,"needsZip64");return{get diskEntries(){return e},set diskEntries(s){e=t=s},get totalEntries(){return t},set totalEntries(s){t=e=s},get size(){return r},set size(s){r=s},get offset(){return n},set offset(s){n=s},get commentLength(){return o},set commentLength(s){o=s},get mainHeaderSize(){return(a()?b.ZIP64HDR+b.END64HDR:0)+b.ENDHDR+o},loadFromBinary:i(function(s){if((s.length!==b.ENDHDR||s.readUInt32LE(0)!==b.ENDSIG)&&(s.length<b.ZIP64HDR||s.readUInt32LE(0)!==b.ZIP64SIG))throw K.Errors.INVALID_END();s.readUInt32LE(0)===b.ENDSIG?(e=s.readUInt16LE(b.ENDSUB),t=s.readUInt16LE(b.ENDTOT),r=s.readUInt32LE(b.ENDSIZ),n=s.readUInt32LE(b.ENDOFF),o=s.readUInt16LE(b.ENDCOM)):(e=K.readBigUInt64LE(s,b.ZIP64SUB),t=K.readBigUInt64LE(s,b.ZIP64TOT),r=K.readBigUInt64LE(s,b.ZIP64SIZB),n=K.readBigUInt64LE(s,b.ZIP64OFF),o=0)},"loadFromBinary"),toBinary:i(function(){if(!a()){var s=Buffer.alloc(b.ENDHDR+o);return s.writeUInt32LE(b.ENDSIG,0),s.writeUInt32LE(0,4),s.writeUInt16LE(e,b.ENDSUB),s.writeUInt16LE(t,b.ENDTOT),s.writeUInt32LE(r,b.ENDSIZ),s.writeUInt32LE(n,b.ENDOFF),s.writeUInt16LE(o,b.ENDCOM),s.fill(" ",b.ENDHDR),s}var s=Buffer.alloc(this.mainHeaderSize);let l=0;s.writeUInt32LE(b.ZIP64SIG,l),K.writeBigUInt64LE(s,b.ZIP64HDR-b.ZIP64LEAD,l+b.ZIP64SIZE),s.writeUInt16LE(45,l+b.ZIP64VEM),s.writeUInt16LE(45,l+b.ZIP64VER),s.writeUInt32LE(0,l+b.ZIP64DSK),s.writeUInt32LE(0,l+b.ZIP64DSKDIR),K.writeBigUInt64LE(s,e,l+b.ZIP64SUB),K.writeBigUInt64LE(s,t,l+b.ZIP64TOT),K.writeBigUInt64LE(s,r,l+b.ZIP64SIZB),K.writeBigUInt64LE(s,n,l+b.ZIP64OFF);let p=n+r;return l+=b.ZIP64HDR,s.writeUInt32LE(b.END64SIG,l),s.writeUInt32LE(0,l+b.END64START),K.writeBigUInt64LE(s,p,l+b.END64OFF),s.writeUInt32LE(1,l+b.END64NUMDISKS),l+=b.END64HDR,s.writeUInt32LE(b.ENDSIG,l),s.writeUInt32LE(0,l+4),s.writeUInt16LE(Math.min(e,b.EF_ZIP64_OR_16),l+b.ENDSUB),s.writeUInt16LE(Math.min(t,b.EF_ZIP64_OR_16),l+b.ENDTOT),s.writeUInt32LE(Math.min(r,b.EF_ZIP64_OR_32),l+b.ENDSIZ),s.writeUInt32LE(Math.min(n,b.EF_ZIP64_OR_32),l+b.ENDOFF),s.writeUInt16LE(o,l+b.ENDCOM),s.fill(" ",l+b.ENDHDR),s},"toBinary"),toJSON:i(function(){let s=i(function(l,p){let m=l.toString(16).toUpperCase();for(;m.length<p;)m="0"+m;return"0x"+m},"offset");return{diskEntries:e,totalEntries:t,size:r+" bytes",offset:s(n,4),commentLength:o}},"toJSON"),toString:i(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var Fe=W(Ue=>{Ue.EntryHeader=Ct();Ue.MainHeader=bt()});var vt=W((ss,wt)=>{wt.exports=function(e){var t=require("zlib"),r={chunkSize:(parseInt(e.length/1024)+1)*1024};return{deflate:i(function(){return t.deflateRawSync(e,r)},"deflate"),deflateAsync:i(function(n){var o=t.createDeflateRaw(r),a=[],s=0;o.on("data",function(l){a.push(l),s+=l.length}),o.on("end",function(){var l=Buffer.alloc(s),p=0;l.fill(0);for(var m=0;m<a.length;m++){var y=a[m];y.copy(l,p),p+=y.length}n&&n(l)}),o.end(e)},"deflateAsync")}}});var xt=W((as,Dt)=>{var Xr=+(process?.versions?.node??"").split(".")[0]||0;Dt.exports=function(e,t){var r=require("zlib");let n=Xr>=15&&t>0?{maxOutputLength:t}:{};return{inflate:i(function(){return r.inflateRawSync(e,n)},"inflate"),inflateAsync:i(function(o){var a=r.createInflateRaw(n),s=[],l=0;a.on("data",function(p){s.push(p),l+=p.length}),a.on("end",function(){var p=Buffer.alloc(l),m=0;p.fill(0);for(var y=0;y<s.length;y++){var T=s[y];T.copy(p,m),m+=T.length}o&&o(p)}),a.end(e)},"inflateAsync")}}});var kt=W((ls,Mt)=>{"use strict";var{randomFillSync:Nt}=require("crypto"),Qr=Ee(),en=new Uint32Array(256).map((e,t)=>{for(let r=0;r<8;r++)(t&1)!==0?t=t>>>1^3988292384:t>>>=1;return t>>>0}),Ot=i((e,t)=>Math.imul(e,t)>>>0,"uMul"),Lt=i((e,t)=>en[(e^t)&255]^e>>>8,"crc32update"),ue=i(()=>typeof Nt=="function"?Nt(Buffer.alloc(12)):ue.node(),"genSalt");ue.node=()=>{let e=Buffer.alloc(12),t=e.length;for(let r=0;r<t;r++)e[r]=Math.random()*256&255;return e};var Te={genSalt:ue};function _e(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<t.length;r++)this.updateKeys(t[r])}i(_e,"Initkeys");_e.prototype.updateKeys=function(e){let t=this.keys;return t[0]=Lt(t[0],e),t[1]+=t[0]&255,t[1]=Ot(t[1],134775813)+1,t[2]=Lt(t[2],t[1]>>>24),e};_e.prototype.next=function(){let e=(this.keys[2]|2)>>>0;return Ot(e,e^1)>>8&255};function tn(e){let t=new _e(e);return function(r){let n=Buffer.alloc(r.length),o=0;for(let a of r)n[o++]=t.updateKeys(a^t.next());return n}}i(tn,"make_decrypter");function rn(e){let t=new _e(e);return function(r,n,o=0){n||(n=Buffer.alloc(r.length));for(let a of r){let s=t.next();n[o++]=a^s,t.updateKeys(a)}return n}}i(rn,"make_encrypter");function nn(e,t,r){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);let n=tn(r),o=n(e.slice(0,12)),a=(t.flags&8)===8?t.timeHighByte:t.crc>>>24;if(o[11]!==a)throw Qr.WRONG_PASSWORD();return n(e.slice(12))}i(nn,"decrypt");function on(e){Buffer.isBuffer(e)&&e.length>=12?Te.genSalt=function(){return e.slice(0,12)}:e==="node"?Te.genSalt=ue.node:Te.genSalt=ue}i(on,"_salter");function sn(e,t,r,n=!1){e==null&&(e=Buffer.alloc(0)),Buffer.isBuffer(e)||(e=Buffer.from(e.toString()));let o=rn(r),a=Te.genSalt();a[11]=t.crc>>>24&255,n&&(a[10]=t.crc>>>16&255);let s=Buffer.alloc(e.length+12);return o(a,s),o(e,s,12)}i(sn,"encrypt");Mt.exports={decrypt:nn,encrypt:sn,_salter:on}});var Pt=W(Ie=>{Ie.Deflater=vt();Ie.Inflater=xt();Ie.ZipCrypto=kt()});var He=W((ps,Ut)=>{var N=re(),an=Fe(),z=N.Constants,Be=Pt();Ut.exports=function(e,t){var r=new an.EntryHeader,n=Buffer.alloc(0),o=Buffer.alloc(0),a=!1,s=null,l=Buffer.alloc(0),p=Buffer.alloc(0),m=!0;let y=e,T=typeof y.decoder=="object"?y.decoder:N.decoder;m=T.hasOwnProperty("efs")?T.efs:!1;function S(){return!t||!(t instanceof Uint8Array)?Buffer.alloc(0):(p=r.loadLocalHeaderFromBinary(t),t.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}i(S,"getCompressedDataFromZip");function C(c){let g=r.flags_desc||r.localHeader.flags_desc?r.crc:r.localHeader.crc;return N.crc32(c)===g}i(C,"crc32OK");function u(c,g,R){if(typeof g>"u"&&typeof c=="string"&&(R=c,c=void 0),a)return c&&g&&g(Buffer.alloc(0),N.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var A=S();if(A.length===0)return c&&g&&g(A),A;if(r.encrypted){if(typeof R!="string"&&!Buffer.isBuffer(R))throw N.Errors.INVALID_PASS_PARAM();A=Be.ZipCrypto.decrypt(A,r,R)}var I;switch(r.method){case N.Constants.STORED:if(I=Buffer.alloc(A.length),A.copy(I),C(I))return c&&g&&g(I),I;throw c&&g&&g(I,N.Errors.BAD_CRC()),N.Errors.BAD_CRC();case N.Constants.DEFLATED:var w=new Be.Inflater(A,r.size);if(c)w.inflateAsync(function(v){g&&(C(v)?g(v):g(v,N.Errors.BAD_CRC()))});else{if(I=w.inflate(),!C(I))throw N.Errors.BAD_CRC(`"${T.decode(n)}"`);return I}break;default:throw c&&g&&g(Buffer.alloc(0),N.Errors.UNKNOWN_METHOD()),N.Errors.UNKNOWN_METHOD()}}i(u,"decompress");function f(c,g){if((!s||!s.length)&&Buffer.isBuffer(t))return c&&g&&g(S()),S();if(s.length&&!a){var R;switch(r.method){case N.Constants.STORED:return r.compressedSize=r.size,R=Buffer.alloc(s.length),s.copy(R),c&&g&&g(R),R;default:case N.Constants.DEFLATED:var A=new Be.Deflater(s);if(c)A.deflateAsync(function(w){R=Buffer.alloc(w.length),r.compressedSize=w.length,w.copy(R),g&&g(R)});else{var I=A.deflate();return r.compressedSize=I.length,I}A=null;break}}else if(c&&g)g(Buffer.alloc(0));else return Buffer.alloc(0)}i(f,"compress");function d(c,g){return N.readBigUInt64LE(c,g)}i(d,"readUInt64LE");function h(c){try{for(var g=0,R,A,I;g+4<c.length;)R=c.readUInt16LE(g),g+=2,A=c.readUInt16LE(g),g+=2,I=c.slice(g,g+A),g+=A,z.ID_ZIP64===R&&E(I)}catch{throw N.Errors.EXTRA_FIELD_PARSE_ERROR()}}i(h,"parseExtra");function E(c){var g,R,A,I;c.length>=z.EF_ZIP64_SCOMP&&(g=d(c,z.EF_ZIP64_SUNCOMP),r.size===z.EF_ZIP64_OR_32&&(r.size=g)),c.length>=z.EF_ZIP64_RHO&&(R=d(c,z.EF_ZIP64_SCOMP),r.compressedSize===z.EF_ZIP64_OR_32&&(r.compressedSize=R)),c.length>=z.EF_ZIP64_DSN&&(A=d(c,z.EF_ZIP64_RHO),r.offset===z.EF_ZIP64_OR_32&&(r.offset=A)),c.length>=z.EF_ZIP64_DSN+4&&(I=c.readUInt32LE(z.EF_ZIP64_DSN),r.diskNumStart===z.EF_ZIP64_OR_16&&(r.diskNumStart=I))}return i(E,"parseZip64ExtendedInformation"),{get entryName(){return T.decode(n)},get rawEntryName(){return n},set entryName(c){n=N.toBuffer(c,T.encode);var g=n[n.length-1];a=g===47||g===92,r.fileNameLength=n.length},get efs(){return typeof m=="function"?m(this.entryName):m},get extra(){return l},set extra(c){l=c,r.extraLength=c.length,h(c)},get comment(){return T.decode(o)},set comment(c){if(o=N.toBuffer(c,T.encode),r.commentLength=o.length,o.length>65535)throw N.Errors.COMMENT_TOO_LONG()},get name(){let c=T.decode(n);return a?c.replace(/[/\\]$/,"").split("/").pop():c.split("/").pop()},get isDirectory(){return a},getCompressedData:i(function(){return f(!1,null)},"getCompressedData"),getCompressedDataAsync:i(function(c){f(!0,c)},"getCompressedDataAsync"),setData:i(function(c){s=N.toBuffer(c,N.decoder.encode),!a&&s.length?(r.size=s.length,r.method=N.Constants.DEFLATED,r.crc=N.crc32(c),r.changed=!0):r.method=N.Constants.STORED},"setData"),getData:i(function(c){return r.changed?s:u(!1,null,c)},"getData"),getDataAsync:i(function(c,g){r.changed?c(s):u(!0,c,g)},"getDataAsync"),set attr(c){r.attr=c},get attr(){return r.attr},set header(c){r.loadFromBinary(c)},get header(){return r},packCentralHeader:i(function(){r.flags_efs=this.efs,r.extraLength=l.length;var c=r.centralHeaderToBinary(),g=N.Constants.CENHDR;return n.copy(c,g),g+=n.length,l.copy(c,g),g+=r.extraLength,o.copy(c,g),c},"packCentralHeader"),packLocalHeader:i(function(){let c=0;r.flags_efs=this.efs,r.extraLocalLength=p.length;let g=r.localHeaderToBinary(),R=Buffer.alloc(g.length+n.length+r.extraLocalLength);return g.copy(R,c),c+=g.length,n.copy(R,c),c+=n.length,p.copy(R,c),c+=p.length,R},"packLocalHeader"),toJSON:i(function(){let c=i(function(g){return"<"+(g&&g.length+" bytes buffer"||"null")+">"},"bytes");return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:c(t),data:c(s)}},"toJSON"),toString:i(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var Ht=W((gs,Bt)=>{var Ft=He(),cn=Fe(),G=re();Bt.exports=function(e,t){var r=[],n=Object.create(null),o=Buffer.alloc(0),a=new cn.MainHeader,s=!1,l=null;let p=new Set,m=t,{noSort:y,decoder:T}=m;e?u(m.readEntries):s=!0;function S(){let d=new Set;for(let h of Object.keys(n)){let E=h.split("/");if(E.pop(),!!E.length)for(let c=0;c<E.length;c++){let g=E.slice(0,c+1).join("/")+"/";d.add(g)}}for(let h of d)if(!(h in n)){let E=new Ft(m);E.entryName=h,E.attr=16,E.temporary=!0,r.push(E),n[E.entryName]=E,p.add(E)}}i(S,"makeTemporaryFolders");function C(){if(s=!0,n=Object.create(null),a.diskEntries>(e.length-a.offset)/G.Constants.CENHDR)throw G.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(a.diskEntries);for(var d=a.offset,h=0;h<r.length;h++){var E=d,c=new Ft(m,e);c.header=e.slice(E,E+=G.Constants.CENHDR),c.entryName=e.slice(E,E+=c.header.fileNameLength),c.header.extraLength&&(c.extra=e.slice(E,E+=c.header.extraLength)),c.header.commentLength&&(c.comment=e.slice(E,E+c.header.commentLength)),d+=c.header.centralHeaderSize,r[h]=c,n[c.entryName]=c}p.clear(),S()}i(C,"readEntries");function u(d){var h=e.length-G.Constants.ENDHDR,E=Math.max(0,h-65535),c=E,g=e.length,R=-1,A=0;for(typeof m.trailingSpace=="boolean"&&m.trailingSpace&&(E=0),h;h>=c;h--)if(e[h]===80){if(e.readUInt32LE(h)===G.Constants.ENDSIG){R=h,A=h,g=h+G.Constants.ENDHDR,c=h-G.Constants.END64HDR;continue}if(e.readUInt32LE(h)===G.Constants.END64SIG){c=E;continue}if(e.readUInt32LE(h)===G.Constants.ZIP64SIG){R=h,g=h+G.readBigUInt64LE(e,h+G.Constants.ZIP64SIZE)+G.Constants.ZIP64LEAD;break}}if(R==-1)throw G.Errors.INVALID_FORMAT();a.loadFromBinary(e.slice(R,g)),a.commentLength&&(o=e.slice(A+G.Constants.ENDHDR)),d&&C()}i(u,"readMainHeader");function f(){r.length>1&&!y&&(r=r.map(d=>({entry:d,key:d.entryName.toLowerCase()})).sort((d,h)=>d.key.localeCompare(h.key)).map(d=>d.entry))}return i(f,"sortEntries"),{get entries(){return s||C(),r.filter(d=>!p.has(d))},get comment(){return T.decode(o)},set comment(d){o=G.toBuffer(d,T.encode),a.commentLength=o.length},getEntryCount:i(function(){return s?r.length:a.diskEntries},"getEntryCount"),forEach:i(function(d){this.entries.forEach(d)},"forEach"),getEntry:i(function(d){return s||C(),n[d]||null},"getEntry"),setEntry:i(function(d){s||C(),r.push(d),n[d.entryName]=d,a.totalEntries=r.length},"setEntry"),deleteFile:i(function(d,h=!0){s||C();let E=n[d];this.getEntryChildren(E,h).map(g=>g.entryName).forEach(this.deleteEntry)},"deleteFile"),deleteEntry:i(function(d){s||C();let h=n[d],E=r.indexOf(h);E>=0&&(r.splice(E,1),delete n[d],a.totalEntries=r.length)},"deleteEntry"),getEntryChildren:i(function(d,h=!0){if(s||C(),typeof d=="object")if(d.isDirectory&&h){let E=[],c=d.entryName;for(let g of r)g.entryName.startsWith(c)&&E.push(g);return E}else return[d];return[]},"getEntryChildren"),getChildCount:i(function(d){if(d&&d.isDirectory){let h=this.getEntryChildren(d);return h.includes(d)?h.length-1:h.length}return 0},"getChildCount"),compressToBuffer:i(function(){s||C(),f();let d=[],h=[],E=0,c=0;a.size=0,a.offset=0;let g=0;for(let I of this.entries){let w=I.getCompressedData();I.header.offset=c;let v=I.packLocalHeader(),D=v.length+w.length;c+=D,d.push(v),d.push(w);let x=I.packCentralHeader();h.push(x),a.size+=x.length,E+=D+x.length,g++}E+=a.mainHeaderSize,a.offset=c,a.totalEntries=g,c=0;let R=Buffer.alloc(E);for(let I of d)I.copy(R,c),c+=I.length;for(let I of h)I.copy(R,c),c+=I.length;let A=a.toBinary();return o&&o.copy(A,A.length-o.length),A.copy(R,c),e=R,s=!1,R},"compressToBuffer"),toAsyncBuffer:i(function(d,h,E,c){try{s||C(),f();let g=[],R=[],A=0,I=0,w=0;a.size=0,a.offset=0;let v=i(function(D){if(D.length>0){let x=D.shift(),H=x.entryName+x.extra.toString();E&&E(H),x.getCompressedDataAsync(function($){c&&c(H),x.header.offset=I;let X=x.packLocalHeader(),ye=X.length+$.length;I+=ye,g.push(X),g.push($);let ce=x.packCentralHeader();R.push(ce),a.size+=ce.length,A+=ye+ce.length,w++,v(D)})}else{A+=a.mainHeaderSize,a.offset=I,a.totalEntries=w,I=0;let x=Buffer.alloc(A);g.forEach(function($){$.copy(x,I),I+=$.length}),R.forEach(function($){$.copy(x,I),I+=$.length});let H=a.toBinary();o&&o.copy(H,H.length-o.length),H.copy(x,I),e=x,s=!1,d(x)}},"compress2Buffer");v(Array.from(this.entries))}catch(g){h(g)}},"toAsyncBuffer")}}});var Gt=W((hs,$t)=>{var M=re(),O=require("path"),ln=He(),dn=Ht(),Q=i((...e)=>M.findLast(e,t=>typeof t=="boolean"),"get_Bool"),Wt=i((...e)=>M.findLast(e,t=>typeof t=="string"),"get_Str"),un=i((...e)=>M.findLast(e,t=>typeof t=="function"),"get_Fun"),pn={noSort:!1,readEntries:!1,method:M.Constants.NONE,fs:null};$t.exports=function(e,t){let r=null,n=Object.assign(Object.create(null),pn);e&&typeof e=="object"&&(e instanceof Uint8Array||(Object.assign(n,e),e=n.input?n.input:void 0,n.input&&delete n.input),Buffer.isBuffer(e)&&(r=e,n.method=M.Constants.BUFFER,e=void 0)),Object.assign(n,t);let o=new M(n),a=i(u=>{u.filter(f=>f.attr).sort((f,d)=>d.path.length-f.path.length).forEach(f=>o.fs.chmodSync(f.path,f.attr))},"applyDirAttributes");if((typeof n.decoder!="object"||typeof n.decoder.encode!="function"||typeof n.decoder.decode!="function")&&(n.decoder=M.decoder),e&&typeof e=="string")if(o.fs.existsSync(e))n.method=M.Constants.FILE,n.filename=e,r=o.fs.readFileSync(e);else throw M.Errors.INVALID_FILENAME();let s=new dn(r,n),{canonical:l,sanitize:p,zipnamefix:m}=M;function y(u){if(u&&s){var f;if(typeof u=="string"&&(f=s.getEntry(O.posix.normalize(u))),typeof u=="object"&&typeof u.entryName<"u"&&typeof u.header<"u"&&(f=s.getEntry(u.entryName)),f)return f}return null}i(y,"getEntry");function T(u){let{join:f,normalize:d,sep:h}=O.posix;return f(O.isAbsolute(u)?"/":".",d(h+u.split("\\").join(h)+h))}i(T,"fixPath");function S(u){return u instanceof RegExp?(function(f){return function(d){return f.test(d)}})(u):typeof u!="function"?()=>!0:u}i(S,"filenameFilter");let C=i((u,f)=>{let d=f.slice(-1);return d=d===o.sep?o.sep:"",O.relative(u,f)+d},"relativePath");return{readFile:i(function(u,f){var d=y(u);return d&&d.getData(f)||null},"readFile"),childCount:i(function(u){let f=y(u);if(f)return s.getChildCount(f)},"childCount"),readFileAsync:i(function(u,f){var d=y(u);d?d.getDataAsync(f):f(null,"getEntry failed for:"+u)},"readFileAsync"),readAsText:i(function(u,f){var d=y(u);if(d){var h=d.getData();if(h&&h.length)return h.toString(f||"utf8")}return""},"readAsText"),readAsTextAsync:i(function(u,f,d){var h=y(u);h?h.getDataAsync(function(E,c){if(c){f(E,c);return}E&&E.length?f(E.toString(d||"utf8")):f("")}):f("")},"readAsTextAsync"),deleteFile:i(function(u,f=!0){var d=y(u);d&&s.deleteFile(d.entryName,f)},"deleteFile"),deleteEntry:i(function(u){var f=y(u);f&&s.deleteEntry(f.entryName)},"deleteEntry"),addZipComment:i(function(u){s.comment=u},"addZipComment"),getZipComment:i(function(){return s.comment||""},"getZipComment"),addZipEntryComment:i(function(u,f){var d=y(u);d&&(d.comment=f)},"addZipEntryComment"),getZipEntryComment:i(function(u){var f=y(u);return f&&f.comment||""},"getZipEntryComment"),updateFile:i(function(u,f){var d=y(u);d&&d.setData(f)},"updateFile"),addLocalFile:i(function(u,f,d,h){if(o.fs.existsSync(u)){f=f?T(f):"";let E=O.win32.basename(O.win32.normalize(u));f+=d||E;let c=o.fs.statSync(u),g=c.isFile()?o.fs.readFileSync(u):Buffer.alloc(0);c.isDirectory()&&(f+=o.sep),this.addFile(f,g,h,c)}else throw M.Errors.FILE_NOT_FOUND(u)},"addLocalFile"),addLocalFileAsync:i(function(u,f){u=typeof u=="object"?u:{localPath:u};let d=O.resolve(u.localPath),{comment:h}=u,{zipPath:E,zipName:c}=u,g=this;o.fs.stat(d,function(R,A){if(R)return f(R,!1);E=E?T(E):"";let I=O.win32.basename(O.win32.normalize(d));if(E+=c||I,A.isFile())o.fs.readFile(d,function(w,v){return w?f(w,!1):(g.addFile(E,v,h,A),setImmediate(f,void 0,!0))});else if(A.isDirectory())return E+=o.sep,g.addFile(E,Buffer.alloc(0),h,A),setImmediate(f,void 0,!0)})},"addLocalFileAsync"),addLocalFolder:i(function(u,f,d){if(d=S(d),f=f?T(f):"",u=O.normalize(u),o.fs.existsSync(u)){let h=o.findFiles(u),E=this;if(h.length)for(let c of h){let g=O.join(f,C(u,c));d(g)&&E.addLocalFile(c,O.dirname(g))}}else throw M.Errors.FILE_NOT_FOUND(u)},"addLocalFolder"),addLocalFolderAsync:i(function(u,f,d,h){h=S(h),d=d?T(d):"",u=O.normalize(u);var E=this;o.fs.open(u,"r",function(c){if(c&&c.code==="ENOENT")f(void 0,M.Errors.FILE_NOT_FOUND(u));else if(c)f(void 0,c);else{var g=o.findFiles(u),R=-1,A=i(function(){if(R+=1,R<g.length){var I=g[R],w=C(u,I).split("\\").join("/");w=w.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),h(w)?o.fs.stat(I,function(v,D){v&&f(void 0,v),D.isFile()?o.fs.readFile(I,function(x,H){x?f(void 0,x):(E.addFile(d+w,H,"",D),A())}):(E.addFile(d+w+"/",Buffer.alloc(0),"",D),A())}):process.nextTick(()=>{A()})}else f(!0,void 0)},"next");A()}})},"addLocalFolderAsync"),addLocalFolderAsync2:i(function(u,f){let d=this;u=typeof u=="object"?u:{localPath:u};let h=O.resolve(T(u.localPath)),{zipPath:E,filter:c,namefix:g}=u;c instanceof RegExp?c=(function(I){return function(w){return I.test(w)}})(c):typeof c!="function"&&(c=i(function(){return!0},"filter")),E=E?T(E):"",g==="latin1"&&(g=i(I=>I.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),"namefix")),typeof g!="function"&&(g=i(I=>I,"namefix"));let R=i(I=>O.join(E,g(C(h,I))),"relPathFix"),A=i(I=>O.win32.basename(O.win32.normalize(g(I))),"fileNameFix");o.fs.open(h,"r",function(I){I&&I.code==="ENOENT"?f(void 0,M.Errors.FILE_NOT_FOUND(h)):I?f(void 0,I):o.findFilesAsync(h,function(w,v){if(w)return f(w);v=v.filter(D=>c(R(D))),v.length||f(void 0,!1),setImmediate(v.reverse().reduce(function(D,x){return function(H,$){if(H||$===!1)return setImmediate(D,H,!1);d.addLocalFileAsync({localPath:x,zipPath:O.dirname(R(x)),zipName:A(x)},D)}},f))})})},"addLocalFolderAsync2"),addLocalFolderPromise:i(function(u,f){return new Promise((d,h)=>{this.addLocalFolderAsync2(Object.assign({localPath:u},f),(E,c)=>{E&&h(E),c&&d(this)})})},"addLocalFolderPromise"),addFile:i(function(u,f,d,h){u=m(u);let E=y(u),c=E!=null;c||(E=new ln(n),E.entryName=u),E.comment=d||"";let g=typeof h=="object"&&h instanceof o.fs.Stats;g&&(E.header.time=h.mtime);var R=E.isDirectory?16:0;let A=E.isDirectory?16384:32768;return g?A|=4095&h.mode:typeof h=="number"?A|=4095&h:A|=E.isDirectory?493:420,R=(R|A<<16)>>>0,E.attr=R,E.setData(f),c||s.setEntry(E),E},"addFile"),getEntries:i(function(u){return s.password=u,s?s.entries:[]},"getEntries"),getEntry:i(function(u){return y(u)},"getEntry"),getEntryCount:i(function(){return s.getEntryCount()},"getEntryCount"),forEach:i(function(u){return s.forEach(u)},"forEach"),extractEntryTo:i(function(u,f,d,h,E,c){h=Q(!1,h),E=Q(!1,E),d=Q(!0,d),c=Wt(E,c);var g=y(u);if(!g)throw M.Errors.NO_ENTRY();var R=l(g.entryName),A=p(f,c&&!g.isDirectory?l(c):d?R:O.basename(R));if(g.isDirectory){var I=s.getEntryChildren(g);return I.forEach(function(D){if(D.isDirectory)return;var x=D.getData();if(!x)throw M.Errors.CANT_EXTRACT_FILE();var H=l(d?D.entryName:D.entryName.substring(g.entryName.length)),$=p(f,H);let X=E?D.header.fileAttr:void 0;o.writeFileTo($,x,h,X)}),!0}var w=g.getData(s.password);if(!w)throw M.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(A)&&!h)throw M.Errors.CANT_OVERRIDE();let v=E?u.header.fileAttr:void 0;return o.writeFileTo(A,w,h,v),!0},"extractEntryTo"),test:i(function(u){if(!s)return!1;for(var f of s.entries)try{if(f.isDirectory)continue;var d=f.getData(u);if(!d)return!1}catch{return!1}return!0},"test"),extractAllTo:i(function(u,f,d,h){if(d=Q(!1,d),h=Wt(d,h),f=Q(!1,f),!s)throw M.Errors.NO_ZIP();let E=[];s.entries.forEach(function(c){var g=p(u,l(c.entryName));if(c.isDirectory){o.makeDir(g),d&&E.push({path:g,attr:c.header.fileAttr});return}var R=c.getData(h);if(!R)throw M.Errors.CANT_EXTRACT_FILE();let A=d?c.header.fileAttr:void 0;o.writeFileTo(g,R,f,A);try{o.fs.utimesSync(g,c.header.time,c.header.time)}catch{}}),a(E)},"extractAllTo"),extractAllToAsync:i(function(u,f,d,h){if(h=un(f,d,h),d=Q(!1,d),f=Q(!1,f),!h)return new Promise((w,v)=>{this.extractAllToAsync(u,f,d,function(D){D?v(D):w(this)})});if(!s){h(M.Errors.NO_ZIP());return}u=O.resolve(u);let E=i(w=>p(u,O.normalize(l(w.entryName))),"getPath"),c=i((w,v)=>new Error(w+': "'+v+'"'),"getError"),g=[],R=[];s.entries.forEach(w=>{w.isDirectory?g.push(w):R.push(w)});let A=[];for(let w of g){let v=E(w),D=d?w.header.fileAttr:void 0;try{o.makeDir(v)}catch{h(c("Unable to create folder",v));continue}D&&A.push({path:v,attr:D});try{o.fs.utimesSync(v,w.header.time,w.header.time)}catch{}}let I=i(w=>{if(!w)try{a(A)}catch(v){return h(c("Unable to set folder permissions",v.path||""))}h(w)},"done");R.reverse().reduce(function(w,v){return function(D){if(D)w(D);else{let x=O.normalize(l(v.entryName)),H=p(u,x);v.getDataAsync(function($,X){if(X)w(X);else if(!$)w(M.Errors.CANT_EXTRACT_FILE());else{let ye=d?v.header.fileAttr:void 0;o.writeFileToAsync(H,$,f,ye,function(ce){if(!ce)return w(c("Unable to write file",H));o.fs.utimes(H,v.header.time,v.header.time,function(){w()})})}})}}},I)()},"extractAllToAsync"),writeZip:i(function(u,f){if(arguments.length===1&&typeof u=="function"&&(f=u,u=""),!u&&n.filename&&(u=n.filename),!!u){var d=s.compressToBuffer();if(d){var h=o.writeFileTo(u,d,!0);typeof f=="function"&&f(h?null:new Error("failed"),"")}}},"writeZip"),writeZipPromise:i(function(u,f){let{overwrite:d,perm:h}=Object.assign({overwrite:!0},f);return new Promise((E,c)=>{!u&&n.filename&&(u=n.filename),u||c("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(g=>{let R=i(A=>A?E(A):c("ADM-ZIP: Wasn't able to write zip file"),"ret");o.writeFileToAsync(u,g,d,h,R)},c)})},"writeZipPromise"),toBufferPromise:i(function(){return new Promise((u,f)=>{s.toAsyncBuffer(u,f)})},"toBufferPromise"),toBuffer:i(function(u,f,d,h){return typeof u=="function"?(s.toAsyncBuffer(u,f,d,h),null):s.compressToBuffer()},"toBuffer")}}});var Yt=W((_s,Z)=>{var $e=require("fs"),Se=require("path"),gn=require("os"),mn=require("crypto"),Vt=["\u25C8 encrypted .env [www.dotenvx.com]","\u25C8 secrets for agents [www.dotenvx.com]","\u2301 auth for agents [www.vestauth.com]","\u2318 custom filepath { path: '/custom/path/.env' }","\u2318 enable debugging { debug: true }","\u2318 override existing { override: true }","\u2318 suppress logs { quiet: true }","\u2318 multiple files { path: ['.env.local', '.env'] }"];function hn(){return Vt[Math.floor(Math.random()*Vt.length)]}i(hn,"_getRandomTip");function ne(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}i(ne,"parseBoolean");function yn(){return process.stdout.isTTY}i(yn,"supportsAnsi");function En(e){return yn()?`\x1B[2m${e}\x1B[0m`:e}i(En,"dim");var Tn=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function _n(e){let t={},r=e.toString();r=r.replace(/\r\n?/mg,`
|
|
2
|
+
`);let n;for(;(n=Tn.exec(r))!=null;){let o=n[1],a=n[2]||"";a=a.trim();let s=a[0];a=a.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),s==='"'&&(a=a.replace(/\\n/g,`
|
|
3
|
+
`),a=a.replace(/\\r/g,"\r")),t[o]=a}return t}i(_n,"parse");function In(e){e=e||{};let t=Jt(e);e.path=t;let r=U.configDotenv(e);if(!r.parsed){let s=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw s.code="MISSING_DATA",s}let n=Zt(e).split(","),o=n.length,a;for(let s=0;s<o;s++)try{let l=n[s].trim(),p=Sn(r,l);a=U.decrypt(p.ciphertext,p.key);break}catch(l){if(s+1>=o)throw l}return U.parse(a)}i(In,"_parseVault");function Rn(e){console.error(`\u26A0 ${e}`)}i(Rn,"_warn");function pe(e){console.log(`\u2506 ${e}`)}i(pe,"_debug");function Kt(e){console.log(`\u25C7 ${e}`)}i(Kt,"_log");function Zt(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}i(Zt,"_dotenvKey");function Sn(e,t){let r;try{r=new URL(t)}catch(l){if(l.code==="ERR_INVALID_URL"){let p=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw p.code="INVALID_DOTENV_KEY",p}throw l}let n=r.password;if(!n){let l=new Error("INVALID_DOTENV_KEY: Missing key part");throw l.code="INVALID_DOTENV_KEY",l}let o=r.searchParams.get("environment");if(!o){let l=new Error("INVALID_DOTENV_KEY: Missing environment part");throw l.code="INVALID_DOTENV_KEY",l}let a=`DOTENV_VAULT_${o.toUpperCase()}`,s=e.parsed[a];if(!s){let l=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw l.code="NOT_FOUND_DOTENV_ENVIRONMENT",l}return{ciphertext:s,key:n}}i(Sn,"_instructions");function Jt(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)$e.existsSync(r)&&(t=r.endsWith(".vault")?r:`${r}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=Se.resolve(process.cwd(),".env.vault");return $e.existsSync(t)?t:null}i(Jt,"_vaultPath");function zt(e){return e[0]==="~"?Se.join(gn.homedir(),e.slice(1)):e}i(zt,"_resolveHome");function Cn(e){let t=ne(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),r=ne(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!r)&&Kt("loading env from encrypted .env.vault");let n=U._parseVault(e),o=process.env;return e&&e.processEnv!=null&&(o=e.processEnv),U.populate(o,n,e),{parsed:n}}i(Cn,"_configVault");function An(e){let t=Se.resolve(process.cwd(),".env"),r="utf8",n=process.env;e&&e.processEnv!=null&&(n=e.processEnv);let o=ne(n.DOTENV_CONFIG_DEBUG||e&&e.debug),a=ne(n.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?r=e.encoding:o&&pe("no encoding is specified (UTF-8 is used by default)");let s=[t];if(e&&e.path)if(!Array.isArray(e.path))s=[zt(e.path)];else{s=[];for(let y of e.path)s.push(zt(y))}let l,p={};for(let y of s)try{let T=U.parse($e.readFileSync(y,{encoding:r}));U.populate(p,T,e)}catch(T){o&&pe(`failed to load ${y} ${T.message}`),l=T}let m=U.populate(n,p,e);if(o=ne(n.DOTENV_CONFIG_DEBUG||o),a=ne(n.DOTENV_CONFIG_QUIET||a),o||!a){let y=Object.keys(m).length,T=[];for(let S of s)try{let C=Se.relative(process.cwd(),S);T.push(C)}catch(C){o&&pe(`failed to load ${S} ${C.message}`),l=C}Kt(`injected env (${y}) from ${T.join(",")} ${En(`// tip: ${hn()}`)}`)}return l?{parsed:p,error:l}:{parsed:p}}i(An,"configDotenv");function bn(e){if(Zt(e).length===0)return U.configDotenv(e);let t=Jt(e);return t?U._configVault(e):(Rn(`you set DOTENV_KEY but you are missing a .env.vault file at ${t}`),U.configDotenv(e))}i(bn,"config");function wn(e,t){let r=Buffer.from(t.slice(-64),"hex"),n=Buffer.from(e,"base64"),o=n.subarray(0,12),a=n.subarray(-16);n=n.subarray(12,-16);try{let s=mn.createDecipheriv("aes-256-gcm",r,o);return s.setAuthTag(a),`${s.update(n)}${s.final()}`}catch(s){let l=s instanceof RangeError,p=s.message==="Invalid key length",m=s.message==="Unsupported state or unable to authenticate data";if(l||p){let y=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw y.code="INVALID_DOTENV_KEY",y}else if(m){let y=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw y.code="DECRYPTION_FAILED",y}else throw s}}i(wn,"decrypt");function vn(e,t,r={}){let n=!!(r&&r.debug),o=!!(r&&r.override),a={};if(typeof t!="object"){let s=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw s.code="OBJECT_REQUIRED",s}for(let s of Object.keys(t))Object.prototype.hasOwnProperty.call(e,s)?(o===!0&&(e[s]=t[s],a[s]=t[s]),n&&pe(o===!0?`"${s}" is already defined and WAS overwritten`:`"${s}" is already defined and was NOT overwritten`)):(e[s]=t[s],a[s]=t[s]);return a}i(vn,"populate");var U={configDotenv:An,_configVault:Cn,_parseVault:In,config:bn,decrypt:wn,parse:_n,populate:vn};Z.exports.configDotenv=U.configDotenv;Z.exports._configVault=U._configVault;Z.exports._parseVault=U._parseVault;Z.exports.config=U.config;Z.exports.decrypt=U.decrypt;Z.exports.parse=U.parse;Z.exports.populate=U.populate;Z.exports=U});var Ao={};Gr(Ao,{TestRunMonitor:()=>Me});module.exports=jr(Ao);var ke=i(e=>new Promise(t=>setTimeout(t,e)),"awaitSleep");var Nr=require("child_process"),he=require("crypto"),k=require("fs"),Lr=require("fs/promises"),Or=require("stream/promises"),Mr=require("http"),kr=de(require("net")),Pr=require("os"),V=require("path");function zr(e){if(e)return{...e,...e.tests?{tests:e.tests.map(t=>{let{errorMessage:r,...n}=t;return n})}:{}}}i(zr,"projectReportStatsForTelemetry");function at(e,t,r){e.emit({outcome:t,stats:zr(r)})}i(at,"emitReportProcessingStatsTelemetry");var ct=["script","template"],lt='<script id="playwrightReportBase64" type="application/zip">',dt="</script>";var hr=require("htmlparser2"),yr=de(Gt()),B=require("node:fs"),ee=require("node:path"),Er=require("node:os"),Tr=require("node:crypto");var J=de(require("path")),je=require("fs");var We=require("path"),Re=require("fs");function fn(e,t,r=10){let n=e;for(let o=0;o<r;o++){let a=(0,We.join)(n,"package.json");if((0,Re.existsSync)(a))try{if(JSON.parse((0,Re.readFileSync)(a,"utf8")).name===t)return n}catch{}n=(0,We.join)(n,"..")}}i(fn,"findRepositoryRoot");function jt(e,t=10){return fn(e,"checksum-customer-engineering-workspace",t)}i(jt,"findCustomerEngineeringRoot");var Ve=de(Yt());var j=i((e,t)=>{if(e==null||e==="")return t?.default??!1;let r=e.toLowerCase().trim();return r==="true"?!0:r==="false"?!1:t?.default??!1},"parseBoolean");function qt(e){if(e===void 0||e.trim()==="")return 5e7;let t=Number(e);return!Number.isInteger(t)||t<0?5e7:t}i(qt,"resolveMaxRRwebBytes");var Dn=__dirname,Xt=J.join(__dirname,".."),er=(0,je.existsSync)(Xt)?Xt:Dn;(0,Ve.config)({path:J.resolve(er,".env")});var Qt=j(process.env.CHECKSUM_RUNTIME_DEV_MODE);function xn(){let e=__dirname;for(;!(0,je.existsSync)(J.join(e,"package.json"));)e=J.join(e,"..");return e}i(xn,"findRoot");var fe=xn(),Nn=jt(fe,10);(0,Ve.config)({path:[er,Nn].filter(e=>!!e).map(e=>J.resolve(e,".env")),override:!1});var Ge=j(process.env.CHECKSUM_RUNTIME_REPO_MODE),Ln=Ge?J.join(fe,"package","pw-report-template.html"):J.join(fe,"pw-report-template.html"),On=j(process.env.CHECKSUM_DEBUG_ANALYTICS),Mn=j(process.env.CHECKSUM_LOG_ANALYTICS_TO_CONSOLE),kn=qt(process.env.CHECKSUM_RUNTIME_RRWEB_MAX_BYTES),Ce={isDevMode:Qt,isRepoMode:Ge,CI:!!process.env.CI,checksumRootFolderBypass:Ge&&process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS_FOR_REPO_MODE?process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS_FOR_REPO_MODE:process.env.CHECKSUM_RUNTIME_ROOT_FOLDER_BYPASS,logLevel:process.env.CHECKSUM_RUNTIME_LOG_LEVEL??"warnings",checksumScript:{source:process.env.CHECKSUM_RUNTIME_SCRIPT_SOURCE??(Qt?"url":"file"),url:process.env.CHECKSUM_RUNTIME_SCRIPT_URL,path:fe+"/checksumlib.js"},runtimeRoot:fe,playwrightReporter:{htmlReportTemplatePath:Ln},bypassProxyForLocalhost:j(process.env.CHECKSUM_RUNTIME_BYPASS_PROXY_FOR_LOCALHOST),useCLIDebug:j(process.env.CHECKSUM_RUNTIME_USE_CLI_DEBUG),useRemoteDebugging:{enabled:j(process.env.CHECKSUM_RUNTIME_USE_REMOTE_DEBUGGING),port:parseInt(process.env.CHECKSUM_AGENT_RUNTIME_REMOTE_DEBUGGING_PORT??"9500")},testRun:{timeMachine:{active:!0,headless:!j(process.env.CHECKSUM_RUNTIME_SHOW_RUNTIME_TIME_MACHINE),recordRRwebEventsToFile:j(process.env.CHECKSUM_RUNTIME_RECORD_RRWEB_EVENTS_TO_FILE,{default:!0}),maxRRwebBytes:kn},monitoring:{debugAnalytics:On,logToConsole:Mn,segment:{writeKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_WRITE_KEY??"TMuP8uorDj4QzJfNs0gEHDO7kHozVBOo",devWriteKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_DEV_WRITE_KEY??"gofHHwvdNHJNmb7KqACUmypZclVHEQ2l"}},autoRecovery:{verboseConsoleLog:j(process.env.CHECKSUM_RUNTIME_AUTO_RECOVERY_CONSOLE_LOG,{default:!1}),sessionTimeout:18e4},disableAutoRecovery:j(process.env.CHECKSUM_RUNTIME_DISABLE_AUTO_RECOVERY),disableHostReports:j(process.env.CHECKSUM_RUNTIME_DISABLE_HOST_REPORTS),disableTimeMachine:j(process.env.CHECKSUM_RUNTIME_DISABLE_TIME_MACHINE),disableRrwebRecording:j(process.env.CHECKSUM_RUNTIME_DISABLE_RRWEB_RECORDING),request:{userEmail:process.env.CHECKSUM_RUNTIME_REQUEST_USER_EMAIL,reason:process.env.CHECKSUM_RUNTIME_REQUEST_REASON},platform:{name:process.env.CHECKSUM_RUNTIME_PLATFORM_NAME,jobURL:process.env.CHECKSUM_RUNTIME_PLATFORM_JOB_URL,jobName:process.env.CHECKSUM_RUNTIME_PLATFORM_JOB_NAME},runType:process.env.CHECKSUM_RUNTIME_RUN_TYPE},buildTime:process.env.CHECKSUM_RUNTIME_BUILD_TIME??"unknown"};var Js=require("@playwright/test/reporter");var oe=require("path");var ze=i((e,t,r)=>`v2:${Pn(e)}::${JSON.stringify([...t,r])}`,"computeVariantKey"),Pn=i(e=>(e??"").replace(/\\/g,"/"),"normalizeFilePath");var Ae=require("fs"),F=de(require("typescript"));var Un=/^[0-9a-zA-Z]+$/,Fn=5;function tr(e){return e?e.length===Fn&&Un.test(e):!1}i(tr,"isValidChecksumTestId");var Ke=class{static{i(this,"FileNameExtractionStrategy")}extract(t,r){if(!t)return;let n=t.split("/"),o=n[n.length-1];if(!o||!o.endsWith(".checksum.spec.ts"))return;let s=o.replace(".checksum.spec.ts","").split(" - ").pop();return tr(s)?s:void 0}},Ze=class{static{i(this,"FileContentExtractionStrategy")}extract(t,r){if(!(!t||!(0,Ae.existsSync)(t)))try{let n=(0,Ae.readFileSync)(t,"utf-8"),o=F.createSourceFile(t,n,F.ScriptTarget.Latest,!0),a=new Map,s=i(l=>{if(F.isCallExpression(l)){let p=l;if(this.isTestCall(p.expression)){let m=p.arguments[0];if(m&&F.isCallExpression(m)&&F.isIdentifier(m.expression)&&m.expression.text==="defineChecksumTest"){let y=this.extractDefineChecksumTestArgs(m);y&&tr(y.checksumTestId)&&a.set(y.testTitle,y.checksumTestId)}}}F.forEachChild(l,s)},"visit");return s(o),r&&a.has(r)?a.get(r):a.size>0?Array.from(a.values())[0]:void 0}catch{return}}isTestCall(t){return F.isIdentifier(t)&&t.text==="test"?!0:F.isPropertyAccessExpression(t)?F.isIdentifier(t.expression)&&t.expression.text==="test":!1}extractDefineChecksumTestArgs(t){let r=t.arguments;if(r.length<2)return;let n=r[0],o=r[1];if(!n||!o)return;let a=this.extractStringLiteral(n),s=this.extractStringLiteral(o);if(a&&s)return{testTitle:a,checksumTestId:s}}extractStringLiteral(t){if(F.isStringLiteral(t)||F.isNoSubstitutionTemplateLiteral(t))return t.text}},Je=class{static{i(this,"ChecksumTestIdExtractor")}constructor(t){this.strategies=t??[new Ze,new Ke]}extract(t,r){for(let n of this.strategies){let o=n.extract(t,r);if(o)return o}}};var rr=new Je;function be(e,t){return t.pwTestIdToChecksumTestId[e.playwrightTestId]||(e.filePath!==void 0?rr.extract(e.filePath,e.title):void 0)}i(be,"resolveChecksumTestId");var qe=i((e,t)=>Object.values(t[e]??{}).some(r=>r.autoRecoveryMetadata?.data?.autoRecovered),"isAutoRecovered"),Ye=i(e=>typeof e=="number"&&!isNaN(e)?e:0,"getStat");function Xe(e,t,r){let n=[],o=0,a=0,s=Ye(t.expected)+Ye(t.flaky),l=Ye(t.unexpected);for(let p of e){let m=Bn(p,r);n.push(m),m.recovered&&a++,m.bug&&(o++,m.outcome==="expected"||m.outcome==="flaky"?s--:m.outcome==="unexpected"&&l--)}return{passed:s,failed:l,bug:o,recovered:a,tests:n}}i(Xe,"computeReportStats");function Bn(e,t){let r=be({playwrightTestId:e.playwrightTestId,filePath:e.filePath,title:e.title},t),n=Hn(e),o=Wn(e.annotations),a=qe(e.playwrightTestId,t.playwrightIdToMetadata),s=$n(r,e,t),l=t.toRelativeFilePath(e.filePath);return{checksumTestId:r,playwrightTestId:e.playwrightTestId,success:e.ok,recovered:a,bug:n,annotations:o,tags:e.tags,outcome:e.outcome,variantKey:ze(e.filePath,e.titlePath,e.title),...e.filePath!==void 0?{filePath:e.filePath}:{},...l!==void 0?{relativeFilePath:l}:{},...e.projectName?{project:e.projectName}:{},...e.errorMessage?{errorMessage:e.errorMessage}:{},...s!==void 0?{usingChecksumTestIdPlaceholder:s}:{}}}i(Bn,"rowToTestWithMetadata");function nr(e,t){let r=e.files,n=i(l=>{let m=be({playwrightTestId:l.testId,filePath:l.location.file,title:l.title},t)??`${l.location.file}::${l.title}`,y=ze(l.location.file,l.path??[],l.title);return`${m}::${l.projectName}::${y}`},"keyFor"),o=new Map;for(let l of r)for(let p of l.tests)o.set(n(p),p);let a=new Set(o.values()),s={total:0,expected:0,unexpected:0,flaky:0,skipped:0};for(let l of r){l.tests=l.tests.filter(p=>a.has(p));for(let p of l.tests)s.total++,p.outcome==="expected"?s.expected++:p.outcome==="unexpected"?s.unexpected++:p.outcome==="flaky"?s.flaky++:s.skipped++}e.files=r.filter(l=>l.tests.length>0),e.stats={...e.stats,...s}}i(nr,"dedupeReportByChecksumTestId");var Hn=i(e=>e.tags.includes("bug")||e.annotations.some(t=>t.type==="bug")||e.title.includes("@bug"),"detectBug"),Wn=i(e=>e.filter(t=>!!t?.type).map(t=>({type:t.type,description:t.description||""})),"normalizeAnnotations"),$n=i((e,t,r)=>{if(r.checksumTestIdToUsingPlaceholder)return r.pwTestIdToChecksumTestId[t.playwrightTestId]&&r.checksumTestIdToUsingPlaceholder[e]||!1},"computeUsingPlaceholder");var or=i((e,t,r)=>{if(!e)return;let n=r||t,o;if((0,oe.isAbsolute)(e))o=e;else{let a=(0,oe.dirname)(t);o=(0,oe.resolve)(a,e)}return o.replace(n+"/","")},"toRelativeFilePath");var sr=require("node:util");var se=8*1024,ge=`
|
|
4
|
+
\u2026 [truncated]`,Gn=/[\u001b\u0080-\u009f]/g;function Qe(e){let t=e.replaceAll("\0","");return jn((0,sr.stripVTControlCharacters)(t))}i(Qe,"sanitizeTestErrorMessage");function jn(e){return e.replace(Gn,"")}i(jn,"removeResidualVTControls");function we(e){let t=Qe(e);if(Buffer.byteLength(t,"utf8")<=se)return{value:t,truncated:!1};let r=se-Buffer.byteLength(ge,"utf8"),n="",o=0;for(let a of t){let s=Buffer.byteLength(a,"utf8");if(o+s>r)break;n+=a,o+=s}return{value:n+ge,truncated:!0}}i(we,"boundTestErrorMessage");var ar=require("node:crypto");var Vn=new Set(["failed","timedOut","interrupted"]),et=new WeakMap;function cr(){let e={messages:new Map,ambiguousKeys:new Set,truncatedCount:0,identityConflictCount:0};return et.set(e,new Map),e}i(cr,"createErrorDetailIndex");function lr(e,t){try{let r=zn(e);if(!r||Kn(r.tests))return!1;for(let n of r.tests){if(!ie(n))continue;let o=gr(n.projectName),a=n.testId;if(o===void 0||!ve(a))continue;let s=Zn(n);if(!s)continue;let l=Yn(s);l.truncated&&(t.truncatedCount+=1),Qn(t,fr(r.fileId,o,a),l.value,Xn(s))}return!0}catch{return!1}}i(lr,"addTestFileErrorDetails");function dr(e){return ie(e)&&Object.prototype.hasOwnProperty.call(e,"fileId")&&Object.prototype.hasOwnProperty.call(e,"tests")}i(dr,"isTestFileErrorDetailCandidate");function ur(e,t,r,n){let o=gr(r);if(!ve(t)||o===void 0||!ve(n))return;let a=fr(t,o,n);if(!e.ambiguousKeys.has(a))return e.messages.get(a)}i(ur,"getTestErrorMessage");function zn(e){if(!ie(e))return;let t=e.fileId,r=e.tests;if(!(!ve(t)||!Array.isArray(r)))return{fileId:t,tests:r}}i(zn,"parseTestFile");function Kn(e){return e.length>0&&!e.some(ie)}i(Kn,"hasOnlyMalformedTests");function Zn(e){let t=e.results;if(!Array.isArray(t))return;let r=t.at(-1);if(!ie(r))return;let n=r.status;if(typeof n!="string"||!Vn.has(n))return;let o=r.errors;if(Array.isArray(o))for(let a of o){let s=Jn(a);if(s)return s}}i(Zn,"extractFinalErrorDetail");function Jn(e){if(typeof e=="string"){let n=pr(e);return n?{message:n}:void 0}if(!ie(e))return;let t=ir(e.message,e.value),r=ir(e.codeframe,e.snippet);return t?!r||t.includes(r)?{message:t}:{message:t,frame:r}:r?{frame:r}:void 0}i(Jn,"normalizeError");function Yn(e){let{message:t,frame:r}=e;if(!t)return we(r??"");if(!r)return we(t);let n=Buffer.byteLength(t,"utf8");if(n>se)return we(t);let o=`
|
|
5
|
+
|
|
6
|
+
`,a=Buffer.byteLength(o,"utf8"),s=Buffer.byteLength(r,"utf8");if(n+a+s<=se)return{value:`${t}${o}${r}`,truncated:!1};let l=a+Buffer.byteLength(ge,"utf8"),p=se-n;if(p<l)return{value:t,truncated:!0};let m=qn(r,p-l);return{value:`${t}${o}${m}${ge}`,truncated:!0}}i(Yn,"boundNormalizedErrorDetail");function qn(e,t){let r="",n=0;for(let o of e){let a=Buffer.byteLength(o,"utf8");if(n+a>t)break;r+=o,n+=a}return r}i(qn,"utf8Prefix");function Xn(e){let t=(0,ar.createHash)("sha256");return e.message&&t.update(e.message,"utf8"),e.message&&e.frame&&t.update(`
|
|
7
|
+
|
|
8
|
+
`,"utf8"),e.frame&&t.update(e.frame,"utf8"),t.digest("hex")}i(Xn,"digestNormalizedErrorDetail");function pr(e){let t=Qe(e);return t.trim().length===0?"":t.replace(/^(?:[^\S\r\n]*(?:\r\n|\r|\n))+/u,"").replace(/(?:(?:\r\n|\r|\n)[^\S\r\n]*)+$/u,"")}i(pr,"normalizeErrorText");function Qn(e,t,r,n){if(e.ambiguousKeys.has(t))return;let o=et.get(e);if(o||(o=new Map,et.set(e,o)),e.messages.get(t)===void 0){e.messages.set(t,r),o.set(t,n);return}o.get(t)!==n&&(e.messages.delete(t),o.delete(t),e.ambiguousKeys.add(t),e.identityConflictCount+=1)}i(Qn,"addErrorDetail");function fr(e,t,r){return JSON.stringify([e,t,r])}i(fr,"createIdentityKey");function ir(...e){for(let t of e){if(typeof t!="string")continue;let r=pr(t);if(r)return r}}i(ir,"firstMeaningfulString");function ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(ie,"isRecord");function gr(e){return e==null||e===""?"":typeof e=="string"?e:void 0}i(gr,"normalizeProjectName");function ve(e){return typeof e=="string"&&e.length>0}i(ve,"isNonEmptyString");var eo=i(e=>Number.isSafeInteger(e)&&e>=0?Math.min(e,8388608):0,"effectiveErrorDetailsPayloadBudgetBytes"),to=i(e=>Buffer.byteLength(`,"errorMessage":${JSON.stringify(e)}`,"utf8"),"serializedErrorMessagePropertyBytes");function mr(e,t=8388608){let r=eo(t),n=0,o=e.tests?.map(a=>{if(a.errorMessage===void 0)return a;let s=to(a.errorMessage);if(s<=r)return r-=s,a;n+=1;let l={...a};return delete l.errorMessage,l});return{stats:{...e,...o!==void 0?{tests:o}:{}},omittedCount:n}}i(mr,"applyErrorDetailsPayloadBudget");var no=i((e,t)=>e.files.flatMap(r=>r.tests.map(n=>{let o=t?ur(t,r.fileId,n.projectName,n.testId):void 0;return{playwrightTestId:n.testId,ok:!!n.ok,outcome:n.outcome,title:n.title,titlePath:n.path??[],filePath:n.location?.file,...n.projectName?{projectName:n.projectName}:{},tags:n.tags??[],annotations:n.annotations??[],...o?{errorMessage:o}:{}}})),"htmlReportToRows"),De=class e{constructor(t,r,n,o={},a={},s,l,p,m={}){this.reportHTMLFilePath=t;this.testRunUUID=r;this.pwTestIdToChecksumTestId=n;this.playwrightIdToMetadata=o;this.channel=s;this.checksumTestIdToUsingPlaceholder=m;this.supportVideo=!1;this.config={hosted:!0,assetsBaseURL:"https://api.checksum.ai/api/test-runs"};this.config={...this.config,...a},this.checksumRoot=l||(0,ee.dirname)((0,ee.dirname)(t)),this.projectRoot=p||this.checksumRoot}static{i(this,"PlaywrightReportProcessor")}static{this.templateCache=null}async process(){let t=0;try{t=(0,B.statSync)(this.reportHTMLFilePath)?.size||0,this.channel.debug(`Report HTML file size approximately ${t} bytes`)}catch(a){this.channel.debug(`Failed to retrieve file size for ${this.reportHTMLFilePath}`,a)}let r=(0,ee.join)((0,Er.tmpdir)(),`pw-report-${(0,Tr.randomUUID)()}.zip`),n=i(()=>{try{(0,B.existsSync)(r)&&(0,B.unlinkSync)(r)}catch{}},"cleanupFile"),o={sigterm:i(()=>{n(),process.exit(143)},"sigterm"),sigint:i(()=>{n(),process.exit(130)},"sigint"),exit:n};process.once("SIGTERM",o.sigterm),process.once("SIGINT",o.sigint),process.once("exit",o.exit);try{this.channel.debug("Extracting base64 to temp ZIP file...");let a=Date.now();await this.extractBase64ToFile(r);let s=Date.now()-a;this.channel.debug("Modifying ZIP file...");let l=Date.now(),p=this.modifyZipFile(r),m=Date.now()-l;this.channel.debug("Writing output HTML...");let y=Date.now();await this.writeOutputWithStreamedZip(r);let T=Date.now()-y;return{report_html_bytes:t,extract_ms:s,modify_ms:m,write_ms:T,entry_count:p.entryCount,json_entry_count:p.jsonEntryCount,largest_entry_bytes:p.largestEntryBytes,largest_entry_name:p.largestEntryName,error_details_extracted:p.errorDetailsExtracted,error_details_truncated:p.errorDetailsTruncated,error_detail_parse_failures:p.errorDetailParseFailures,error_detail_identity_conflicts:p.errorDetailIdentityConflicts,error_details_payload_budget_omitted:p.errorDetailsPayloadBudgetOmitted}}finally{process.removeListener("SIGTERM",o.sigterm),process.removeListener("SIGINT",o.sigint),process.removeListener("exit",o.exit);try{(0,B.existsSync)(r)&&(0,B.unlinkSync)(r)}catch{this.channel.debug(`Failed to cleanup temp file: ${r}`)}}}async extractBase64ToFile(t){return new Promise((r,n)=>{let o=!1,a=!1,s=!1,l=[],p=0,m=(0,B.createWriteStream)(t);m.on("error",u=>{if(!a){a=!0;try{C.destroyed||C.destroy(),S.end()}catch{}n(u)}});let y=i(()=>{if(p<4)return;let u=l.join("");l.length=0,s||(u=u.replace("data:application/zip;base64,",""),s=!0);let f=Math.floor(u.length/4)*4,d=u.slice(0,f),h=u.slice(f);if(h.length>0?(l.push(h),p=h.length):p=0,d.length>0){let E=Buffer.from(d,"base64");m.write(E)}},"flushBuffer"),T=i(u=>ct.includes(u),"isPayloadTag"),S=new hr.Parser({onopentag:i((u,f)=>{T(u)&&f.id==="playwrightReportBase64"&&(o=!0)},"onopentag"),ontext:i(u=>{o&&(l.push(u),p+=u.length,p>1024*1024&&y())},"ontext"),onclosetag:i(u=>{if(T(u)&&o&&!a){if(a=!0,p>0){let f=l.join("");if(s||(f=f.replace("data:application/zip;base64,","")),f.length>0){let d=Buffer.from(f,"base64");m.write(d)}}try{C.destroyed||C.destroy()}catch{}m.end(()=>r())}},"onclosetag"),onerror:i(u=>{if(!a){a=!0;try{S.end(),C.destroyed||C.destroy(),m.destroyed||m.destroy()}catch{}n(u)}},"onerror")}),C=(0,B.createReadStream)(this.reportHTMLFilePath,{encoding:"utf8"});C.on("data",u=>S.write(u.toString())),C.on("end",()=>{if(S.end(),!a){a=!0;try{m.destroyed||m.destroy()}catch{}n(new Error("Could not find playwrightReportBase64 in HTML"))}}),C.on("error",u=>{if(!a){a=!0;try{S.end(),m.destroyed||m.destroy()}catch{}n(u)}})})}modifyZipFile(t){let r=new yr.default(t),n=r.getEntries(),o=cr(),a,s,l=0,p=0,m=0,y="";for(let S of n){if(S.isDirectory||!S.entryName.endsWith(".json"))continue;let C=S.getData().toString("utf8");if(p+=1,C.length>m&&(m=C.length,y=S.entryName),S.entryName==="report.json")a=JSON.parse(C),s=S;else{let u=this.replaceAttachmentPaths(C);S.setData(Buffer.from(u,"utf8"));try{let f=JSON.parse(u);dr(f)&&!lr(f,o)&&(l+=1)}catch{l+=1}}}if(!a||!s)throw new Error("report.json not found in ZIP file");this.config.dedupeByChecksumTestId&&nr(a,{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId}),this.handleReportJSON(a),this.report=a;let T=this.extractStats(a,o);return s.setData(Buffer.from(JSON.stringify(a),"utf8")),r.writeZip(t),{entryCount:n.length,jsonEntryCount:p,largestEntryBytes:m,largestEntryName:y,errorDetailsExtracted:o.messages.size,errorDetailsTruncated:o.truncatedCount,errorDetailParseFailures:l,errorDetailIdentityConflicts:o.identityConflictCount,errorDetailsPayloadBudgetOmitted:T}}replaceAttachmentPaths(t){return t.replace(/"path"\s*:\s*"([^"]+)"/g,(r,n)=>n.startsWith("http://")||n.startsWith("https://")?r:`"path":"${this.makeAttachmentPath(n)}"`)}async writeOutputWithStreamedZip(t){let r=this.getTemplate(),n=this.getProcessedFilePath(),o=n.replace(".html",".backup.html");(0,B.copyFileSync)(n,o);let a=(0,B.createWriteStream)(n);await new Promise((s,l)=>{a.on("error",l),a.write(r),a.write(lt+"data:application/zip;base64,");let p=(0,B.createReadStream)(t,{highWaterMark:3*1024*1024});p.on("data",m=>{let T=(typeof m=="string"?Buffer.from(m):m).toString("base64");a.write(T)||p.pause()}),a.on("drain",()=>{p.resume()}),p.on("end",()=>{a.write(dt),a.end(()=>s())}),p.on("error",m=>{try{a.destroyed||a.destroy()}catch{}l(m)}),a.on("error",m=>{try{p.destroyed||p.destroy()}catch{}l(m)})})}testHasTrace(t,r){try{if(!this.report)return!0;let n=Object.keys(this.pwTestIdToChecksumTestId??{}).find(a=>this.pwTestIdToChecksumTestId[a]===t);if(!n)return!0;let o=i(a=>a.some(s=>s.attachments?.some(l=>l.name==="trace")),"hasTrace");for(let a of this.report.files)for(let s of a.tests)if(s.testId===n&&s.projectName===r&&o(s.results))return!0;return!1}catch(n){return this.channel.debug("Failed to check if test has trace, assuming trace exists",n),!0}}getProcessedFilePath(){return this.reportHTMLFilePath}getTemplate(){return e.templateCache||(e.templateCache=(0,B.readFileSync)(Ce.playwrightReporter.htmlReportTemplatePath,"utf-8")),e.templateCache}getReportsStats(){return this.stats}extractStats(t,r){if(!t.stats)return 0;let n=Xe(no(t,r),t.stats,{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId,playwrightIdToMetadata:this.playwrightIdToMetadata,checksumTestIdToUsingPlaceholder:this.checksumTestIdToUsingPlaceholder,toRelativeFilePath:i(a=>or(a,this.checksumRoot,this.projectRoot),"toRelativeFilePath")}),o=mr(n,this.config.errorDetailsPayloadBudgetBytes??8388608);return this.stats=o.stats,o.omittedCount}makeAttachmentPath(t){return this.config.hosted?`${this.config.assetsBaseURL}/${this.testRunUUID}/report-data-file-url?fileName=${(0,ee.basename)(t)}`:t}handleReportJSON(t){let r={},n=i(o=>{let a=o.testId,s=this.playwrightIdToMetadata[a];s&&(r[a]=s);let l=be({playwrightTestId:o.testId,filePath:o.location?.file,title:o.title},{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId});l!==void 0&&(o.checksumTestId=l),o.results.forEach(p=>{this.processAttachments(p.attachments)})},"getChecksumMetadataForPWTestId");t.files.forEach(o=>{o.tests.forEach(n)}),t.checksumMetadata=r}processAttachments(t){if(t.forEach(r=>this.updateAttachment(r)),!this.supportVideo){let r=t.findIndex(n=>n.name==="video");r!==-1&&t.splice(r,1)}}updateAttachment(t){t.path&&(t.path=this.makeAttachmentPath(t.path))}};var _r={trace:"application/zip","trace-backup-file":"application/zip",har:"application/zip",report:"text/html","rrweb-recording":"application/json"},oo={click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",upload_files:"upload_files",wait:"wait",get_more_items:"get_more_items",reset:void 0,save:void 0,fail:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0,logout_and_login:"logout_and_login",canvas_click:"canvas_click",native_accept:"native_accept",native_dismiss:"native_dismiss",hard_assertion:void 0,soft_assertion:void 0,recovery:void 0,scroll:void 0},Ti=Object.fromEntries(Object.entries(oo).map(e=>e.reverse())),so={goto:"navigation",click:"click",dblclick:"double_click",dragTo:"drag_and_drop",check:"check",uncheck:"uncheck",fill:"input",hover:"hover",selectOption:"selectoption",waitForTimeout:"wait","keyboard.press":"keystroke",setInputFiles:"upload_files",getPage:"switch_tab",reauthenticate:"logout_and_login",canvasClick:"canvas_click"},_i=Object.fromEntries(Object.entries(so).map(e=>e.reverse()));var Ii={input:[1,2],selectoption:[1,2],keystroke:[1,2],wait:[1,2],navigation:[1,2],click:[0,1],double_click:[0,1],drag_and_drop:[1,2],upload_files:[1,2],canvas_click:[1,2],logout_and_login:[1],login:[1,2],click_and_type:[1,2],clear_and_type:[1,2],check:[0,1],uncheck:[0,1],hover:[0,1]},Ri={input:1,selectoption:1,keystroke:1,wait:-1,navigation:1,click:0,double_click:0,drag_and_drop:1,upload_files:1,canvas_click:-1,logout_and_login:-1,login:1,click_and_type:0,clear_and_type:0,check:0,uncheck:0,hover:0,native_accept:-1,native_dismiss:-1};var Oe=require("fs"),vr=require("path"),Dr=require("stream");var Ir=i(e=>{if(e.error!=null)return"ERROR";let t=e.status_code;if(typeof t=="number"&&t>=500)return"ERROR";let r=e.exit_code;return typeof r=="number"&&r!==0?"ERROR":"INFO"},"severityFor");var tt=require("fs");var Rr="\x1B[31m",io="\x1B[33m",ao="\x1B[32m",co="\x1B[36m",lo="\x1B[2m",uo="\x1B[1m",me="\x1B[0m",po=i(()=>{let e=process.env.WIDE_EVENT_PRETTY;return e==="true"||e==="1"?!0:e==="false"||e==="0"?!1:process.stdout.isTTY?!0:process.env.APP_ENV==="local"},"shouldPretty"),fo=new Set(["severity","message","kind","timestamp","_startedAtMs"]),go=i(e=>{let t=new WeakSet;return JSON.stringify(e,(r,n)=>{if(typeof n=="bigint")return n.toString();if(typeof n=="object"&&n!==null){if(t.has(n))return"[Circular]";t.add(n)}return n})},"safeStringify"),mo=i(e=>e==="ERROR"||e==="CRITICAL"?Rr:e==="WARNING"?io:ao,"colorForSeverity"),ho=i(e=>{let t=String(e.severity??"INFO"),r=`${mo(t)}${t.padEnd(5)}${me}`,n=e.kind?`${co}${e.kind}${me}`:"",o=String(e.message??""),a=e.error&&typeof e.error=="object"?(()=>{let y=e.error;return` ${Rr}${y.type??"Error"}: ${y.message??""}${me}`})():"",s=["outcome","test_suite_run_id","status"],l=Object.entries(e).filter(([y,T])=>!fo.has(y)&&T!=null&&y!=="error"&&typeof T!="object"),p=i(y=>{let T=s.indexOf(y);return T===-1?s.length:T},"rank"),m=l.sort(([y],[T])=>p(y)-p(T)).slice(0,8).map(([y,T])=>`${lo}${y}=${me}${T}`).join(" ");return[r,uo+n+me,o,m,a].filter(y=>y&&y.trim()!=="").join(" ")},"formatPretty"),yo=i(e=>{let t=e.trace_id;if(typeof t!="string"||t==="")return e;let r=process.env.GCP_PROJECT_ID||process.env.GOOGLE_CLOUD_PROJECT;return r?{...e,"logging.googleapis.com/trace":`projects/${r}/traces/${t}`}:e},"withGcpTraceField"),Sr=i(e=>{let t=po()?ho(e):go(yo(e));(0,tt.writeSync)(1,t+`
|
|
9
|
+
`)},"emitEvent");var Cr=i(e=>{(0,tt.writeSync)(2,e.endsWith(`
|
|
10
|
+
`)?e:`${e}
|
|
11
|
+
`)},"writeStderrLine");var Eo=i(e=>{let t=e.kind??"event",r=e.outcome?` ${e.outcome}`:"",n=typeof e.duration_ms=="number"?` ${e.duration_ms}ms`:"";return`${t}${r}${n}`.trim()},"defaultMessage"),To=i((e,t,r)=>{let n=Date.now(),o={timestamp:new Date().toISOString(),kind:e,...t},a=!1,s={set(l){return Object.assign(o,l),s},emit(l){a||(a=!0,l&&Object.assign(o,l),o.duration_ms===void 0&&(o.duration_ms=Date.now()-n),r(o))}};return s},"startHandle"),_o=i((e={})=>{let t=e.decide??(()=>!0),r=e.deriveMessage??Eo,n=e.label??"[wide-event]",o=e.sink??(l=>Sr(l)),a=i(l=>{if(!t(l))return;let p={severity:Ir(l),message:l.message??r(l),...l};try{o(p)}catch(m){try{Cr(`${n} emit failed: ${String(m)}`)}catch{}}},"emit");return{emit:a,emitWideEvent:i((l,p={})=>{a({timestamp:new Date().toISOString(),kind:l,...p})},"emitWideEvent"),wideEvent:i((l,p={})=>To(l,p,a),"wideEvent"),configureSink:i(l=>{o=l},"configureSink")}},"createWideEvents"),Ar=i(e=>e==="true"||e==="1","truthy"),br=i(()=>Ar(process.env.CHECKSUM_WIDE_EVENTS)||Ar(process.env.WIDE_EVENT_PRETTY),"wideEventsEnabled"),rt=_o({decide:i(()=>br(),"decide")}),nt=rt.configureSink,ae=i((e,t={})=>rt.wideEvent(e,t),"wideEvent"),xe=i((e,t={})=>{rt.emitWideEvent(e,t)},"emitWideEvent"),Y=i(e=>e instanceof Error?{type:e.name,message:e.message}:{type:"UnknownError",message:String(e)},"toErrorField");async function Ne(e,t){let r;try{r=await e.json()}catch{r=void 0}return Io({ok:e.ok,status:e.status,body:r},t)}i(Ne,"assertOkJson");function Io(e,t){let r=e.body&&typeof e.body=="object"?e.body:void 0;if(!e.ok){let o=Ro(r?.message);throw So(new Error(`${t.resource} failed (HTTP ${e.status})`+(o?`: ${o}`:".")),e.status)}if(!r)throw new Error(`${t.resource} (HTTP ${e.status}) returned a non-object body; expected JSON.`);let n=(t.requiredFields??[]).filter(o=>!r[o]);if(n.length>0)throw new Error(`${t.resource} (HTTP ${e.status}) response is missing required field${n.length>1?"s":""}: ${n.join(", ")}.`);return r}i(Io,"assertJsonBody");function Ro(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>typeof t=="string").join("; "):""}i(Ro,"extractMessage");function So(e,t){return Object.assign(e,{status:t})}i(So,"withStatus");var wr=i(e=>typeof e=="number"&&e>=400&&e<500&&e!==408&&e!==429,"isNonRetryableStatus");var Co=i(e=>{let t=e;if(t?.name==="TimeoutError")return"timeout";if(t?.name==="AbortError")return"no_progress_abort";let r=t?.cause?.code;if(r==="UND_ERR_CONNECT_TIMEOUT"||r==="UND_ERR_HEADERS_TIMEOUT"||r==="UND_ERR_BODY_TIMEOUT")return"timeout";if(typeof r=="string"&&r.length>0)return`network_error:${r}`;let n=typeof t?.message=="string"?t.message:"";return n.startsWith("Upload failed with status")?"http_error":n.startsWith("get-upload-url")?"signed_url_error":n.includes("No upload URL")?"signed_url_missing":"network_error"},"classifyUploadError"),Le=class{constructor(t,r,n,o,a=!1,s={start:i(p=>{},"start"),complete:i(p=>{},"complete"),error:i((p,m)=>{},"error")},l){this.apiBaseURL=t;this.apiKey=r;this.uploadTimeout=n;this.makeGetUploadUrlAPIPath=o;this.isolationMode=a;this.reporter=s;this.sessionId=l;this.SIGNED_URL_TIMEOUT_MS=3e4;this.MAX_ATTEMPTS=6;this.BACKOFF_BASE_MS=1e3;this.BACKOFF_CAP_MS=16e3;this.PUT_NO_PROGRESS_ABORT_MS=6e4;this.ASSET_DEADLINE_MS=20*6e4}static{i(this,"TestAssetUploader")}async uploadAsset(t){if(t.uploadStarted=!0,this.isolationMode){t.lastProgress=Date.now(),t.loadedBytes=0,t.sizeBytes=100,t.response=new Promise(s=>{setTimeout(()=>{t.complete=!0,t.lastProgress=Date.now(),t.loadedBytes=100,s({statusCode:200,ok:!0,body:"OK"})},10)});return}let{path:r}=t.info,n=Date.now()+this.ASSET_DEADLINE_MS,o=ae("asset_upload",{test_suite_run_id:this.sessionId,asset_type:t.info.type,file_name:t.info.fileName??(0,vr.basename)(r),test_id:t.info.testId,project:t.info.project}),a=[];try{let l=(0,Oe.statSync)(r).size;t.sizeBytes=l,t.loadedBytes=0,t.lastProgress=Date.now(),o.set({size_bytes:l}),this.reporter.start(r);let p;for(let m=1;m<=this.MAX_ATTEMPTS&&!(Date.now()>=n);m++){let y={attempt:m};try{let T=Date.now();if(await this.getSignedURLForUpload(t),y.signed_url_ms=Date.now()-T,!t.uploadURL)throw new Error("No upload URL returned");let S=Date.now();await this.putWithWatchdog(t,r,l),y.put_ms=Date.now()-S,y.loaded_bytes=t.loadedBytes,a.push(y),this.reporter.complete(r),t.complete=!0,o.emit({outcome:"success",attempt_count:a.length,attempts:a,loaded_bytes:t.loadedBytes});return}catch(T){p=T,y.loaded_bytes=t.loadedBytes,y.failure_reason=Co(T),y.error=Y(T);let S=wr(T?.status);if(y.non_retryable=S,a.push(y),delete t.uploadURL,S||m>=this.MAX_ATTEMPTS||Date.now()>=n)break;await this.backoff(m,n)}}this.reporter.error(r,p),t.error=!0,o.emit({outcome:"error",attempt_count:a.length,attempts:a,loaded_bytes:t.loadedBytes,size_bytes:t.sizeBytes,deadline_exceeded:Date.now()>=n,error:Y(p)})}catch(s){this.reporter.error(r,s),t.error=!0,o.emit({outcome:"error",failure_reason:"pre_upload",attempt_count:a.length,attempts:a,error:Y(s)})}}async putWithWatchdog(t,r,n){let o=t.uploadURL;if(!o)throw new Error("No upload URL returned");let a=new AbortController,s=this.uploadTimeout??void 0;t.loadedBytes=0,t.lastProgress=Date.now();let l=0,p=Date.now(),m=setInterval(()=>{let d=t.loadedBytes??0;d>l?(l=d,p=Date.now()):Date.now()-p>this.PUT_NO_PROGRESS_ABORT_MS&&a.abort()},1e4),y=s!==void 0?setTimeout(()=>a.abort(new DOMException("upload attempt timeout","TimeoutError")),s):void 0,T=(0,Oe.createReadStream)(r),S=0,C=new TransformStream({transform(d,h){S+=d.byteLength,S>(t.loadedBytes??0)&&(t.lastProgress=Date.now()),t.loadedBytes=S,t.sizeBytes=n,h.enqueue(d)}}),u=Dr.Readable.toWeb(T).pipeThrough(C),f={method:"PUT",headers:{"Content-Type":_r[t.info.type]??""},body:u,duplex:"half",signal:a.signal};try{let d=await fetch(o,f);if(!d.ok)throw await d.body?.cancel(),Object.assign(new Error(`Upload failed with status ${d.status}`),{status:d.status});t.loadedBytes=n,t.response=Promise.resolve(await d.text())}finally{clearInterval(m),clearTimeout(y),T.destroy()}}async backoff(t,r){let n=Math.min(this.BACKOFF_CAP_MS,this.BACKOFF_BASE_MS*2**(t-1)),o=n/2+Math.random()*(n/2),a=Math.max(0,Math.min(o,r-Date.now()));a>0&&await new Promise(s=>setTimeout(s,a))}async getSignedURLForUpload(t){let r=new AbortController,n=setTimeout(()=>r.abort(),this.SIGNED_URL_TIMEOUT_MS);try{let o=JSON.stringify(t.info),a=`${this.apiBaseURL}/${this.makeGetUploadUrlAPIPath(t)}`,s={Accept:"application/json","Content-Type":"application/json",ChecksumAppCode:this.apiKey},l=await fetch(a,{method:"POST",headers:s,body:o,signal:r.signal}),{url:p}=await Ne(l,{resource:"get-upload-url",requiredFields:["url"]});t.uploadURL=p}catch(o){throw delete t.uploadURL,o}finally{clearTimeout(n)}}};function xr(e,t,r=Date.now()){if(e.length===0)return!1;let n=e.reduce((o,a)=>Math.max(o,a.lastProgress??0),0);return n>0&&r-n>t}i(xr,"isUploadStalled");var ot=class{static{i(this,"CLIChannel")}constructor(){}sendToCLI(...t){console.log(`{trm}${t.map(r=>r.toString()).join(`,
|
|
12
|
+
`)}{/trm}`)}event(t,r){return new Promise(n=>{let o=r?`${t}=${r}`:t;setTimeout(()=>{this.sendToCLI(`monitor:${o}`),n(!0)},100)})}trace(t,r){let n=r?`${t}=${JSON.stringify(r)}`:t;setTimeout(()=>{this.sendToCLI(`trace:${n}`)},100)}log(t){return this.event("log",t)}debug(...t){this.sendToCLI(t)}wideEvent(t){let r=Buffer.from(JSON.stringify(t),"utf-8").toString("base64");this.sendToCLI(`wideevent:${r}`)}},Me=class{constructor(t,r=!1){this.config=t;this.isolationMode=r;this.MAX_UPLOADS=15;this.MONITOR_INTERVAL=2500;this.UPLOAD_TIMEOUT=600*1e3;this.UPLOAD_STALL_TIMEOUT=600*1e3;this.WATCH_TIMEOUT=120*1e3;this.assets=[];this.watchAssets=[];this.processingPaths=new Set;this.reportComplete=!1;this.processingInProgress=!1;this.pwTestIdToChecksumTestId={};this.checksumTestIdToUsingPlaceholder={};this.progressFlushInFlight=!1;this.stallEventEmitted=!1;this.channel=new ot,nt(n=>this.channel.wideEvent(n)),this.testAssetUploader=new Le(t.apiURL,t.apiKey,this.UPLOAD_TIMEOUT,()=>`client-api/test-runs/${this.config.sessionId}/get-upload-url`,this.isolationMode,{start:i(n=>this.channel.trace("Upload Start",{filename:n}),"start"),complete:i(n=>{if(!this.reportAsset||n!==this.reportAsset.info.path)try{(0,k.unlinkSync)(n),this.channel.debug(`[TestAssetUploader] Deleted file after successful upload: ${n}`)}catch(o){this.channel.debug(`[TestAssetUploader] Failed to delete file after upload: ${n}`,o)}this.channel.trace("Upload Complete",{filename:n})},"complete"),error:i((n,o)=>this.channel.trace("Upload Failed",{filename:n,error:o}),"error")},t.sessionId),setInterval(this.monitorUploads.bind(this),this.MONITOR_INTERVAL),this.listenForMessages(),this.startServer()}static{i(this,"TestRunMonitor")}listenForMessages(){process.stdin.on("data",t=>{(async()=>{let r=t.toString().trim();if(!r.startsWith("cli:"))return;let[n,o]=r.substring(4).split("=");switch(this.channel.debug("Received message from CLI "+n+" "+o),n){case"report":if(this.testRunEndTime=Date.now(),o!=="false")try{let a=Buffer.from(o??"","base64").toString("utf-8"),s=JSON.parse(a);await this.handleReport(s)}catch(a){this.channel.debug("Error JSON parsing report payload, continue without report. Error: "+this.stringify(a)),this.reportComplete=!0}else this.reportComplete=!0;this.monitorUploadsCompletion();break;case"shutdown":this.shutdown();break}})()})}async readMetadataFile(t){try{let r=await(0,Lr.readFile)(t,"utf-8");return JSON.parse(r)}catch(r){return this.channel.trace("Runtime Error",`Error reading checksum metadata file ${t}: ${r.message}`),{}}}async serveReport(t){try{let r=(0,V.dirname)(t);await this.channel.log("Serving report in browser: "+r);let n=Ce.isRepoMode?`yarn playwright show-report ${r}`:`npx playwright show-report ${r}`;(0,Nr.execSync)(n,{encoding:"utf8",stdio:"pipe"}),await this.channel.log("Success: Report opened in browser")}catch(r){await this.channel.log(`Error serving report in browser: ${r.message}`),r.stderr&&await this.channel.log(r.stderr.toString())}}async handleReport(t){let{reportPath:r,pathToChecksumMetadata:n,didFail:o,openReportCriteria:a,checksumRoot:s,projectRoot:l,isUploadReport:p,dedupeByChecksumTestId:m}=t;this.channel.debug(`Handling report ${this.isolationMode?"(isolation mode)":""}`+r),this.uploadReportData((0,V.dirname)(r),p);let y=ae("report_processing",{test_suite_run_id:this.config.sessionId,report_path:r,isolation_mode:this.isolationMode,is_upload_report:!!p});try{let T=await this.readMetadataFile(n),S=new De(r,this.config.sessionId,this.pwTestIdToChecksumTestId,T,{hosted:!this.isolationMode,...m?{dedupeByChecksumTestId:m}:{}},this.channel,s,l,this.checksumTestIdToUsingPlaceholder),C=this.initAsset({type:"report",path:""});this.reportAsset=C;try{let d=await S.process();C.info.path=S.getProcessedFilePath(),y.set({processed_path:C.info.path,...d}),this.uploadAsset(C)}catch(d){this.channel.debug("Error processing report, "+d.message),C.error=!0,y.set({error:Y(d)})}let u=S.getReportsStats();this.stats=u,at(y,C.error?"error":"success",u),this.channel.debug("Checking watch assets");let f=this.watchAssets.filter(d=>!(d.type!=="trace"||S.testHasTrace(d.testId??"",d.project??"")));f.length>0&&(this.channel.debug("Removed watch assets - "),this.channel.debug(JSON.stringify(f.map(d=>d.path)))),this.watchAssets=this.watchAssets.filter(d=>d.type!=="trace"||S.testHasTrace(d.testId??"",d.project??""))}catch(T){this.channel.debug("Error processing report, "+this.stringify(T)),this.reportAsset&&(this.reportAsset.error=!0),y.emit({outcome:"error",error:Y(T)})}finally{if((a==="always"||a==="on-failure"&&o)&&await this.serveReport(r),n&&(0,k.existsSync)(n))try{(0,k.unlinkSync)(n)}catch(S){console.error(`Error deleting checksum metadata file ${n}: ${S.message}`)}}}async uploadReportData(t,r){let n=(0,V.join)(t,"data");try{let o=(0,k.readdirSync)(n),a=r?[".webm"]:[".zip",".webm"],s=o.filter(l=>!a.includes((0,V.extname)(l)));this.channel.debug("Preparing to upload report data files,"+s);for(let l of s)this.channel.debug("Uploading report data file,"+l),this.addAsset({type:"report-data-file",fileName:l,path:`${n}/${l}`})}catch(o){this.channel.debug(`Error reading/adding report data files from dir ${n}`+o.message)}}shutdown(){this.channel.debug("Received shutdown message from CLI"),this.server.close(),process.exit(0)}async monitorUploadsCompletion(){if(!this.reportComplete&&this.reportAsset&&(this.reportAsset.complete||this.reportAsset.error)){this.reportComplete=!0;let t="";try{let r=JSON.stringify(this.stats),n=`checksum-stats-${(0,he.randomBytes)(8).toString("hex")}.json`;t=(0,V.join)((0,Pr.tmpdir)(),n),(0,k.writeFileSync)(t,r,"utf-8"),this.channel.debug(`Stats written to temporary file: ${t}`)}catch(r){this.channel.debug("Error writing stats to file"),this.channel.log(`[monitorUploadsCompletion] Error writing stats to file: ${r.message}`)}this.channel.event("report-complete",`${this.reportAsset?.complete?"true":"false"}:${t}`)}if(!this.processingInProgress&&this.reportComplete&&(this.assets.filter(t=>t.complete||t.error).length===this.assets.length||this.isUploadStalled())&&(this.watchAssets.length===0||this.testRunEndTime&&Date.now()-this.testRunEndTime>this.WATCH_TIMEOUT)){let t=Date.now(),r=this.assets.filter(s=>!s.complete&&!s.error);this.assets.forEach(s=>{!s.complete&&!s.error&&(s.error=!0)});let n=this.assets.find(s=>s.error)?"uploads-complete-with-errors":"uploads-complete",o=this.assets.filter(s=>s.error);xe("uploads_completion",{test_suite_run_id:this.config.sessionId,outcome:o.length>0?"error":"success",decision:n,total_assets:this.assets.length,completed:this.assets.filter(s=>s.complete).length,errored:o.length,stalled:r.length>0,stalled_count:r.length,watch_remaining:this.watchAssets.length,report_complete:this.reportComplete,upload_finalize_ms:this.testRunEndTime?t-this.testRunEndTime:void 0,errored_assets:o.map(s=>this.assetSnapshot(s,t))});let a=n==="uploads-complete"?{}:{uploadErrors:this.assets.filter(s=>s.error).map(s=>{try{return JSON.stringify(s)}catch{return s.info.path}}),watchAssets:this.watchAssets,testRunEndTime:this.testRunEndTime,now:Date.now()};try{this.cleanUp()}catch(s){this.channel.debug("cleanUp failed (ignored): "+s?.message)}this.channel.event(n,JSON.stringify(a));return}await ke(1e3),this.monitorUploadsCompletion()}assetSnapshot(t,r){return{file_name:t.info.fileName??(0,V.basename)(t.info.path),asset_type:t.info.type,test_id:t.info.testId,loaded_bytes:t.loadedBytes,size_bytes:t.sizeBytes,last_progress_age_ms:t.lastProgress?r-t.lastProgress:void 0}}cleanUp(){let t;for(let r of this.assets)if(r.info.type==="rrweb-recording"){t=(0,V.dirname)(r.info.path);break}t&&(0,k.rmSync)(t,{recursive:!0,force:!0})}isUploadStalled(){let t=xr(this.assets,this.UPLOAD_STALL_TIMEOUT);if(t&&(this.channel.log("Uploads are stalled"),!this.stallEventEmitted)){this.stallEventEmitted=!0;let r=Date.now(),n=this.assets.filter(o=>!o.complete&&!o.error);xe("upload_stall_detected",{test_suite_run_id:this.config.sessionId,outcome:"error",timeout_ms:this.UPLOAD_STALL_TIMEOUT,total_assets:this.assets.length,pending_count:n.length,pending_assets:n.map(o=>this.assetSnapshot(o,r))})}return t}async startServer(){let t=await this.acquirePortNumber();this.channel.event("port",t.toString()),this.server=(0,Mr.createServer)((r,n)=>{let o=i(s=>{n.writeHead(400,{"Content-Type":"text/plain"}),n.end(s)},"returnErrorWithMessage");if(r.method!=="POST"){n.writeHead(404,{"Content-Type":"text/plain"}),n.end("Method not allowed");return}let a="";r.on("data",s=>{a+=s.toString()}),r.on("end",()=>{let s;try{s=JSON.parse(a)}catch{o("Invalid body");return}let{type:l,payload:p,watch:m}=s;switch(this.channel.debug(`Server received message, ${l}, ${this.stringify(p)}`),l){case"asset":if(!p.path||!p.type){o("Missing arguments");return}m?this.watchAsset(p):this.processAsset(p);break;case"testInfo":if(!p.pwTestId||!p.checksumTestId){o("Missing arguments");return}this.pwTestIdToChecksumTestId[p.pwTestId]=p.checksumTestId,p.usingChecksumTestIdPlaceholder!==void 0&&(this.checksumTestIdToUsingPlaceholder[p.checksumTestId]=p.usingChecksumTestIdPlaceholder);break;case"checksumTestMetadata":{let y=p;if(!y.checksumTestId||!p.data){o("Missing arguments");return}this.channel.event("checksumTestMetadata",JSON.stringify({...y}));break}case"testStats":break;case"playwrightConfig":this.channel.event("playwrightConfig",JSON.stringify(p));break;case"runProgress":this.forwardProgress(p);break;default:o("Invalid message type");return}n.writeHead(200,{"Content-Type":"text/plain"}),n.end("OK")})}),this.server.listen(t)}forwardProgress(t){this.latestProgress=t,!this.progressFlushInFlight&&this.flushProgress()}async flushProgress(){this.progressFlushInFlight=!0;try{for(;this.latestProgress;){let t=this.latestProgress;this.latestProgress=void 0,await this.patchProgress(t)}}finally{this.progressFlushInFlight=!1}}async patchProgress(t){if(this.isolationMode)return;let r=new AbortController,n=setTimeout(()=>r.abort(),3e4);try{await fetch(`${this.config.apiURL}/client-api/test-runs/${this.config.sessionId}/progress`,{method:"PATCH",headers:{Accept:"application/json","Content-Type":"application/json",ChecksumAppCode:this.config.apiKey},body:JSON.stringify({progress:t}),signal:r.signal})}catch(o){this.channel.debug("Failed to send run progress: "+o?.message)}finally{clearTimeout(n)}}stringify(t){try{return JSON.stringify(t)}catch{return"message"in t?t.message:t}}monitorUploads(){let{totalSizeBytes:t,totalUploadedBytes:r}=this.calculateUploadProgress();if(t>0&&!this.isolationMode){let a=(r/t*100).toFixed(2);this.channel.event("upload-progress",a)}let n=this.assets.filter(a=>!a.uploadStarted);if(n.length===0)return;let o=i(()=>this.assets.filter(a=>a.uploadStarted&&!a.complete&&!a.error).length,"getNumOfActiveUploads");if(!(o()>=this.MAX_UPLOADS))for(;n.length>0&&o()<this.MAX_UPLOADS;){let a=n.pop();if(a===void 0)break;this.uploadAsset(a)}}calculateUploadProgress(){let t=this.assets.reduce((n,{sizeBytes:o})=>n+(o??0),0),r=Math.min(t,this.assets.reduce((n,{loadedBytes:o})=>n+(o??0),0));return{totalSizeBytes:t,totalUploadedBytes:r}}getUploadLogMessage(t){switch(t.info.type){case"report":return"Uploading report";case"har":return`Uploading har file for test ${t.info.testId}`;case"trace":return`Uploading trace file for test ${t.info.testId}`;case"esra":return`Uploading metadata file for test ${t.info.testId}`;case"test-files":return`Uploading auto-healed test code for file ${t.info.path}`;default:return}}async uploadAsset(t){try{t.uploadStarted=!0;let r=this.getUploadLogMessage(t);r&&!this.isolationMode&&this.channel.event("log",r),await this.testAssetUploader.uploadAsset(t)}catch(r){t.error=!0,this.channel.debug("Error uploading asset"+this.stringify(r)),this.channel.trace("Upload Failed",{asset:t.info.fileName,error:String(r)})}}async getSignedURLForUpload(t){try{let{apiKey:r,sessionId:n,apiURL:o}=this.config,a=t.info,s=await fetch(`${o}/client-api/test-runs/${n}/get-upload-url`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",ChecksumAppCode:r},body:JSON.stringify(a)}),{url:l}=await Ne(s,{resource:"get-upload-url",requiredFields:["url"]});t.uploadURL=l}catch(r){this.channel.debug("Error getting signed URL for artifact"+this.stringify(r))}}watchAsset(t){if(this.watchAssets.some(n=>n.path===t.path)){this.channel.debug(`Already watching file ${t.path}, skipping duplicate`);return}this.channel.debug("Watching file "+t.path),this.watchAssets.push({...t,addedAt:Date.now()});let r=i(async()=>{await this.waitForFileComplete(t.path)&&(this.processAsset(t),this.watchAssets=this.watchAssets.filter(o=>o.path!==t.path))},"waitForCompletion");if((0,k.existsSync)(t.path))r();else{let n=(0,V.dirname)(t.path),o=(0,V.basename)(t.path),a=!1,s=(0,k.watch)(n,(l,p)=>{(async()=>{if(!(p!==o||a))try{this.channel.debug("Watched file changed "+t.path),a=!0,await r()}finally{s.close()}})()})}}waitForFileComplete(t,r=1e3,n=6e4,o=1){return new Promise(a=>{let s=Date.now(),l=0,p=i(()=>{if(!(0,k.existsSync)(t)){this.channel.debug(`Asset required for upload doesn't exist anymore ${t}`),a(!1);return}let m=(0,k.statSync)(t).size;if(m===l){if(o>0){this.channel.debug(`File size has not changed, verifying stabilization, ${t}, size: ${m}, equalSizeValidationCountLeft: ${o}`),o--,setTimeout(p,r);return}this.channel.debug(`File size has not changed, stabilization verified, ${t}, size: ${m}`),a(!0);return}if(this.channel.debug(`File size changed, waiting for stabilization, ${t}, previous size: ${l}, current size: ${m}`),Date.now()-s>n){this.channel.debug(`Asset required for upload is taking over ${n} ms to write to disk ${t}`),a(!0);return}l=m,setTimeout(p,r)},"checkFile");p()})}processAsset(t){switch(t.type){case"trace":return this.processTrace(t.path,t.testId);case"har":return this.processHar();case"rrweb-recording":case"esra":case"test-files":return this.addAsset(t);default:return}}async processHar(){}async calculateFileSha1Streaming(t){let r=(0,he.createHash)("sha1"),n=(0,k.createReadStream)(t);return await(0,Or.pipeline)(n,r),r.digest("hex")}async processTrace(t,r){if(this.processingPaths.has(t)){this.channel.debug(`Trace file ${t} already being processed, skipping`);return}this.processingPaths.add(t);let n;try{this.processingInProgress=!0,await ke(1e3),n=ae("trace_processing",{test_suite_run_id:this.config.sessionId,test_id:r});let o=t;if(!this.isolationMode){this.channel.debug(`Preparing trace for upload (testId: ${r})...`),o=t.replace(".zip",".actual.zip"),(0,k.renameSync)(t,o);let l="checksum-playwright-trace:"+Date.now().toString()+(0,he.randomBytes)(1024).toString("hex");(0,k.writeFileSync)(t,l)}let s=await i(async()=>await this.calculateFileSha1Streaming(t)+(0,V.extname)(t),"makePlaywrightHTMLReporterName")();this.channel.debug(`Trace file for test ${r} has been manipulated with file name ${s}, sending for upload...`),this.addAsset({type:"report-data-file",path:o,...r!==void 0?{testId:r}:{},fileName:s}),n?.emit({outcome:"success",file_name:s})}catch(o){let a=String(o);this.channel.debug("Error processing trace file"+a),this.channel.trace("Trace Processing Error",{error:a}),n?.emit({outcome:"error",error:Y(o)})}finally{this.processingPaths.delete(t),this.processingInProgress=!1}}addAsset(t){this.channel.debug("Adding file "+t.path);let r=this.initAsset(t);return this.assets.push(r),r}initAsset(t){return{complete:!1,error:!1,info:t,removeAfterUpload:t.type==="rrweb-recording"}}async acquirePortNumber(){return new Promise((t,r)=>{let n=kr.createServer();n.unref(),n.on("error",r),n.listen(0,()=>{let o=n.address().port;n.close(()=>{t(o)})})})}},Ur;try{Ur=JSON.parse(process.argv[2]??"")}catch(e){console.log("Error starting test run monitor",e),process.exit(1)}new Me(Ur,process.argv?.[3]==="isolated");0&&(module.exports={TestRunMonitor});
|