@checksum-ai/runtime 5.3.0 → 5.3.2

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/package.json CHANGED
@@ -45,5 +45,5 @@
45
45
  "url": "https://github.com/checksum-ai/checksum-ai-monorepo/issues"
46
46
  },
47
47
  "homepage": "https://github.com/checksum-ai/checksum-ai-monorepo/tree/main/packages/runtime#readme",
48
- "version": "5.3.0"
48
+ "version": "5.3.2"
49
49
  }
@@ -1,13 +1,13 @@
1
- "use strict";var Sn=Object.create;var he=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var Rn=Object.getOwnPropertyNames;var An=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty;var s=(e,t)=>he(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}},Cn=(e,t)=>{for(var r in t)he(e,r,{get:t[r],enumerable:!0})},It=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rn(t))!Mn.call(e,o)&&o!==r&&he(e,o,{get:()=>t[o],enumerable:!(n=In(t,o))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?Sn(An(e)):{},It(t||!e||!e.__esModule?he(r,"default",{value:e,enumerable:!0}):r,e)),xn=e=>It(he({},"__esModule",{value:!0}),e);var je=W((Bi,q)=>{var Ke=require("fs"),Re=require("path"),Nn=require("os"),wn=require("crypto"),Mt=["\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 Dn(){return Mt[Math.floor(Math.random()*Mt.length)]}s(Dn,"_getRandomTip");function ie(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}s(ie,"parseBoolean");function Ln(){return process.stdout.isTTY}s(Ln,"supportsAnsi");function On(e){return Ln()?`\x1B[2m${e}\x1B[0m`:e}s(On,"dim");var Pn=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Un(e){let t={},r=e.toString();r=r.replace(/\r\n?/mg,`
1
+ "use strict";var Sn=Object.create;var he=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var Rn=Object.getOwnPropertyNames;var Mn=Object.getPrototypeOf,An=Object.prototype.hasOwnProperty;var s=(e,t)=>he(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}},Cn=(e,t)=>{for(var r in t)he(e,r,{get:t[r],enumerable:!0})},It=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rn(t))!An.call(e,o)&&o!==r&&he(e,o,{get:()=>t[o],enumerable:!(n=In(t,o))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?Sn(Mn(e)):{},It(t||!e||!e.__esModule?he(r,"default",{value:e,enumerable:!0}):r,e)),xn=e=>It(he({},"__esModule",{value:!0}),e);var je=W((Bi,q)=>{var Ke=require("fs"),Re=require("path"),Nn=require("os"),wn=require("crypto"),At=["\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 At[Math.floor(Math.random()*At.length)]}s(On,"_getRandomTip");function ie(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}s(ie,"parseBoolean");function Dn(){return process.stdout.isTTY}s(Dn,"supportsAnsi");function Ln(e){return Dn()?`\x1B[2m${e}\x1B[0m`:e}s(Ln,"dim");var Pn=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Un(e){let t={},r=e.toString();r=r.replace(/\r\n?/mg,`
2
2
  `);let n;for(;(n=Pn.exec(r))!=null;){let o=n[1],a=n[2]||"";a=a.trim();let i=a[0];a=a.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),i==='"'&&(a=a.replace(/\\n/g,`
3
- `),a=a.replace(/\\r/g,"\r")),t[o]=a}return t}s(Un,"parse");function Fn(e){e=e||{};let t=Nt(e);e.path=t;let r=k.configDotenv(e);if(!r.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=vt(e).split(","),o=n.length,a;for(let i=0;i<o;i++)try{let c=n[i].trim(),d=Bn(r,c);a=k.decrypt(d.ciphertext,d.key);break}catch(c){if(i+1>=o)throw c}return k.parse(a)}s(Fn,"_parseVault");function kn(e){console.error(`\u26A0 ${e}`)}s(kn,"_warn");function ye(e){console.log(`\u2506 ${e}`)}s(ye,"_debug");function xt(e){console.log(`\u25C7 ${e}`)}s(xt,"_log");function vt(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:""}s(vt,"_dotenvKey");function Bn(e,t){let r;try{r=new URL(t)}catch(c){if(c.code==="ERR_INVALID_URL"){let d=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 d.code="INVALID_DOTENV_KEY",d}throw c}let n=r.password;if(!n){let c=new Error("INVALID_DOTENV_KEY: Missing key part");throw c.code="INVALID_DOTENV_KEY",c}let o=r.searchParams.get("environment");if(!o){let c=new Error("INVALID_DOTENV_KEY: Missing environment part");throw c.code="INVALID_DOTENV_KEY",c}let a=`DOTENV_VAULT_${o.toUpperCase()}`,i=e.parsed[a];if(!i){let c=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw c.code="NOT_FOUND_DOTENV_ENVIRONMENT",c}return{ciphertext:i,key:n}}s(Bn,"_instructions");function Nt(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)Ke.existsSync(r)&&(t=r.endsWith(".vault")?r:`${r}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=Re.resolve(process.cwd(),".env.vault");return Ke.existsSync(t)?t:null}s(Nt,"_vaultPath");function Ct(e){return e[0]==="~"?Re.join(Nn.homedir(),e.slice(1)):e}s(Ct,"_resolveHome");function Hn(e){let t=ie(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),r=ie(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!r)&&xt("loading env from encrypted .env.vault");let n=k._parseVault(e),o=process.env;return e&&e.processEnv!=null&&(o=e.processEnv),k.populate(o,n,e),{parsed:n}}s(Hn,"_configVault");function Gn(e){let t=Re.resolve(process.cwd(),".env"),r="utf8",n=process.env;e&&e.processEnv!=null&&(n=e.processEnv);let o=ie(n.DOTENV_CONFIG_DEBUG||e&&e.debug),a=ie(n.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?r=e.encoding:o&&ye("no encoding is specified (UTF-8 is used by default)");let i=[t];if(e&&e.path)if(!Array.isArray(e.path))i=[Ct(e.path)];else{i=[];for(let y of e.path)i.push(Ct(y))}let c,d={};for(let y of i)try{let T=k.parse(Ke.readFileSync(y,{encoding:r}));k.populate(d,T,e)}catch(T){o&&ye(`failed to load ${y} ${T.message}`),c=T}let m=k.populate(n,d,e);if(o=ie(n.DOTENV_CONFIG_DEBUG||o),a=ie(n.DOTENV_CONFIG_QUIET||a),o||!a){let y=Object.keys(m).length,T=[];for(let R of i)try{let _=Re.relative(process.cwd(),R);T.push(_)}catch(_){o&&ye(`failed to load ${R} ${_.message}`),c=_}xt(`injected env (${y}) from ${T.join(",")} ${On(`// tip: ${Dn()}`)}`)}return c?{parsed:d,error:c}:{parsed:d}}s(Gn,"configDotenv");function Wn(e){if(vt(e).length===0)return k.configDotenv(e);let t=Nt(e);return t?k._configVault(e):(kn(`you set DOTENV_KEY but you are missing a .env.vault file at ${t}`),k.configDotenv(e))}s(Wn,"config");function $n(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 i=wn.createDecipheriv("aes-256-gcm",r,o);return i.setAuthTag(a),`${i.update(n)}${i.final()}`}catch(i){let c=i instanceof RangeError,d=i.message==="Invalid key length",m=i.message==="Unsupported state or unable to authenticate data";if(c||d){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 i}}s($n,"decrypt");function zn(e,t,r={}){let n=!!(r&&r.debug),o=!!(r&&r.override),a={};if(typeof t!="object"){let i=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw i.code="OBJECT_REQUIRED",i}for(let i of Object.keys(t))Object.prototype.hasOwnProperty.call(e,i)?(o===!0&&(e[i]=t[i],a[i]=t[i]),n&&ye(o===!0?`"${i}" is already defined and WAS overwritten`:`"${i}" is already defined and was NOT overwritten`)):(e[i]=t[i],a[i]=t[i]);return a}s(zn,"populate");var k={configDotenv:Gn,_configVault:Hn,_parseVault:Fn,config:Wn,decrypt:$n,parse:Un,populate:zn};q.exports.configDotenv=k.configDotenv;q.exports._configVault=k._configVault;q.exports._parseVault=k._parseVault;q.exports.config=k.config;q.exports.decrypt=k.decrypt;q.exports.parse=k.parse;q.exports.populate=k.populate;q.exports=k});var Ze=W((ha,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 Ae=W(kt=>{var Ft={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 Jn(e){return function(...t){return t.length&&(e=e.replace(/\{(\d)\}/g,(r,n)=>t[n]||"")),new Error("ADM-ZIP: "+e)}}s(Jn,"E");for(let e of Object.keys(Ft))kt[e]=Jn(Ft[e])});var $t=W((Ta,Wt)=>{var Yn=require("fs"),F=require("path"),Bt=Ze(),qn=Ae(),Xn=typeof process=="object"&&process.platform==="win32",Ht=s(e=>typeof e=="object"&&e!==null,"is_Obj"),Gt=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 D(e){this.sep=F.sep,this.fs=Yn,Ht(e)&&Ht(e.fs)&&typeof e.fs.statSync=="function"&&(this.fs=e.fs)}s(D,"Utils");Wt.exports=D;D.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 i;try{i=t.fs.statSync(o)}catch(c){if(c.message&&c.message.startsWith("ENOENT"))t.fs.mkdirSync(o);else throw c}if(i&&i.isFile())throw qn.FILE_IN_THE_WAY(`"${o}"`)}})}s(r,"mkdirSync"),r(e)};D.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 i=F.dirname(e);o.fs.existsSync(i)||o.makeDir(i);var c;try{c=o.fs.openSync(e,"w",438)}catch{o.fs.chmodSync(e,438),c=o.fs.openSync(e,"w",438)}if(c)try{o.fs.writeSync(c,t,0,t.length,0)}finally{o.fs.closeSync(c)}return o.fs.chmodSync(e,n||438),!0};D.prototype.writeFileToAsync=function(e,t,r,n,o){typeof n=="function"&&(o=n,n=void 0);let a=this;a.fs.exists(e,function(i){if(i&&!r)return o(!1);a.fs.stat(e,function(c,d){if(i&&d&&d.isDirectory())return o(!1);var m=F.dirname(e);a.fs.exists(m,function(y){if(!y)try{a.makeDir(m)}catch{return o(!1)}let T=s(function(R){a.fs.write(R,t,0,t.length,0,function(_){a.fs.close(R,function(){if(_)return o(!1);a.fs.chmod(e,n||438,function(){o(!0)})})})},"writeToFd");a.fs.open(e,"w",438,function(R,_){R?a.fs.chmod(e,438,function(){a.fs.open(e,"w",438,function(u,f){if(u||!f)return o(!1);T(f)})}):_?T(_):o(!1)})})})})};D.prototype.findFiles=function(e){let t=this;function r(n,o,a,i){typeof o=="boolean"&&(a=o,o=void 0);let c=[];return t.fs.readdirSync(n).forEach(function(d){let m=F.join(n,d),y=t.fs.statSync(m);if((!o||o.test(m))&&c.push(F.normalize(m)+(y.isDirectory()?t.sep:"")),y.isDirectory()&&a){let T=t.fs.realpathSync(m);i.has(T)||(i.add(T),c=c.concat(r(m,o,a,i)))}}),c}return s(r,"findSync"),r(e,void 0,!0,new Set([t.fs.realpathSync(e)]))};D.prototype.findFilesAsync=function(e,t){let r=this,n=[],o=!1,a=s(function(c){o||(o=!0,t(c,c?void 0:n))},"finish"),i=s(function(c,d,m){r.fs.readdir(c,function(y,T){if(y)return m(y);let R=T.length;if(!R)return m();T.forEach(function(_){let u=F.join(c,_);r.fs.stat(u,function(f,p){if(f)return m(f);if(!p){--R||m();return}if(n.push(F.normalize(u)+(p.isDirectory()?r.sep:"")),!p.isDirectory()){--R||m();return}r.fs.realpath(u,function(h,E){if(h)return m(h);if(d.has(E)){--R||m();return}d.add(E),i(u,d,function(l){if(l)return m(l);--R||m()})})})})})},"walk");r.fs.realpath(e,function(c,d){if(c)return a(c);i(e,new Set([d]),a)})};D.prototype.getAttributes=function(){};D.prototype.setAttributes=function(){};D.crc32update=function(e,t){return Gt[(e^t)&255]^e>>>8};D.crc32=function(e){typeof e=="string"&&(e=Buffer.from(e,"utf8"));let t=e.length,r=-1;for(let n=0;n<t;)r=D.crc32update(r,e[n++]);return~r>>>0};D.methodToString=function(e){switch(e){case Bt.STORED:return"STORED ("+e+")";case Bt.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}};D.canonical=function(e){if(!e)return"";let t=F.posix.normalize("/"+e.split("\\").join("/"));return F.join(".",t)};D.zipnamefix=function(e){if(!e)return"";let t=F.posix.normalize("/"+e.split("\\").join("/"));return F.posix.join(".",t)};D.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]};D.sanitize=function(e,t){e=F.resolve(F.normalize(e));for(var r=t.split("/"),n=0,o=r.length;n<o;n++){var a=F.normalize(F.join(e,r.slice(n,o).join(F.sep)));if(a===e||a.startsWith(e+F.sep))return a}return F.normalize(F.join(e,F.basename(t)))};D.toBuffer=s(function(t,r){return Buffer.isBuffer(t)?t:t instanceof Uint8Array?Buffer.from(t):typeof t=="string"?r(t):Buffer.alloc(0)},"toBuffer");D.readBigUInt64LE=function(e,t){let r=e.readUInt32LE(t);return e.readUInt32LE(t+4)*4294967296+r};D.writeBigUInt64LE=function(e,t,r){let n=t>>>0,o=Math.floor(t/4294967296)>>>0;e.writeUInt32LE(n,r),e.writeUInt32LE(o,r+4)};D.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)};D.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};D.isWin=Xn;D.crcTable=Gt});var Vt=W((ba,zt)=>{var Qn=require("path");zt.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 s(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=Qn.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:s(function(){},"decodeAttributes"),encodeAttributes:s(function(){},"encodeAttributes"),toJSON:s(function(){return{path:r,isDirectory:n.directory,isReadOnly:n.readonly,isHidden:n.hidden,isExecutable:n.executable,mTime:n.mtime,aTime:n.atime}},"toJSON"),toString:s(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var jt=W((Ia,Kt)=>{Kt.exports={efs:!0,encode:s(e=>Buffer.from(e,"utf8"),"encode"),decode:s(e=>e.toString("utf8"),"decode")}});var le=W((Aa,ae)=>{ae.exports=$t();ae.exports.Constants=Ze();ae.exports.Errors=Ae();ae.exports.FileAttr=Vt();ae.exports.decoder=jt()});var Jt=W((Ma,Zt)=>{var Q=le(),b=Q.Constants;Zt.exports=function(){var e=20,t=10,r=0,n=0,o=0,a=0,i=0,c=0,d=0,m=0,y=0,T=0,R=0,_=0,u=0;e|=Q.isWin?2560:768,r|=b.FLG_EFS;let f={extraLen:0},p=s(l=>Math.max(0,l)>>>0,"uint32"),h=s(l=>Math.max(0,l)&65535,"uint16"),E=s(l=>Math.max(0,l)&255,"uint8");return o=Q.fromDate2DOS(new Date),{get made(){return e},set made(l){e=l},get version(){return t},set version(l){t=l},get flags(){return r},set flags(l){r=l},get flags_efs(){return(r&b.FLG_EFS)>0},set flags_efs(l){l?r|=b.FLG_EFS:r&=~b.FLG_EFS},get flags_desc(){return(r&b.FLG_DESC)>0},set flags_desc(l){l?r|=b.FLG_DESC:r&=~b.FLG_DESC},get method(){return n},set method(l){switch(l){case b.STORED:this.version=10;break;case b.DEFLATED:default:this.version=20}n=l},get time(){return Q.fromDOS2Date(this.timeval)},set time(l){l=new Date(l),this.timeval=Q.fromDate2DOS(l)},get timeval(){return o},set timeval(l){o=p(l)},get timeHighByte(){return E(o>>>8)},get crc(){return a},set crc(l){a=p(l)},get compressedSize(){return i},set compressedSize(l){i=p(l)},get size(){return c},set size(l){c=p(l)},get fileNameLength(){return d},set fileNameLength(l){d=l},get extraLength(){return m},set extraLength(l){m=l},get extraLocalLength(){return f.extraLen},set extraLocalLength(l){f.extraLen=l},get commentLength(){return y},set commentLength(l){y=l},get diskNumStart(){return T},set diskNumStart(l){T=p(l)},get inAttr(){return R},set inAttr(l){R=p(l)},get attr(){return _},set attr(l){_=p(l)},get fileAttr(){return(_||0)>>16&4095},get offset(){return u},set offset(l){u=p(l)},get encrypted(){return(r&b.FLG_ENC)===b.FLG_ENC},get centralHeaderSize(){return b.CENHDR+d+m+y},get realDataOffset(){return u+b.LOCHDR+f.fnameLen+f.extraLen},get localHeader(){return f},loadLocalHeaderFromBinary:s(function(l){var g=l.slice(u,u+b.LOCHDR);if(g.readUInt32LE(0)!==b.LOCSIG)throw Q.Errors.INVALID_LOC();f.version=g.readUInt16LE(b.LOCVER),f.flags=g.readUInt16LE(b.LOCFLG),f.flags_desc=(f.flags&b.FLG_DESC)>0,f.method=g.readUInt16LE(b.LOCHOW),f.time=g.readUInt32LE(b.LOCTIM),f.crc=g.readUInt32LE(b.LOCCRC),f.compressedSize=g.readUInt32LE(b.LOCSIZ),f.size=g.readUInt32LE(b.LOCLEN),f.fnameLen=g.readUInt16LE(b.LOCNAM),f.extraLen=g.readUInt16LE(b.LOCEXT);let I=u+b.LOCHDR+f.fnameLen,A=I+f.extraLen;return l.slice(I,A)},"loadLocalHeaderFromBinary"),loadFromBinary:s(function(l){if(l.length!==b.CENHDR||l.readUInt32LE(0)!==b.CENSIG)throw Q.Errors.INVALID_CEN();e=l.readUInt16LE(b.CENVEM),t=l.readUInt16LE(b.CENVER),r=l.readUInt16LE(b.CENFLG),n=l.readUInt16LE(b.CENHOW),o=l.readUInt32LE(b.CENTIM),a=l.readUInt32LE(b.CENCRC),i=l.readUInt32LE(b.CENSIZ),c=l.readUInt32LE(b.CENLEN),d=l.readUInt16LE(b.CENNAM),m=l.readUInt16LE(b.CENEXT),y=l.readUInt16LE(b.CENCOM),T=l.readUInt16LE(b.CENDSK),R=l.readUInt16LE(b.CENATT),_=l.readUInt32LE(b.CENATX),u=l.readUInt32LE(b.CENOFF)},"loadFromBinary"),localHeaderToBinary:s(function(){var l=Buffer.alloc(b.LOCHDR);return l.writeUInt32LE(b.LOCSIG,0),l.writeUInt16LE(t,b.LOCVER),l.writeUInt16LE(r&~b.FLG_DESC,b.LOCFLG),l.writeUInt16LE(n,b.LOCHOW),l.writeUInt32LE(o,b.LOCTIM),l.writeUInt32LE(a,b.LOCCRC),l.writeUInt32LE(i,b.LOCSIZ),l.writeUInt32LE(c,b.LOCLEN),l.writeUInt16LE(d,b.LOCNAM),l.writeUInt16LE(f.extraLen,b.LOCEXT),l},"localHeaderToBinary"),centralHeaderToBinary:s(function(){var l=Buffer.alloc(b.CENHDR+d+m+y);return l.writeUInt32LE(b.CENSIG,0),l.writeUInt16LE(e,b.CENVEM),l.writeUInt16LE(t,b.CENVER),l.writeUInt16LE(r&~b.FLG_DESC,b.CENFLG),l.writeUInt16LE(n,b.CENHOW),l.writeUInt32LE(o,b.CENTIM),l.writeUInt32LE(a,b.CENCRC),l.writeUInt32LE(i,b.CENSIZ),l.writeUInt32LE(c,b.CENLEN),l.writeUInt16LE(d,b.CENNAM),l.writeUInt16LE(m,b.CENEXT),l.writeUInt16LE(y,b.CENCOM),l.writeUInt16LE(T,b.CENDSK),l.writeUInt16LE(R,b.CENATT),l.writeUInt32LE(_,b.CENATX),l.writeUInt32LE(u,b.CENOFF),l},"centralHeaderToBinary"),toJSON:s(function(){let l=s(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:l(i),size:l(c),fileNameLength:l(d),extraLength:l(m),commentLength:l(y),diskNumStart:T,inAttr:R,attr:_,offset:u,centralHeaderSize:l(b.CENHDR+d+m+y)}},"toJSON"),toString:s(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var qt=W((xa,Yt)=>{var Z=le(),M=Z.Constants;Yt.exports=function(){var e=0,t=0,r=0,n=0,o=0;let a=s(()=>e>M.EF_ZIP64_OR_16||t>M.EF_ZIP64_OR_16||r>M.EF_ZIP64_OR_32||n>M.EF_ZIP64_OR_32,"needsZip64");return{get diskEntries(){return e},set diskEntries(i){e=t=i},get totalEntries(){return t},set totalEntries(i){t=e=i},get size(){return r},set size(i){r=i},get offset(){return n},set offset(i){n=i},get commentLength(){return o},set commentLength(i){o=i},get mainHeaderSize(){return(a()?M.ZIP64HDR+M.END64HDR:0)+M.ENDHDR+o},loadFromBinary:s(function(i){if((i.length!==M.ENDHDR||i.readUInt32LE(0)!==M.ENDSIG)&&(i.length<M.ZIP64HDR||i.readUInt32LE(0)!==M.ZIP64SIG))throw Z.Errors.INVALID_END();i.readUInt32LE(0)===M.ENDSIG?(e=i.readUInt16LE(M.ENDSUB),t=i.readUInt16LE(M.ENDTOT),r=i.readUInt32LE(M.ENDSIZ),n=i.readUInt32LE(M.ENDOFF),o=i.readUInt16LE(M.ENDCOM)):(e=Z.readBigUInt64LE(i,M.ZIP64SUB),t=Z.readBigUInt64LE(i,M.ZIP64TOT),r=Z.readBigUInt64LE(i,M.ZIP64SIZB),n=Z.readBigUInt64LE(i,M.ZIP64OFF),o=0)},"loadFromBinary"),toBinary:s(function(){if(!a()){var i=Buffer.alloc(M.ENDHDR+o);return i.writeUInt32LE(M.ENDSIG,0),i.writeUInt32LE(0,4),i.writeUInt16LE(e,M.ENDSUB),i.writeUInt16LE(t,M.ENDTOT),i.writeUInt32LE(r,M.ENDSIZ),i.writeUInt32LE(n,M.ENDOFF),i.writeUInt16LE(o,M.ENDCOM),i.fill(" ",M.ENDHDR),i}var i=Buffer.alloc(this.mainHeaderSize);let c=0;i.writeUInt32LE(M.ZIP64SIG,c),Z.writeBigUInt64LE(i,M.ZIP64HDR-M.ZIP64LEAD,c+M.ZIP64SIZE),i.writeUInt16LE(45,c+M.ZIP64VEM),i.writeUInt16LE(45,c+M.ZIP64VER),i.writeUInt32LE(0,c+M.ZIP64DSK),i.writeUInt32LE(0,c+M.ZIP64DSKDIR),Z.writeBigUInt64LE(i,e,c+M.ZIP64SUB),Z.writeBigUInt64LE(i,t,c+M.ZIP64TOT),Z.writeBigUInt64LE(i,r,c+M.ZIP64SIZB),Z.writeBigUInt64LE(i,n,c+M.ZIP64OFF);let d=n+r;return c+=M.ZIP64HDR,i.writeUInt32LE(M.END64SIG,c),i.writeUInt32LE(0,c+M.END64START),Z.writeBigUInt64LE(i,d,c+M.END64OFF),i.writeUInt32LE(1,c+M.END64NUMDISKS),c+=M.END64HDR,i.writeUInt32LE(M.ENDSIG,c),i.writeUInt32LE(0,c+4),i.writeUInt16LE(Math.min(e,M.EF_ZIP64_OR_16),c+M.ENDSUB),i.writeUInt16LE(Math.min(t,M.EF_ZIP64_OR_16),c+M.ENDTOT),i.writeUInt32LE(Math.min(r,M.EF_ZIP64_OR_32),c+M.ENDSIZ),i.writeUInt32LE(Math.min(n,M.EF_ZIP64_OR_32),c+M.ENDOFF),i.writeUInt16LE(o,c+M.ENDCOM),i.fill(" ",c+M.ENDHDR),i},"toBinary"),toJSON:s(function(){let i=s(function(c,d){let m=c.toString(16).toUpperCase();for(;m.length<d;)m="0"+m;return"0x"+m},"offset");return{diskEntries:e,totalEntries:t,size:r+" bytes",offset:i(n,4),commentLength:o}},"toJSON"),toString:s(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var Ye=W(Je=>{Je.EntryHeader=Jt();Je.MainHeader=qt()});var Qt=W((wa,Xt)=>{Xt.exports=function(e){var t=require("zlib"),r={chunkSize:(parseInt(e.length/1024)+1)*1024};return{deflate:s(function(){return t.deflateRawSync(e,r)},"deflate"),deflateAsync:s(function(n){var o=t.createDeflateRaw(r),a=[],i=0;o.on("data",function(c){a.push(c),i+=c.length}),o.on("end",function(){var c=Buffer.alloc(i),d=0;c.fill(0);for(var m=0;m<a.length;m++){var y=a[m];y.copy(c,d),d+=y.length}n&&n(c)}),o.end(e)},"deflateAsync")}}});var tr=W((La,er)=>{var eo=+(process?.versions?.node??"").split(".")[0]||0;er.exports=function(e,t){var r=require("zlib");let n=eo>=15&&t>0?{maxOutputLength:t}:{};return{inflate:s(function(){return r.inflateRawSync(e,n)},"inflate"),inflateAsync:s(function(o){var a=r.createInflateRaw(n),i=[],c=0;a.on("data",function(d){i.push(d),c+=d.length}),a.on("end",function(){var d=Buffer.alloc(c),m=0;d.fill(0);for(var y=0;y<i.length;y++){var T=i[y];T.copy(d,m),m+=T.length}o&&o(d)}),a.end(e)},"inflateAsync")}}});var ir=W((Pa,sr)=>{"use strict";var{randomFillSync:rr}=require("crypto"),to=Ae(),ro=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}),or=s((e,t)=>Math.imul(e,t)>>>0,"uMul"),nr=s((e,t)=>ro[(e^t)&255]^e>>>8,"crc32update"),Ee=s(()=>typeof rr=="function"?rr(Buffer.alloc(12)):Ee.node(),"genSalt");Ee.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 Me={genSalt:Ee};function Ce(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])}s(Ce,"Initkeys");Ce.prototype.updateKeys=function(e){let t=this.keys;return t[0]=nr(t[0],e),t[1]+=t[0]&255,t[1]=or(t[1],134775813)+1,t[2]=nr(t[2],t[1]>>>24),e};Ce.prototype.next=function(){let e=(this.keys[2]|2)>>>0;return or(e,e^1)>>8&255};function no(e){let t=new Ce(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}}s(no,"make_decrypter");function oo(e){let t=new Ce(e);return function(r,n,o=0){n||(n=Buffer.alloc(r.length));for(let a of r){let i=t.next();n[o++]=a^i,t.updateKeys(a)}return n}}s(oo,"make_encrypter");function so(e,t,r){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);let n=no(r),o=n(e.slice(0,12)),a=(t.flags&8)===8?t.timeHighByte:t.crc>>>24;if(o[11]!==a)throw to.WRONG_PASSWORD();return n(e.slice(12))}s(so,"decrypt");function io(e){Buffer.isBuffer(e)&&e.length>=12?Me.genSalt=function(){return e.slice(0,12)}:e==="node"?Me.genSalt=Ee.node:Me.genSalt=Ee}s(io,"_salter");function ao(e,t,r,n=!1){e==null&&(e=Buffer.alloc(0)),Buffer.isBuffer(e)||(e=Buffer.from(e.toString()));let o=oo(r),a=Me.genSalt();a[11]=t.crc>>>24&255,n&&(a[10]=t.crc>>>16&255);let i=Buffer.alloc(e.length+12);return o(a,i),o(e,i,12)}s(ao,"encrypt");sr.exports={decrypt:so,encrypt:ao,_salter:io}});var ar=W(xe=>{xe.Deflater=Qt();xe.Inflater=tr();xe.ZipCrypto=ir()});var Xe=W((ka,lr)=>{var w=le(),lo=Ye(),j=w.Constants,qe=ar();lr.exports=function(e,t){var r=new lo.EntryHeader,n=Buffer.alloc(0),o=Buffer.alloc(0),a=!1,i=null,c=Buffer.alloc(0),d=Buffer.alloc(0),m=!0;let y=e,T=typeof y.decoder=="object"?y.decoder:w.decoder;m=T.hasOwnProperty("efs")?T.efs:!1;function R(){return!t||!(t instanceof Uint8Array)?Buffer.alloc(0):(d=r.loadLocalHeaderFromBinary(t),t.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}s(R,"getCompressedDataFromZip");function _(l){let g=r.flags_desc||r.localHeader.flags_desc?r.crc:r.localHeader.crc;return w.crc32(l)===g}s(_,"crc32OK");function u(l,g,I){if(typeof g>"u"&&typeof l=="string"&&(I=l,l=void 0),a)return l&&g&&g(Buffer.alloc(0),w.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var A=R();if(A.length===0)return l&&g&&g(A),A;if(r.encrypted){if(typeof I!="string"&&!Buffer.isBuffer(I))throw w.Errors.INVALID_PASS_PARAM();A=qe.ZipCrypto.decrypt(A,r,I)}var S;switch(r.method){case w.Constants.STORED:if(S=Buffer.alloc(A.length),A.copy(S),_(S))return l&&g&&g(S),S;throw l&&g&&g(S,w.Errors.BAD_CRC()),w.Errors.BAD_CRC();case w.Constants.DEFLATED:var C=new qe.Inflater(A,r.size);if(l)C.inflateAsync(function(x){g&&(_(x)?g(x):g(x,w.Errors.BAD_CRC()))});else{if(S=C.inflate(),!_(S))throw w.Errors.BAD_CRC(`"${T.decode(n)}"`);return S}break;default:throw l&&g&&g(Buffer.alloc(0),w.Errors.UNKNOWN_METHOD()),w.Errors.UNKNOWN_METHOD()}}s(u,"decompress");function f(l,g){if((!i||!i.length)&&Buffer.isBuffer(t))return l&&g&&g(R()),R();if(i.length&&!a){var I;switch(r.method){case w.Constants.STORED:return r.compressedSize=r.size,I=Buffer.alloc(i.length),i.copy(I),l&&g&&g(I),I;default:case w.Constants.DEFLATED:var A=new qe.Deflater(i);if(l)A.deflateAsync(function(C){I=Buffer.alloc(C.length),r.compressedSize=C.length,C.copy(I),g&&g(I)});else{var S=A.deflate();return r.compressedSize=S.length,S}A=null;break}}else if(l&&g)g(Buffer.alloc(0));else return Buffer.alloc(0)}s(f,"compress");function p(l,g){return w.readBigUInt64LE(l,g)}s(p,"readUInt64LE");function h(l){try{for(var g=0,I,A,S;g+4<l.length;)I=l.readUInt16LE(g),g+=2,A=l.readUInt16LE(g),g+=2,S=l.slice(g,g+A),g+=A,j.ID_ZIP64===I&&E(S)}catch{throw w.Errors.EXTRA_FIELD_PARSE_ERROR()}}s(h,"parseExtra");function E(l){var g,I,A,S;l.length>=j.EF_ZIP64_SCOMP&&(g=p(l,j.EF_ZIP64_SUNCOMP),r.size===j.EF_ZIP64_OR_32&&(r.size=g)),l.length>=j.EF_ZIP64_RHO&&(I=p(l,j.EF_ZIP64_SCOMP),r.compressedSize===j.EF_ZIP64_OR_32&&(r.compressedSize=I)),l.length>=j.EF_ZIP64_DSN&&(A=p(l,j.EF_ZIP64_RHO),r.offset===j.EF_ZIP64_OR_32&&(r.offset=A)),l.length>=j.EF_ZIP64_DSN+4&&(S=l.readUInt32LE(j.EF_ZIP64_DSN),r.diskNumStart===j.EF_ZIP64_OR_16&&(r.diskNumStart=S))}return s(E,"parseZip64ExtendedInformation"),{get entryName(){return T.decode(n)},get rawEntryName(){return n},set entryName(l){n=w.toBuffer(l,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 c},set extra(l){c=l,r.extraLength=l.length,h(l)},get comment(){return T.decode(o)},set comment(l){if(o=w.toBuffer(l,T.encode),r.commentLength=o.length,o.length>65535)throw w.Errors.COMMENT_TOO_LONG()},get name(){let l=T.decode(n);return a?l.replace(/[/\\]$/,"").split("/").pop():l.split("/").pop()},get isDirectory(){return a},getCompressedData:s(function(){return f(!1,null)},"getCompressedData"),getCompressedDataAsync:s(function(l){f(!0,l)},"getCompressedDataAsync"),setData:s(function(l){i=w.toBuffer(l,w.decoder.encode),!a&&i.length?(r.size=i.length,r.method=w.Constants.DEFLATED,r.crc=w.crc32(l),r.changed=!0):r.method=w.Constants.STORED},"setData"),getData:s(function(l){return r.changed?i:u(!1,null,l)},"getData"),getDataAsync:s(function(l,g){r.changed?l(i):u(!0,l,g)},"getDataAsync"),set attr(l){r.attr=l},get attr(){return r.attr},set header(l){r.loadFromBinary(l)},get header(){return r},packCentralHeader:s(function(){r.flags_efs=this.efs,r.extraLength=c.length;var l=r.centralHeaderToBinary(),g=w.Constants.CENHDR;return n.copy(l,g),g+=n.length,c.copy(l,g),g+=r.extraLength,o.copy(l,g),l},"packCentralHeader"),packLocalHeader:s(function(){let l=0;r.flags_efs=this.efs,r.extraLocalLength=d.length;let g=r.localHeaderToBinary(),I=Buffer.alloc(g.length+n.length+r.extraLocalLength);return g.copy(I,l),l+=g.length,n.copy(I,l),l+=n.length,d.copy(I,l),l+=d.length,I},"packLocalHeader"),toJSON:s(function(){let l=s(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:l(t),data:l(i)}},"toJSON"),toString:s(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var ur=W((Ha,dr)=>{var cr=Xe(),co=Ye(),z=le();dr.exports=function(e,t){var r=[],n=Object.create(null),o=Buffer.alloc(0),a=new co.MainHeader,i=!1,c=null;let d=new Set,m=t,{noSort:y,decoder:T}=m;e?u(m.readEntries):i=!0;function R(){let p=new Set;for(let h of Object.keys(n)){let E=h.split("/");if(E.pop(),!!E.length)for(let l=0;l<E.length;l++){let g=E.slice(0,l+1).join("/")+"/";p.add(g)}}for(let h of p)if(!(h in n)){let E=new cr(m);E.entryName=h,E.attr=16,E.temporary=!0,r.push(E),n[E.entryName]=E,d.add(E)}}s(R,"makeTemporaryFolders");function _(){if(i=!0,n=Object.create(null),a.diskEntries>(e.length-a.offset)/z.Constants.CENHDR)throw z.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(a.diskEntries);for(var p=a.offset,h=0;h<r.length;h++){var E=p,l=new cr(m,e);l.header=e.slice(E,E+=z.Constants.CENHDR),l.entryName=e.slice(E,E+=l.header.fileNameLength),l.header.extraLength&&(l.extra=e.slice(E,E+=l.header.extraLength)),l.header.commentLength&&(l.comment=e.slice(E,E+l.header.commentLength)),p+=l.header.centralHeaderSize,r[h]=l,n[l.entryName]=l}d.clear(),R()}s(_,"readEntries");function u(p){var h=e.length-z.Constants.ENDHDR,E=Math.max(0,h-65535),l=E,g=e.length,I=-1,A=0;for(typeof m.trailingSpace=="boolean"&&m.trailingSpace&&(E=0),h;h>=l;h--)if(e[h]===80){if(e.readUInt32LE(h)===z.Constants.ENDSIG){I=h,A=h,g=h+z.Constants.ENDHDR,l=h-z.Constants.END64HDR;continue}if(e.readUInt32LE(h)===z.Constants.END64SIG){l=E;continue}if(e.readUInt32LE(h)===z.Constants.ZIP64SIG){I=h,g=h+z.readBigUInt64LE(e,h+z.Constants.ZIP64SIZE)+z.Constants.ZIP64LEAD;break}}if(I==-1)throw z.Errors.INVALID_FORMAT();a.loadFromBinary(e.slice(I,g)),a.commentLength&&(o=e.slice(A+z.Constants.ENDHDR)),p&&_()}s(u,"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 s(f,"sortEntries"),{get entries(){return i||_(),r.filter(p=>!d.has(p))},get comment(){return T.decode(o)},set comment(p){o=z.toBuffer(p,T.encode),a.commentLength=o.length},getEntryCount:s(function(){return i?r.length:a.diskEntries},"getEntryCount"),forEach:s(function(p){this.entries.forEach(p)},"forEach"),getEntry:s(function(p){return i||_(),n[p]||null},"getEntry"),setEntry:s(function(p){i||_(),r.push(p),n[p.entryName]=p,a.totalEntries=r.length},"setEntry"),deleteFile:s(function(p,h=!0){i||_();let E=n[p];this.getEntryChildren(E,h).map(g=>g.entryName).forEach(this.deleteEntry)},"deleteFile"),deleteEntry:s(function(p){i||_();let h=n[p],E=r.indexOf(h);E>=0&&(r.splice(E,1),delete n[p],a.totalEntries=r.length)},"deleteEntry"),getEntryChildren:s(function(p,h=!0){if(i||_(),typeof p=="object")if(p.isDirectory&&h){let E=[],l=p.entryName;for(let g of r)g.entryName.startsWith(l)&&E.push(g);return E}else return[p];return[]},"getEntryChildren"),getChildCount:s(function(p){if(p&&p.isDirectory){let h=this.getEntryChildren(p);return h.includes(p)?h.length-1:h.length}return 0},"getChildCount"),compressToBuffer:s(function(){i||_(),f();let p=[],h=[],E=0,l=0;a.size=0,a.offset=0;let g=0;for(let S of this.entries){let C=S.getCompressedData();S.header.offset=l;let x=S.packLocalHeader(),v=x.length+C.length;l+=v,p.push(x),p.push(C);let N=S.packCentralHeader();h.push(N),a.size+=N.length,E+=v+N.length,g++}E+=a.mainHeaderSize,a.offset=l,a.totalEntries=g,l=0;let I=Buffer.alloc(E);for(let S of p)S.copy(I,l),l+=S.length;for(let S of h)S.copy(I,l),l+=S.length;let A=a.toBinary();return o&&o.copy(A,A.length-o.length),A.copy(I,l),e=I,i=!1,I},"compressToBuffer"),toAsyncBuffer:s(function(p,h,E,l){try{i||_(),f();let g=[],I=[],A=0,S=0,C=0;a.size=0,a.offset=0;let x=s(function(v){if(v.length>0){let N=v.shift(),G=N.entryName+N.extra.toString();E&&E(G),N.getCompressedDataAsync(function($){l&&l(G),N.header.offset=S;let te=N.packLocalHeader(),Ie=te.length+$.length;S+=Ie,g.push(te),g.push($);let ge=N.packCentralHeader();I.push(ge),a.size+=ge.length,A+=Ie+ge.length,C++,x(v)})}else{A+=a.mainHeaderSize,a.offset=S,a.totalEntries=C,S=0;let N=Buffer.alloc(A);g.forEach(function($){$.copy(N,S),S+=$.length}),I.forEach(function($){$.copy(N,S),S+=$.length});let G=a.toBinary();o&&o.copy(G,G.length-o.length),G.copy(N,S),e=N,i=!1,p(N)}},"compress2Buffer");x(Array.from(this.entries))}catch(g){h(g)}},"toAsyncBuffer")}}});var mr=W((Wa,fr)=>{var O=le(),L=require("path"),uo=Xe(),po=ur(),re=s((...e)=>O.findLast(e,t=>typeof t=="boolean"),"get_Bool"),pr=s((...e)=>O.findLast(e,t=>typeof t=="string"),"get_Str"),fo=s((...e)=>O.findLast(e,t=>typeof t=="function"),"get_Fun"),mo={noSort:!1,readEntries:!1,method:O.Constants.NONE,fs:null};fr.exports=function(e,t){let r=null,n=Object.assign(Object.create(null),mo);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=O.Constants.BUFFER,e=void 0)),Object.assign(n,t);let o=new O(n),a=s(u=>{u.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=O.decoder),e&&typeof e=="string")if(o.fs.existsSync(e))n.method=O.Constants.FILE,n.filename=e,r=o.fs.readFileSync(e);else throw O.Errors.INVALID_FILENAME();let i=new po(r,n),{canonical:c,sanitize:d,zipnamefix:m}=O;function y(u){if(u&&i){var f;if(typeof u=="string"&&(f=i.getEntry(L.posix.normalize(u))),typeof u=="object"&&typeof u.entryName<"u"&&typeof u.header<"u"&&(f=i.getEntry(u.entryName)),f)return f}return null}s(y,"getEntry");function T(u){let{join:f,normalize:p,sep:h}=L.posix;return f(L.isAbsolute(u)?"/":".",p(h+u.split("\\").join(h)+h))}s(T,"fixPath");function R(u){return u instanceof RegExp?(function(f){return function(p){return f.test(p)}})(u):typeof u!="function"?()=>!0:u}s(R,"filenameFilter");let _=s((u,f)=>{let p=f.slice(-1);return p=p===o.sep?o.sep:"",L.relative(u,f)+p},"relativePath");return{readFile:s(function(u,f){var p=y(u);return p&&p.getData(f)||null},"readFile"),childCount:s(function(u){let f=y(u);if(f)return i.getChildCount(f)},"childCount"),readFileAsync:s(function(u,f){var p=y(u);p?p.getDataAsync(f):f(null,"getEntry failed for:"+u)},"readFileAsync"),readAsText:s(function(u,f){var p=y(u);if(p){var h=p.getData();if(h&&h.length)return h.toString(f||"utf8")}return""},"readAsText"),readAsTextAsync:s(function(u,f,p){var h=y(u);h?h.getDataAsync(function(E,l){if(l){f(E,l);return}E&&E.length?f(E.toString(p||"utf8")):f("")}):f("")},"readAsTextAsync"),deleteFile:s(function(u,f=!0){var p=y(u);p&&i.deleteFile(p.entryName,f)},"deleteFile"),deleteEntry:s(function(u){var f=y(u);f&&i.deleteEntry(f.entryName)},"deleteEntry"),addZipComment:s(function(u){i.comment=u},"addZipComment"),getZipComment:s(function(){return i.comment||""},"getZipComment"),addZipEntryComment:s(function(u,f){var p=y(u);p&&(p.comment=f)},"addZipEntryComment"),getZipEntryComment:s(function(u){var f=y(u);return f&&f.comment||""},"getZipEntryComment"),updateFile:s(function(u,f){var p=y(u);p&&p.setData(f)},"updateFile"),addLocalFile:s(function(u,f,p,h){if(o.fs.existsSync(u)){f=f?T(f):"";let E=L.win32.basename(L.win32.normalize(u));f+=p||E;let l=o.fs.statSync(u),g=l.isFile()?o.fs.readFileSync(u):Buffer.alloc(0);l.isDirectory()&&(f+=o.sep),this.addFile(f,g,h,l)}else throw O.Errors.FILE_NOT_FOUND(u)},"addLocalFile"),addLocalFileAsync:s(function(u,f){u=typeof u=="object"?u:{localPath:u};let p=L.resolve(u.localPath),{comment:h}=u,{zipPath:E,zipName:l}=u,g=this;o.fs.stat(p,function(I,A){if(I)return f(I,!1);E=E?T(E):"";let S=L.win32.basename(L.win32.normalize(p));if(E+=l||S,A.isFile())o.fs.readFile(p,function(C,x){return C?f(C,!1):(g.addFile(E,x,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:s(function(u,f,p){if(p=R(p),f=f?T(f):"",u=L.normalize(u),o.fs.existsSync(u)){let h=o.findFiles(u),E=this;if(h.length)for(let l of h){let g=L.join(f,_(u,l));p(g)&&E.addLocalFile(l,L.dirname(g))}}else throw O.Errors.FILE_NOT_FOUND(u)},"addLocalFolder"),addLocalFolderAsync:s(function(u,f,p,h){h=R(h),p=p?T(p):"",u=L.normalize(u);var E=this;o.fs.open(u,"r",function(l){if(l&&l.code==="ENOENT")f(void 0,O.Errors.FILE_NOT_FOUND(u));else if(l)f(void 0,l);else{var g=o.findFiles(u),I=-1,A=s(function(){if(I+=1,I<g.length){var S=g[I],C=_(u,S).split("\\").join("/");C=C.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),h(C)?o.fs.stat(S,function(x,v){x&&f(void 0,x),v.isFile()?o.fs.readFile(S,function(N,G){N?f(void 0,N):(E.addFile(p+C,G,"",v),A())}):(E.addFile(p+C+"/",Buffer.alloc(0),"",v),A())}):process.nextTick(()=>{A()})}else f(!0,void 0)},"next");A()}})},"addLocalFolderAsync"),addLocalFolderAsync2:s(function(u,f){let p=this;u=typeof u=="object"?u:{localPath:u};let h=L.resolve(T(u.localPath)),{zipPath:E,filter:l,namefix:g}=u;l instanceof RegExp?l=(function(S){return function(C){return S.test(C)}})(l):typeof l!="function"&&(l=s(function(){return!0},"filter")),E=E?T(E):"",g==="latin1"&&(g=s(S=>S.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),"namefix")),typeof g!="function"&&(g=s(S=>S,"namefix"));let I=s(S=>L.join(E,g(_(h,S))),"relPathFix"),A=s(S=>L.win32.basename(L.win32.normalize(g(S))),"fileNameFix");o.fs.open(h,"r",function(S){S&&S.code==="ENOENT"?f(void 0,O.Errors.FILE_NOT_FOUND(h)):S?f(void 0,S):o.findFilesAsync(h,function(C,x){if(C)return f(C);x=x.filter(v=>l(I(v))),x.length||f(void 0,!1),setImmediate(x.reverse().reduce(function(v,N){return function(G,$){if(G||$===!1)return setImmediate(v,G,!1);p.addLocalFileAsync({localPath:N,zipPath:L.dirname(I(N)),zipName:A(N)},v)}},f))})})},"addLocalFolderAsync2"),addLocalFolderPromise:s(function(u,f){return new Promise((p,h)=>{this.addLocalFolderAsync2(Object.assign({localPath:u},f),(E,l)=>{E&&h(E),l&&p(this)})})},"addLocalFolderPromise"),addFile:s(function(u,f,p,h){u=m(u);let E=y(u),l=E!=null;l||(E=new uo(n),E.entryName=u),E.comment=p||"";let g=typeof h=="object"&&h instanceof o.fs.Stats;g&&(E.header.time=h.mtime);var I=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,I=(I|A<<16)>>>0,E.attr=I,E.setData(f),l||i.setEntry(E),E},"addFile"),getEntries:s(function(u){return i.password=u,i?i.entries:[]},"getEntries"),getEntry:s(function(u){return y(u)},"getEntry"),getEntryCount:s(function(){return i.getEntryCount()},"getEntryCount"),forEach:s(function(u){return i.forEach(u)},"forEach"),extractEntryTo:s(function(u,f,p,h,E,l){h=re(!1,h),E=re(!1,E),p=re(!0,p),l=pr(E,l);var g=y(u);if(!g)throw O.Errors.NO_ENTRY();var I=c(g.entryName),A=d(f,l&&!g.isDirectory?c(l):p?I:L.basename(I));if(g.isDirectory){var S=i.getEntryChildren(g);return S.forEach(function(v){if(v.isDirectory)return;var N=v.getData();if(!N)throw O.Errors.CANT_EXTRACT_FILE();var G=c(p?v.entryName:v.entryName.substring(g.entryName.length)),$=d(f,G);let te=E?v.header.fileAttr:void 0;o.writeFileTo($,N,h,te)}),!0}var C=g.getData(i.password);if(!C)throw O.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(A)&&!h)throw O.Errors.CANT_OVERRIDE();let x=E?u.header.fileAttr:void 0;return o.writeFileTo(A,C,h,x),!0},"extractEntryTo"),test:s(function(u){if(!i)return!1;for(var f of i.entries)try{if(f.isDirectory)continue;var p=f.getData(u);if(!p)return!1}catch{return!1}return!0},"test"),extractAllTo:s(function(u,f,p,h){if(p=re(!1,p),h=pr(p,h),f=re(!1,f),!i)throw O.Errors.NO_ZIP();let E=[];i.entries.forEach(function(l){var g=d(u,c(l.entryName));if(l.isDirectory){o.makeDir(g),p&&E.push({path:g,attr:l.header.fileAttr});return}var I=l.getData(h);if(!I)throw O.Errors.CANT_EXTRACT_FILE();let A=p?l.header.fileAttr:void 0;o.writeFileTo(g,I,f,A);try{o.fs.utimesSync(g,l.header.time,l.header.time)}catch{}}),a(E)},"extractAllTo"),extractAllToAsync:s(function(u,f,p,h){if(h=fo(f,p,h),p=re(!1,p),f=re(!1,f),!h)return new Promise((C,x)=>{this.extractAllToAsync(u,f,p,function(v){v?x(v):C(this)})});if(!i){h(O.Errors.NO_ZIP());return}u=L.resolve(u);let E=s(C=>d(u,L.normalize(c(C.entryName))),"getPath"),l=s((C,x)=>new Error(C+': "'+x+'"'),"getError"),g=[],I=[];i.entries.forEach(C=>{C.isDirectory?g.push(C):I.push(C)});let A=[];for(let C of g){let x=E(C),v=p?C.header.fileAttr:void 0;try{o.makeDir(x)}catch{h(l("Unable to create folder",x));continue}v&&A.push({path:x,attr:v});try{o.fs.utimesSync(x,C.header.time,C.header.time)}catch{}}let S=s(C=>{if(!C)try{a(A)}catch(x){return h(l("Unable to set folder permissions",x.path||""))}h(C)},"done");I.reverse().reduce(function(C,x){return function(v){if(v)C(v);else{let N=L.normalize(c(x.entryName)),G=d(u,N);x.getDataAsync(function($,te){if(te)C(te);else if(!$)C(O.Errors.CANT_EXTRACT_FILE());else{let Ie=p?x.header.fileAttr:void 0;o.writeFileToAsync(G,$,f,Ie,function(ge){if(!ge)return C(l("Unable to write file",G));o.fs.utimes(G,x.header.time,x.header.time,function(){C()})})}})}}},S)()},"extractAllToAsync"),writeZip:s(function(u,f){if(arguments.length===1&&typeof u=="function"&&(f=u,u=""),!u&&n.filename&&(u=n.filename),!!u){var p=i.compressToBuffer();if(p){var h=o.writeFileTo(u,p,!0);typeof f=="function"&&f(h?null:new Error("failed"),"")}}},"writeZip"),writeZipPromise:s(function(u,f){let{overwrite:p,perm:h}=Object.assign({overwrite:!0},f);return new Promise((E,l)=>{!u&&n.filename&&(u=n.filename),u||l("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(g=>{let I=s(A=>A?E(A):l("ADM-ZIP: Wasn't able to write zip file"),"ret");o.writeFileToAsync(u,g,p,h,I)},l)})},"writeZipPromise"),toBufferPromise:s(function(){return new Promise((u,f)=>{i.toAsyncBuffer(u,f)})},"toBufferPromise"),toBuffer:s(function(u,f,p,h){return typeof u=="function"?(i.toAsyncBuffer(u,f,p,h),null):i.compressToBuffer()},"toBuffer")}}});var Ps={};Cn(Ps,{TestRunMonitor:()=>ze});module.exports=xn(Ps);var Ve=s(e=>new Promise(t=>setTimeout(t,e)),"awaitSleep");function Rt(e=5,t="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"){let r="";for(let n=e;n>0;--n)r+=t[Math.floor(Math.random()*t.length)]??"";return r}s(Rt,"randomString");var ea=require("@playwright/test");var Si=require("@playwright/test");var yi=require("@playwright/test");var fi=require("@playwright/test");var ji=require("@playwright/test");var Fi={openai_gpt_4_1:{model:"gpt-4.1-2025-04-14",type:"openai"},openai_gpt_4_1_mini:{model:"gpt-4.1-mini-2025-04-14",type:"openai"},openai_gpt_4_1_nano:{model:"gpt-4.1-nano-2025-04-14",type:"openai"},gemini_2_0_flash:{model:"gemini-2.0-flash",type:"gemini"},gemini_2_5_pro_exp:{model:"gemini-2.5-pro-exp-03-25",type:"gemini"},gemini_2_5_flash:{model:"gemini-2.5-flash",type:"gemini"},gemini_2_5_pro_preview_05_06:{model:"gemini-2.5-pro-preview-05-06",type:"gemini"},claude_sonnet_4:{model:"claude-sonnet-4@20250514",type:"anthropic-vertexai"},claude_sonnet_4_6:{model:"claude-sonnet-4-6",type:"anthropic-vertexai"},claude_sonnet_5:{model:"claude-sonnet-5",type:"anthropic-vertexai"},claude_opus_4_8:{model:"claude-opus-4-8",type:"anthropic-vertexai"},gemini_2_5_flash_lite:{model:"gemini-2.5-flash-lite",type:"gemini"},gemini_3_5_flash:{model:"gemini-3.5-flash",type:"gemini"},gemini_3_1_flash_lite:{model:"gemini-3.1-flash-lite",type:"gemini"}};var wt=se(je());wt.default.config({path:[`${__dirname}/.env`,`${__dirname}/../../.env`]});var Vn="claude_4",Kn={gemini20flash:{name:"google-vertexai/gemini-2.0-flash",inputTokenLimit:8e5,provider:"gemini",temperature:0},gpt41:{name:"openai/gpt-4.1",inputTokenLimit:8e5,provider:"openai",temperature:0},gemini25flash:{name:"google-vertexai/gemini-2.5-flash",inputTokenLimit:8e5,provider:"gemini",temperature:.7},gemini25flash_lite:{name:"google-vertexai/gemini-2.5-flash-lite",inputTokenLimit:8e5,provider:"gemini",temperature:0},gpt4onano:{name:"openai/gpt-4o-nano",inputTokenLimit:8e5,provider:"openai",temperature:0},gpt41nano:{name:"openai/gpt-4.1-nano",inputTokenLimit:8e5,provider:"openai",temperature:0},gpt41mini:{name:"openai/gpt-4.1-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},o3mini:{name:"openai/o3-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},o4mini:{name:"openai/o4-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},gemini25pro:{name:"google-vertexai/gemini-2.5-pro-preview-05-06",inputTokenLimit:8e5,provider:"gemini",temperature:0},claude37sonnet:{name:"google-vertexai/claude-3-7-sonnet@20250219",inputTokenLimit:15e4,provider:"anthropic",temperature:0},claude4sonnet:{name:"google-vertexai/claude-sonnet-4@20250514",inputTokenLimit:15e4,provider:"anthropic",temperature:1},claudeSonnet46:{name:"google-vertexai/claude-sonnet-4-6",inputTokenLimit:15e4,provider:"anthropic",temperature:1,location:"global"},claudeSonnet5:{name:"google-vertexai/claude-sonnet-5",inputTokenLimit:15e4,provider:"anthropic",temperature:1,location:"global"},claudeOpus48:{name:"google-vertexai/claude-opus-4-8",inputTokenLimit:15e4,provider:"anthropic",temperature:1,location:"global"},gemini35flash:{name:"google-vertexai/gemini-3.5-flash",inputTokenLimit:8e5,provider:"gemini",temperature:0,location:"global"},gemini31flashLite:{name:"google-vertexai/gemini-3.1-flash-lite",inputTokenLimit:8e5,provider:"gemini",temperature:0,location:"global"},gpt4omini:{name:"openai/gpt-4o-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},gpt5mini:{name:"openai/gpt-5-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},gpt5nano:{name:"openai/gpt-5-nano",inputTokenLimit:8e5,provider:"openai",temperature:0}},jn=s(()=>({nodeEnv:process.env.NODE_ENV??"production",selectedModel:{name:Vn},models:Kn,langsmith:{enabled:process.env.LANGSMITH_TRACING==="true",endpoint:process.env.LANGSMITH_ENDPOINT??"",apiKey:process.env.LANGSMITH_API_KEY??"",project:process.env.LANGSMITH_PROJECT??""}}),"make"),U=jn(),zi={claude_4:U.models.claude4sonnet,"claude_3.7":U.models.claude37sonnet,claude_sonnet_4_6:U.models.claudeSonnet46,claude_sonnet_5:U.models.claudeSonnet5,claude_opus_4_8:U.models.claudeOpus48,"gemini_2.5_pro":U.models.gemini25pro,"gemini_2.0_flash":U.models.gemini20flash,"gemini_2.5_flash_lite":U.models.gemini25flash_lite,"gemini_2.5_flash":U.models.gemini25flash,"gemini_3.5_flash":U.models.gemini35flash,"gemini_3.1_flash_lite":U.models.gemini31flashLite,gpt_4o_mini:U.models.gpt4omini,gpt_4o_nano:U.models.gpt4onano,gpt_41_nano:U.models.gpt41nano,gpt_5_mini:U.models.gpt5mini,gpt_5_nano:U.models.gpt5nano,gpt_41_mini:U.models.gpt41mini,gpt_41:U.models.gpt41,o4_mini:U.models.o4mini,o3_mini:U.models.o3mini};var gn=require("child_process"),Se=require("crypto"),P=require("fs"),hn=require("fs/promises"),yn=require("stream/promises"),En=require("http"),Tn=se(require("net")),_n=require("os"),K=require("path");function Zn(e){if(e)return{...e,...e.tests?{tests:e.tests.map(t=>{let{errorMessage:r,...n}=t;return n})}:{}}}s(Zn,"projectReportStatsForTelemetry");function Dt(e,t,r){e.emit({outcome:t,stats:Zn(r)})}s(Dt,"emitReportProcessingStatsTelemetry");var Lt=["script","template"],Ot='<script id="playwrightReportBase64" type="application/zip">',Pt="</script>";var Hr=require("htmlparser2"),Gr=se(mr()),H=require("node:fs"),ne=require("node:path"),Wr=require("node:os"),$r=require("node:crypto");var X=se(require("path")),tt=require("fs");var Qe=require("path"),ve=require("fs");function go(e,t,r=10){let n=e;for(let o=0;o<r;o++){let a=(0,Qe.join)(n,"package.json");if((0,ve.existsSync)(a))try{if(JSON.parse((0,ve.readFileSync)(a,"utf8")).name===t)return n}catch{}n=(0,Qe.join)(n,"..")}}s(go,"findRepositoryRoot");function gr(e,t=10){return go(e,"checksum-customer-engineering-workspace",t)}s(gr,"findCustomerEngineeringRoot");var rt=se(je());var V=s((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 hr(e){if(e===void 0||e.trim()==="")return 5e7;let t=Number(e);return!Number.isInteger(t)||t<0?5e7:t}s(hr,"resolveMaxRRwebBytes");var ho=__dirname,yr=X.join(__dirname,".."),Tr=(0,tt.existsSync)(yr)?yr:ho;(0,rt.config)({path:X.resolve(Tr,".env")});var Er=V(process.env.CHECKSUM_RUNTIME_DEV_MODE);function yo(){let e=__dirname;for(;!(0,tt.existsSync)(X.join(e,"package.json"));)e=X.join(e,"..");return e}s(yo,"findRoot");var Te=yo(),Eo=gr(Te,10);(0,rt.config)({path:[Tr,Eo].filter(e=>!!e).map(e=>X.resolve(e,".env")),override:!1});var et=V(process.env.CHECKSUM_RUNTIME_REPO_MODE),To=et?X.join(Te,"package","pw-report-template.html"):X.join(Te,"pw-report-template.html"),_o=V(process.env.CHECKSUM_DEBUG_ANALYTICS),bo=V(process.env.CHECKSUM_LOG_ANALYTICS_TO_CONSOLE),So=hr(process.env.CHECKSUM_RUNTIME_RRWEB_MAX_BYTES),Ne={isDevMode:Er,isRepoMode:et,CI:!!process.env.CI,checksumRootFolderBypass:et&&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??(Er?"url":"file"),url:process.env.CHECKSUM_RUNTIME_SCRIPT_URL,path:Te+"/checksumlib.js"},runtimeRoot:Te,playwrightReporter:{htmlReportTemplatePath:To},bypassProxyForLocalhost:V(process.env.CHECKSUM_RUNTIME_BYPASS_PROXY_FOR_LOCALHOST),useCLIDebug:V(process.env.CHECKSUM_RUNTIME_USE_CLI_DEBUG),useRemoteDebugging:{enabled:V(process.env.CHECKSUM_RUNTIME_USE_REMOTE_DEBUGGING),port:parseInt(process.env.CHECKSUM_AGENT_RUNTIME_REMOTE_DEBUGGING_PORT??"9500")},testRun:{timeMachine:{headless:!V(process.env.CHECKSUM_RUNTIME_SHOW_RUNTIME_TIME_MACHINE),recordRRwebEventsToFile:V(process.env.CHECKSUM_RUNTIME_RECORD_RRWEB_EVENTS_TO_FILE,{default:!0}),maxRRwebBytes:So},monitoring:{debugAnalytics:_o,logToConsole:bo,segment:{writeKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_WRITE_KEY??"TMuP8uorDj4QzJfNs0gEHDO7kHozVBOo",devWriteKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_DEV_WRITE_KEY??"gofHHwvdNHJNmb7KqACUmypZclVHEQ2l"}},autoRecovery:{verboseConsoleLog:V(process.env.CHECKSUM_RUNTIME_AUTO_RECOVERY_CONSOLE_LOG,{default:!1}),sessionTimeout:18e4},disableAutoRecovery:V(process.env.CHECKSUM_RUNTIME_DISABLE_AUTO_RECOVERY),disableHostReports:V(process.env.CHECKSUM_RUNTIME_DISABLE_HOST_REPORTS),disableTimeMachine:V(process.env.CHECKSUM_RUNTIME_DISABLE_TIME_MACHINE),disableRrwebRecording:V(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 Cl=require("@playwright/test/reporter");var ee=require("path");var nt=s((e,t,r)=>`v2:${Io(e)}::${JSON.stringify([...t,r])}`,"computeVariantKey"),Io=s(e=>(e??"").replace(/\\/g,"/"),"normalizeFilePath");var we=require("fs"),B=se(require("typescript"));var ot=5,ce={mint(){return Rt(ot)},parse(e){let t=ce.tryParse(e);if(t===null)throw new TypeError(`Not a usable checksumTestId: ${JSON.stringify(e)}`);return t},tryParse(e){return typeof e!="string"||e.trim()===""?null:e},isSame(e,t){return e===t}};var _r=" - ",br=/(?:\.fix)?\.checksum\.(?:(?:spec|test)\.(?:ts|js|tsx|jsx)|md)$/i,Ro=/^[A-Za-z0-9_-]+$/,Ao=new RegExp(`^[0-9A-Za-z]{${ot}}$`);function Sr(e){return Mo(e).id}s(Sr,"readTestIdFromFileName");function Mo(e){let t=Co(e);if(t===null)return{title:Ir(e),id:null};let r=t.lastIndexOf(_r);if(r===-1)return{title:t,id:Ao.test(t)?ce.tryParse(t):null};let n=t.slice(r+_r.length);return Ro.test(n)?{title:t.slice(0,r),id:ce.tryParse(n)}:{title:t,id:null}}s(Mo,"splitFileName");function Ir(e){let t=e.replace(/\\/g,"/");return t.slice(t.lastIndexOf("/")+1)}s(Ir,"basename");function Co(e){let t=Ir(e);return br.test(t)?t.replace(br,""):null}s(Co,"stemOf");var st=class{static{s(this,"FileContentReader")}read(t,r){if(!(!t||!(0,we.existsSync)(t)))try{let n=(0,we.readFileSync)(t,"utf-8"),o=B.createSourceFile(t,n,B.ScriptTarget.Latest,!0),a=new Map,i=s(c=>{if(B.isCallExpression(c)&&this.isTestCall(c.expression)){let d=c.arguments[0];if(d&&B.isCallExpression(d)&&B.isIdentifier(d.expression)&&d.expression.text==="defineChecksumTest"){let m=this.extractDefineChecksumTestArgs(d);m&&a.set(m.testTitle,m.checksumTestId)}}B.forEachChild(c,i)},"visit");return i(o),r&&a.has(r)?a.get(r):a.size>0?Array.from(a.values())[0]:void 0}catch{return}}isTestCall(t){return B.isIdentifier(t)&&t.text==="test"?!0:B.isPropertyAccessExpression(t)?B.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),i=ce.tryParse(this.extractStringLiteral(o));if(a&&i)return{testTitle:a,checksumTestId:i}}extractStringLiteral(t){if(B.isStringLiteral(t)||B.isNoSubstitutionTemplateLiteral(t))return t.text}},xo=new st;function Rr(e,t){return xo.read(e,t)??Sr(e)??void 0}s(Rr,"extractChecksumTestId");function De(e,t){return t.pwTestIdToChecksumTestId[e.playwrightTestId]||(e.filePath!==void 0?Rr(e.filePath,e.title):void 0)}s(De,"resolveChecksumTestId");var Ar=s((e,t)=>Object.values(t[e]??{}).some(r=>r.autoRecoveryMetadata?.data?.autoRecovered),"isAutoRecovered"),it=s(e=>typeof e=="number"&&!isNaN(e)?e:0,"getStat");function at(e,t,r){let n=[],o=0,a=0,i=it(t.expected)+it(t.flaky),c=it(t.unexpected);for(let d of e){let m=vo(d,r);n.push(m),m.recovered&&a++,m.bug&&(o++,m.outcome==="expected"||m.outcome==="flaky"?i--:m.outcome==="unexpected"&&c--)}return{passed:i,failed:c,bug:o,recovered:a,tests:n}}s(at,"computeReportStats");function vo(e,t){let r=De({playwrightTestId:e.playwrightTestId,filePath:e.filePath,title:e.title},t),n=No(e),o=wo(e.annotations),a=Ar(e.playwrightTestId,t.playwrightIdToMetadata),i=Do(r,e,t),c=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:nt(e.filePath,e.titlePath,e.title),...e.filePath!==void 0?{filePath:e.filePath}:{},...c!==void 0?{relativeFilePath:c}:{},...e.projectName?{project:e.projectName}:{},...e.errorMessage?{errorMessage:e.errorMessage}:{},...i!==void 0?{usingChecksumTestIdPlaceholder:i}:{}}}s(vo,"rowToTestWithMetadata");function Mr(e,t){let r=e.files,n=s(c=>{let m=De({playwrightTestId:c.testId,filePath:c.location.file,title:c.title},t)??`${c.location.file}::${c.title}`,y=nt(c.location.file,c.path??[],c.title);return`${m}::${c.projectName}::${y}`},"keyFor"),o=new Map;for(let c of r)for(let d of c.tests)o.set(n(d),d);let a=new Set(o.values()),i={total:0,expected:0,unexpected:0,flaky:0,skipped:0};for(let c of r){c.tests=c.tests.filter(d=>a.has(d));for(let d of c.tests)i.total++,d.outcome==="expected"?i.expected++:d.outcome==="unexpected"?i.unexpected++:d.outcome==="flaky"?i.flaky++:i.skipped++}e.files=r.filter(c=>c.tests.length>0),e.stats={...e.stats,...i}}s(Mr,"dedupeReportByChecksumTestId");var No=s(e=>e.tags.includes("bug")||e.annotations.some(t=>t.type==="bug")||e.title.includes("@bug"),"detectBug"),wo=s(e=>e.filter(t=>!!t?.type).map(t=>({type:t.type,description:t.description||""})),"normalizeAnnotations"),Do=s((e,t,r)=>{if(r.checksumTestIdToUsingPlaceholder)return r.pwTestIdToChecksumTestId[t.playwrightTestId]&&r.checksumTestIdToUsingPlaceholder[e]||!1},"computeUsingPlaceholder");var de=s(e=>e.replace(/\\/g,"/"),"toPosix"),Lo=s(e=>/^[A-Za-z]:/.test(e),"isWindowsAbsolute"),Cr=s((e,t,r,n)=>{if(!e)return;let o=de(r||t),a=de(e),i=de(n||(0,ee.dirname)(t)),c=(0,ee.isAbsolute)(a)||Lo(a)?a:de((0,ee.resolve)(i,a)),d=de((0,ee.relative)(o,c));return d&&!d.startsWith("..")?d:c},"toRelativeFilePath");var xr=require("node:util");var ue=8*1024,_e=`
4
- \u2026 [truncated]`,Oo=/[\u001b\u0080-\u009f]/g;function lt(e){let t=e.replaceAll("\0","");return Po((0,xr.stripVTControlCharacters)(t))}s(lt,"sanitizeTestErrorMessage");function Po(e){return e.replace(Oo,"")}s(Po,"removeResidualVTControls");function Le(e){let t=lt(e);if(Buffer.byteLength(t,"utf8")<=ue)return{value:t,truncated:!1};let r=ue-Buffer.byteLength(_e,"utf8"),n="",o=0;for(let a of t){let i=Buffer.byteLength(a,"utf8");if(o+i>r)break;n+=a,o+=i}return{value:n+_e,truncated:!0}}s(Le,"boundTestErrorMessage");var Nr=require("node:crypto");var Uo=new Set(["failed","timedOut","interrupted"]),ct=new WeakMap;function wr(){let e={messages:new Map,ambiguousKeys:new Set,truncatedCount:0,identityConflictCount:0};return ct.set(e,new Map),e}s(wr,"createErrorDetailIndex");function Dr(e,t){try{let r=Fo(e);if(!r||ko(r.tests))return!1;for(let n of r.tests){if(!pe(n))continue;let o=Fr(n.projectName),a=n.testId;if(o===void 0||!Oe(a))continue;let i=Bo(n);if(!i)continue;let c=Go(i);c.truncated&&(t.truncatedCount+=1),zo(t,Ur(r.fileId,o,a),c.value,$o(i))}return!0}catch{return!1}}s(Dr,"addTestFileErrorDetails");function Lr(e){return pe(e)&&Object.prototype.hasOwnProperty.call(e,"fileId")&&Object.prototype.hasOwnProperty.call(e,"tests")}s(Lr,"isTestFileErrorDetailCandidate");function Or(e,t,r,n){let o=Fr(r);if(!Oe(t)||o===void 0||!Oe(n))return;let a=Ur(t,o,n);if(!e.ambiguousKeys.has(a))return e.messages.get(a)}s(Or,"getTestErrorMessage");function Fo(e){if(!pe(e))return;let t=e.fileId,r=e.tests;if(!(!Oe(t)||!Array.isArray(r)))return{fileId:t,tests:r}}s(Fo,"parseTestFile");function ko(e){return e.length>0&&!e.some(pe)}s(ko,"hasOnlyMalformedTests");function Bo(e){let t=e.results;if(!Array.isArray(t))return;let r=t.at(-1);if(!pe(r))return;let n=r.status;if(typeof n!="string"||!Uo.has(n))return;let o=r.errors;if(Array.isArray(o))for(let a of o){let i=Ho(a);if(i)return i}}s(Bo,"extractFinalErrorDetail");function Ho(e){if(typeof e=="string"){let n=Pr(e);return n?{message:n}:void 0}if(!pe(e))return;let t=vr(e.message,e.value),r=vr(e.codeframe,e.snippet);return t?!r||t.includes(r)?{message:t}:{message:t,frame:r}:r?{frame:r}:void 0}s(Ho,"normalizeError");function Go(e){let{message:t,frame:r}=e;if(!t)return Le(r??"");if(!r)return Le(t);let n=Buffer.byteLength(t,"utf8");if(n>ue)return Le(t);let o=`
3
+ `),a=a.replace(/\\r/g,"\r")),t[o]=a}return t}s(Un,"parse");function Fn(e){e=e||{};let t=Nt(e);e.path=t;let r=k.configDotenv(e);if(!r.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=vt(e).split(","),o=n.length,a;for(let i=0;i<o;i++)try{let c=n[i].trim(),d=Bn(r,c);a=k.decrypt(d.ciphertext,d.key);break}catch(c){if(i+1>=o)throw c}return k.parse(a)}s(Fn,"_parseVault");function kn(e){console.error(`\u26A0 ${e}`)}s(kn,"_warn");function ye(e){console.log(`\u2506 ${e}`)}s(ye,"_debug");function xt(e){console.log(`\u25C7 ${e}`)}s(xt,"_log");function vt(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:""}s(vt,"_dotenvKey");function Bn(e,t){let r;try{r=new URL(t)}catch(c){if(c.code==="ERR_INVALID_URL"){let d=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 d.code="INVALID_DOTENV_KEY",d}throw c}let n=r.password;if(!n){let c=new Error("INVALID_DOTENV_KEY: Missing key part");throw c.code="INVALID_DOTENV_KEY",c}let o=r.searchParams.get("environment");if(!o){let c=new Error("INVALID_DOTENV_KEY: Missing environment part");throw c.code="INVALID_DOTENV_KEY",c}let a=`DOTENV_VAULT_${o.toUpperCase()}`,i=e.parsed[a];if(!i){let c=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw c.code="NOT_FOUND_DOTENV_ENVIRONMENT",c}return{ciphertext:i,key:n}}s(Bn,"_instructions");function Nt(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)Ke.existsSync(r)&&(t=r.endsWith(".vault")?r:`${r}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=Re.resolve(process.cwd(),".env.vault");return Ke.existsSync(t)?t:null}s(Nt,"_vaultPath");function Ct(e){return e[0]==="~"?Re.join(Nn.homedir(),e.slice(1)):e}s(Ct,"_resolveHome");function Hn(e){let t=ie(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),r=ie(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!r)&&xt("loading env from encrypted .env.vault");let n=k._parseVault(e),o=process.env;return e&&e.processEnv!=null&&(o=e.processEnv),k.populate(o,n,e),{parsed:n}}s(Hn,"_configVault");function Gn(e){let t=Re.resolve(process.cwd(),".env"),r="utf8",n=process.env;e&&e.processEnv!=null&&(n=e.processEnv);let o=ie(n.DOTENV_CONFIG_DEBUG||e&&e.debug),a=ie(n.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?r=e.encoding:o&&ye("no encoding is specified (UTF-8 is used by default)");let i=[t];if(e&&e.path)if(!Array.isArray(e.path))i=[Ct(e.path)];else{i=[];for(let y of e.path)i.push(Ct(y))}let c,d={};for(let y of i)try{let T=k.parse(Ke.readFileSync(y,{encoding:r}));k.populate(d,T,e)}catch(T){o&&ye(`failed to load ${y} ${T.message}`),c=T}let m=k.populate(n,d,e);if(o=ie(n.DOTENV_CONFIG_DEBUG||o),a=ie(n.DOTENV_CONFIG_QUIET||a),o||!a){let y=Object.keys(m).length,T=[];for(let R of i)try{let _=Re.relative(process.cwd(),R);T.push(_)}catch(_){o&&ye(`failed to load ${R} ${_.message}`),c=_}xt(`injected env (${y}) from ${T.join(",")} ${Ln(`// tip: ${On()}`)}`)}return c?{parsed:d,error:c}:{parsed:d}}s(Gn,"configDotenv");function Wn(e){if(vt(e).length===0)return k.configDotenv(e);let t=Nt(e);return t?k._configVault(e):(kn(`you set DOTENV_KEY but you are missing a .env.vault file at ${t}`),k.configDotenv(e))}s(Wn,"config");function $n(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 i=wn.createDecipheriv("aes-256-gcm",r,o);return i.setAuthTag(a),`${i.update(n)}${i.final()}`}catch(i){let c=i instanceof RangeError,d=i.message==="Invalid key length",m=i.message==="Unsupported state or unable to authenticate data";if(c||d){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 i}}s($n,"decrypt");function zn(e,t,r={}){let n=!!(r&&r.debug),o=!!(r&&r.override),a={};if(typeof t!="object"){let i=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw i.code="OBJECT_REQUIRED",i}for(let i of Object.keys(t))Object.prototype.hasOwnProperty.call(e,i)?(o===!0&&(e[i]=t[i],a[i]=t[i]),n&&ye(o===!0?`"${i}" is already defined and WAS overwritten`:`"${i}" is already defined and was NOT overwritten`)):(e[i]=t[i],a[i]=t[i]);return a}s(zn,"populate");var k={configDotenv:Gn,_configVault:Hn,_parseVault:Fn,config:Wn,decrypt:$n,parse:Un,populate:zn};q.exports.configDotenv=k.configDotenv;q.exports._configVault=k._configVault;q.exports._parseVault=k._parseVault;q.exports.config=k.config;q.exports.decrypt=k.decrypt;q.exports.parse=k.parse;q.exports.populate=k.populate;q.exports=k});var Ze=W((ha,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 Me=W(kt=>{var Ft={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 Jn(e){return function(...t){return t.length&&(e=e.replace(/\{(\d)\}/g,(r,n)=>t[n]||"")),new Error("ADM-ZIP: "+e)}}s(Jn,"E");for(let e of Object.keys(Ft))kt[e]=Jn(Ft[e])});var $t=W((Ta,Wt)=>{var Yn=require("fs"),F=require("path"),Bt=Ze(),qn=Me(),Xn=typeof process=="object"&&process.platform==="win32",Ht=s(e=>typeof e=="object"&&e!==null,"is_Obj"),Gt=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 O(e){this.sep=F.sep,this.fs=Yn,Ht(e)&&Ht(e.fs)&&typeof e.fs.statSync=="function"&&(this.fs=e.fs)}s(O,"Utils");Wt.exports=O;O.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 i;try{i=t.fs.statSync(o)}catch(c){if(c.message&&c.message.startsWith("ENOENT"))t.fs.mkdirSync(o);else throw c}if(i&&i.isFile())throw qn.FILE_IN_THE_WAY(`"${o}"`)}})}s(r,"mkdirSync"),r(e)};O.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 i=F.dirname(e);o.fs.existsSync(i)||o.makeDir(i);var c;try{c=o.fs.openSync(e,"w",438)}catch{o.fs.chmodSync(e,438),c=o.fs.openSync(e,"w",438)}if(c)try{o.fs.writeSync(c,t,0,t.length,0)}finally{o.fs.closeSync(c)}return o.fs.chmodSync(e,n||438),!0};O.prototype.writeFileToAsync=function(e,t,r,n,o){typeof n=="function"&&(o=n,n=void 0);let a=this;a.fs.exists(e,function(i){if(i&&!r)return o(!1);a.fs.stat(e,function(c,d){if(i&&d&&d.isDirectory())return o(!1);var m=F.dirname(e);a.fs.exists(m,function(y){if(!y)try{a.makeDir(m)}catch{return o(!1)}let T=s(function(R){a.fs.write(R,t,0,t.length,0,function(_){a.fs.close(R,function(){if(_)return o(!1);a.fs.chmod(e,n||438,function(){o(!0)})})})},"writeToFd");a.fs.open(e,"w",438,function(R,_){R?a.fs.chmod(e,438,function(){a.fs.open(e,"w",438,function(u,f){if(u||!f)return o(!1);T(f)})}):_?T(_):o(!1)})})})})};O.prototype.findFiles=function(e){let t=this;function r(n,o,a,i){typeof o=="boolean"&&(a=o,o=void 0);let c=[];return t.fs.readdirSync(n).forEach(function(d){let m=F.join(n,d),y=t.fs.statSync(m);if((!o||o.test(m))&&c.push(F.normalize(m)+(y.isDirectory()?t.sep:"")),y.isDirectory()&&a){let T=t.fs.realpathSync(m);i.has(T)||(i.add(T),c=c.concat(r(m,o,a,i)))}}),c}return s(r,"findSync"),r(e,void 0,!0,new Set([t.fs.realpathSync(e)]))};O.prototype.findFilesAsync=function(e,t){let r=this,n=[],o=!1,a=s(function(c){o||(o=!0,t(c,c?void 0:n))},"finish"),i=s(function(c,d,m){r.fs.readdir(c,function(y,T){if(y)return m(y);let R=T.length;if(!R)return m();T.forEach(function(_){let u=F.join(c,_);r.fs.stat(u,function(f,p){if(f)return m(f);if(!p){--R||m();return}if(n.push(F.normalize(u)+(p.isDirectory()?r.sep:"")),!p.isDirectory()){--R||m();return}r.fs.realpath(u,function(h,E){if(h)return m(h);if(d.has(E)){--R||m();return}d.add(E),i(u,d,function(l){if(l)return m(l);--R||m()})})})})})},"walk");r.fs.realpath(e,function(c,d){if(c)return a(c);i(e,new Set([d]),a)})};O.prototype.getAttributes=function(){};O.prototype.setAttributes=function(){};O.crc32update=function(e,t){return Gt[(e^t)&255]^e>>>8};O.crc32=function(e){typeof e=="string"&&(e=Buffer.from(e,"utf8"));let t=e.length,r=-1;for(let n=0;n<t;)r=O.crc32update(r,e[n++]);return~r>>>0};O.methodToString=function(e){switch(e){case Bt.STORED:return"STORED ("+e+")";case Bt.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}};O.canonical=function(e){if(!e)return"";let t=F.posix.normalize("/"+e.split("\\").join("/"));return F.join(".",t)};O.zipnamefix=function(e){if(!e)return"";let t=F.posix.normalize("/"+e.split("\\").join("/"));return F.posix.join(".",t)};O.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]};O.sanitize=function(e,t){e=F.resolve(F.normalize(e));for(var r=t.split("/"),n=0,o=r.length;n<o;n++){var a=F.normalize(F.join(e,r.slice(n,o).join(F.sep)));if(a===e||a.startsWith(e+F.sep))return a}return F.normalize(F.join(e,F.basename(t)))};O.toBuffer=s(function(t,r){return Buffer.isBuffer(t)?t:t instanceof Uint8Array?Buffer.from(t):typeof t=="string"?r(t):Buffer.alloc(0)},"toBuffer");O.readBigUInt64LE=function(e,t){let r=e.readUInt32LE(t);return e.readUInt32LE(t+4)*4294967296+r};O.writeBigUInt64LE=function(e,t,r){let n=t>>>0,o=Math.floor(t/4294967296)>>>0;e.writeUInt32LE(n,r),e.writeUInt32LE(o,r+4)};O.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)};O.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};O.isWin=Xn;O.crcTable=Gt});var Vt=W((ba,zt)=>{var Qn=require("path");zt.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 s(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=Qn.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:s(function(){},"decodeAttributes"),encodeAttributes:s(function(){},"encodeAttributes"),toJSON:s(function(){return{path:r,isDirectory:n.directory,isReadOnly:n.readonly,isHidden:n.hidden,isExecutable:n.executable,mTime:n.mtime,aTime:n.atime}},"toJSON"),toString:s(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var jt=W((Ia,Kt)=>{Kt.exports={efs:!0,encode:s(e=>Buffer.from(e,"utf8"),"encode"),decode:s(e=>e.toString("utf8"),"decode")}});var le=W((Ma,ae)=>{ae.exports=$t();ae.exports.Constants=Ze();ae.exports.Errors=Me();ae.exports.FileAttr=Vt();ae.exports.decoder=jt()});var Jt=W((Aa,Zt)=>{var Q=le(),b=Q.Constants;Zt.exports=function(){var e=20,t=10,r=0,n=0,o=0,a=0,i=0,c=0,d=0,m=0,y=0,T=0,R=0,_=0,u=0;e|=Q.isWin?2560:768,r|=b.FLG_EFS;let f={extraLen:0},p=s(l=>Math.max(0,l)>>>0,"uint32"),h=s(l=>Math.max(0,l)&65535,"uint16"),E=s(l=>Math.max(0,l)&255,"uint8");return o=Q.fromDate2DOS(new Date),{get made(){return e},set made(l){e=l},get version(){return t},set version(l){t=l},get flags(){return r},set flags(l){r=l},get flags_efs(){return(r&b.FLG_EFS)>0},set flags_efs(l){l?r|=b.FLG_EFS:r&=~b.FLG_EFS},get flags_desc(){return(r&b.FLG_DESC)>0},set flags_desc(l){l?r|=b.FLG_DESC:r&=~b.FLG_DESC},get method(){return n},set method(l){switch(l){case b.STORED:this.version=10;break;case b.DEFLATED:default:this.version=20}n=l},get time(){return Q.fromDOS2Date(this.timeval)},set time(l){l=new Date(l),this.timeval=Q.fromDate2DOS(l)},get timeval(){return o},set timeval(l){o=p(l)},get timeHighByte(){return E(o>>>8)},get crc(){return a},set crc(l){a=p(l)},get compressedSize(){return i},set compressedSize(l){i=p(l)},get size(){return c},set size(l){c=p(l)},get fileNameLength(){return d},set fileNameLength(l){d=l},get extraLength(){return m},set extraLength(l){m=l},get extraLocalLength(){return f.extraLen},set extraLocalLength(l){f.extraLen=l},get commentLength(){return y},set commentLength(l){y=l},get diskNumStart(){return T},set diskNumStart(l){T=p(l)},get inAttr(){return R},set inAttr(l){R=p(l)},get attr(){return _},set attr(l){_=p(l)},get fileAttr(){return(_||0)>>16&4095},get offset(){return u},set offset(l){u=p(l)},get encrypted(){return(r&b.FLG_ENC)===b.FLG_ENC},get centralHeaderSize(){return b.CENHDR+d+m+y},get realDataOffset(){return u+b.LOCHDR+f.fnameLen+f.extraLen},get localHeader(){return f},loadLocalHeaderFromBinary:s(function(l){var g=l.slice(u,u+b.LOCHDR);if(g.readUInt32LE(0)!==b.LOCSIG)throw Q.Errors.INVALID_LOC();f.version=g.readUInt16LE(b.LOCVER),f.flags=g.readUInt16LE(b.LOCFLG),f.flags_desc=(f.flags&b.FLG_DESC)>0,f.method=g.readUInt16LE(b.LOCHOW),f.time=g.readUInt32LE(b.LOCTIM),f.crc=g.readUInt32LE(b.LOCCRC),f.compressedSize=g.readUInt32LE(b.LOCSIZ),f.size=g.readUInt32LE(b.LOCLEN),f.fnameLen=g.readUInt16LE(b.LOCNAM),f.extraLen=g.readUInt16LE(b.LOCEXT);let I=u+b.LOCHDR+f.fnameLen,M=I+f.extraLen;return l.slice(I,M)},"loadLocalHeaderFromBinary"),loadFromBinary:s(function(l){if(l.length!==b.CENHDR||l.readUInt32LE(0)!==b.CENSIG)throw Q.Errors.INVALID_CEN();e=l.readUInt16LE(b.CENVEM),t=l.readUInt16LE(b.CENVER),r=l.readUInt16LE(b.CENFLG),n=l.readUInt16LE(b.CENHOW),o=l.readUInt32LE(b.CENTIM),a=l.readUInt32LE(b.CENCRC),i=l.readUInt32LE(b.CENSIZ),c=l.readUInt32LE(b.CENLEN),d=l.readUInt16LE(b.CENNAM),m=l.readUInt16LE(b.CENEXT),y=l.readUInt16LE(b.CENCOM),T=l.readUInt16LE(b.CENDSK),R=l.readUInt16LE(b.CENATT),_=l.readUInt32LE(b.CENATX),u=l.readUInt32LE(b.CENOFF)},"loadFromBinary"),localHeaderToBinary:s(function(){var l=Buffer.alloc(b.LOCHDR);return l.writeUInt32LE(b.LOCSIG,0),l.writeUInt16LE(t,b.LOCVER),l.writeUInt16LE(r&~b.FLG_DESC,b.LOCFLG),l.writeUInt16LE(n,b.LOCHOW),l.writeUInt32LE(o,b.LOCTIM),l.writeUInt32LE(a,b.LOCCRC),l.writeUInt32LE(i,b.LOCSIZ),l.writeUInt32LE(c,b.LOCLEN),l.writeUInt16LE(d,b.LOCNAM),l.writeUInt16LE(f.extraLen,b.LOCEXT),l},"localHeaderToBinary"),centralHeaderToBinary:s(function(){var l=Buffer.alloc(b.CENHDR+d+m+y);return l.writeUInt32LE(b.CENSIG,0),l.writeUInt16LE(e,b.CENVEM),l.writeUInt16LE(t,b.CENVER),l.writeUInt16LE(r&~b.FLG_DESC,b.CENFLG),l.writeUInt16LE(n,b.CENHOW),l.writeUInt32LE(o,b.CENTIM),l.writeUInt32LE(a,b.CENCRC),l.writeUInt32LE(i,b.CENSIZ),l.writeUInt32LE(c,b.CENLEN),l.writeUInt16LE(d,b.CENNAM),l.writeUInt16LE(m,b.CENEXT),l.writeUInt16LE(y,b.CENCOM),l.writeUInt16LE(T,b.CENDSK),l.writeUInt16LE(R,b.CENATT),l.writeUInt32LE(_,b.CENATX),l.writeUInt32LE(u,b.CENOFF),l},"centralHeaderToBinary"),toJSON:s(function(){let l=s(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:l(i),size:l(c),fileNameLength:l(d),extraLength:l(m),commentLength:l(y),diskNumStart:T,inAttr:R,attr:_,offset:u,centralHeaderSize:l(b.CENHDR+d+m+y)}},"toJSON"),toString:s(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var qt=W((xa,Yt)=>{var Z=le(),A=Z.Constants;Yt.exports=function(){var e=0,t=0,r=0,n=0,o=0;let a=s(()=>e>A.EF_ZIP64_OR_16||t>A.EF_ZIP64_OR_16||r>A.EF_ZIP64_OR_32||n>A.EF_ZIP64_OR_32,"needsZip64");return{get diskEntries(){return e},set diskEntries(i){e=t=i},get totalEntries(){return t},set totalEntries(i){t=e=i},get size(){return r},set size(i){r=i},get offset(){return n},set offset(i){n=i},get commentLength(){return o},set commentLength(i){o=i},get mainHeaderSize(){return(a()?A.ZIP64HDR+A.END64HDR:0)+A.ENDHDR+o},loadFromBinary:s(function(i){if((i.length!==A.ENDHDR||i.readUInt32LE(0)!==A.ENDSIG)&&(i.length<A.ZIP64HDR||i.readUInt32LE(0)!==A.ZIP64SIG))throw Z.Errors.INVALID_END();i.readUInt32LE(0)===A.ENDSIG?(e=i.readUInt16LE(A.ENDSUB),t=i.readUInt16LE(A.ENDTOT),r=i.readUInt32LE(A.ENDSIZ),n=i.readUInt32LE(A.ENDOFF),o=i.readUInt16LE(A.ENDCOM)):(e=Z.readBigUInt64LE(i,A.ZIP64SUB),t=Z.readBigUInt64LE(i,A.ZIP64TOT),r=Z.readBigUInt64LE(i,A.ZIP64SIZB),n=Z.readBigUInt64LE(i,A.ZIP64OFF),o=0)},"loadFromBinary"),toBinary:s(function(){if(!a()){var i=Buffer.alloc(A.ENDHDR+o);return i.writeUInt32LE(A.ENDSIG,0),i.writeUInt32LE(0,4),i.writeUInt16LE(e,A.ENDSUB),i.writeUInt16LE(t,A.ENDTOT),i.writeUInt32LE(r,A.ENDSIZ),i.writeUInt32LE(n,A.ENDOFF),i.writeUInt16LE(o,A.ENDCOM),i.fill(" ",A.ENDHDR),i}var i=Buffer.alloc(this.mainHeaderSize);let c=0;i.writeUInt32LE(A.ZIP64SIG,c),Z.writeBigUInt64LE(i,A.ZIP64HDR-A.ZIP64LEAD,c+A.ZIP64SIZE),i.writeUInt16LE(45,c+A.ZIP64VEM),i.writeUInt16LE(45,c+A.ZIP64VER),i.writeUInt32LE(0,c+A.ZIP64DSK),i.writeUInt32LE(0,c+A.ZIP64DSKDIR),Z.writeBigUInt64LE(i,e,c+A.ZIP64SUB),Z.writeBigUInt64LE(i,t,c+A.ZIP64TOT),Z.writeBigUInt64LE(i,r,c+A.ZIP64SIZB),Z.writeBigUInt64LE(i,n,c+A.ZIP64OFF);let d=n+r;return c+=A.ZIP64HDR,i.writeUInt32LE(A.END64SIG,c),i.writeUInt32LE(0,c+A.END64START),Z.writeBigUInt64LE(i,d,c+A.END64OFF),i.writeUInt32LE(1,c+A.END64NUMDISKS),c+=A.END64HDR,i.writeUInt32LE(A.ENDSIG,c),i.writeUInt32LE(0,c+4),i.writeUInt16LE(Math.min(e,A.EF_ZIP64_OR_16),c+A.ENDSUB),i.writeUInt16LE(Math.min(t,A.EF_ZIP64_OR_16),c+A.ENDTOT),i.writeUInt32LE(Math.min(r,A.EF_ZIP64_OR_32),c+A.ENDSIZ),i.writeUInt32LE(Math.min(n,A.EF_ZIP64_OR_32),c+A.ENDOFF),i.writeUInt16LE(o,c+A.ENDCOM),i.fill(" ",c+A.ENDHDR),i},"toBinary"),toJSON:s(function(){let i=s(function(c,d){let m=c.toString(16).toUpperCase();for(;m.length<d;)m="0"+m;return"0x"+m},"offset");return{diskEntries:e,totalEntries:t,size:r+" bytes",offset:i(n,4),commentLength:o}},"toJSON"),toString:s(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var Ye=W(Je=>{Je.EntryHeader=Jt();Je.MainHeader=qt()});var Qt=W((wa,Xt)=>{Xt.exports=function(e){var t=require("zlib"),r={chunkSize:(parseInt(e.length/1024)+1)*1024};return{deflate:s(function(){return t.deflateRawSync(e,r)},"deflate"),deflateAsync:s(function(n){var o=t.createDeflateRaw(r),a=[],i=0;o.on("data",function(c){a.push(c),i+=c.length}),o.on("end",function(){var c=Buffer.alloc(i),d=0;c.fill(0);for(var m=0;m<a.length;m++){var y=a[m];y.copy(c,d),d+=y.length}n&&n(c)}),o.end(e)},"deflateAsync")}}});var tr=W((Da,er)=>{var eo=+(process?.versions?.node??"").split(".")[0]||0;er.exports=function(e,t){var r=require("zlib");let n=eo>=15&&t>0?{maxOutputLength:t}:{};return{inflate:s(function(){return r.inflateRawSync(e,n)},"inflate"),inflateAsync:s(function(o){var a=r.createInflateRaw(n),i=[],c=0;a.on("data",function(d){i.push(d),c+=d.length}),a.on("end",function(){var d=Buffer.alloc(c),m=0;d.fill(0);for(var y=0;y<i.length;y++){var T=i[y];T.copy(d,m),m+=T.length}o&&o(d)}),a.end(e)},"inflateAsync")}}});var ir=W((Pa,sr)=>{"use strict";var{randomFillSync:rr}=require("crypto"),to=Me(),ro=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}),or=s((e,t)=>Math.imul(e,t)>>>0,"uMul"),nr=s((e,t)=>ro[(e^t)&255]^e>>>8,"crc32update"),Ee=s(()=>typeof rr=="function"?rr(Buffer.alloc(12)):Ee.node(),"genSalt");Ee.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 Ae={genSalt:Ee};function Ce(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])}s(Ce,"Initkeys");Ce.prototype.updateKeys=function(e){let t=this.keys;return t[0]=nr(t[0],e),t[1]+=t[0]&255,t[1]=or(t[1],134775813)+1,t[2]=nr(t[2],t[1]>>>24),e};Ce.prototype.next=function(){let e=(this.keys[2]|2)>>>0;return or(e,e^1)>>8&255};function no(e){let t=new Ce(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}}s(no,"make_decrypter");function oo(e){let t=new Ce(e);return function(r,n,o=0){n||(n=Buffer.alloc(r.length));for(let a of r){let i=t.next();n[o++]=a^i,t.updateKeys(a)}return n}}s(oo,"make_encrypter");function so(e,t,r){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);let n=no(r),o=n(e.slice(0,12)),a=(t.flags&8)===8?t.timeHighByte:t.crc>>>24;if(o[11]!==a)throw to.WRONG_PASSWORD();return n(e.slice(12))}s(so,"decrypt");function io(e){Buffer.isBuffer(e)&&e.length>=12?Ae.genSalt=function(){return e.slice(0,12)}:e==="node"?Ae.genSalt=Ee.node:Ae.genSalt=Ee}s(io,"_salter");function ao(e,t,r,n=!1){e==null&&(e=Buffer.alloc(0)),Buffer.isBuffer(e)||(e=Buffer.from(e.toString()));let o=oo(r),a=Ae.genSalt();a[11]=t.crc>>>24&255,n&&(a[10]=t.crc>>>16&255);let i=Buffer.alloc(e.length+12);return o(a,i),o(e,i,12)}s(ao,"encrypt");sr.exports={decrypt:so,encrypt:ao,_salter:io}});var ar=W(xe=>{xe.Deflater=Qt();xe.Inflater=tr();xe.ZipCrypto=ir()});var Xe=W((ka,lr)=>{var w=le(),lo=Ye(),j=w.Constants,qe=ar();lr.exports=function(e,t){var r=new lo.EntryHeader,n=Buffer.alloc(0),o=Buffer.alloc(0),a=!1,i=null,c=Buffer.alloc(0),d=Buffer.alloc(0),m=!0;let y=e,T=typeof y.decoder=="object"?y.decoder:w.decoder;m=T.hasOwnProperty("efs")?T.efs:!1;function R(){return!t||!(t instanceof Uint8Array)?Buffer.alloc(0):(d=r.loadLocalHeaderFromBinary(t),t.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}s(R,"getCompressedDataFromZip");function _(l){let g=r.flags_desc||r.localHeader.flags_desc?r.crc:r.localHeader.crc;return w.crc32(l)===g}s(_,"crc32OK");function u(l,g,I){if(typeof g>"u"&&typeof l=="string"&&(I=l,l=void 0),a)return l&&g&&g(Buffer.alloc(0),w.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var M=R();if(M.length===0)return l&&g&&g(M),M;if(r.encrypted){if(typeof I!="string"&&!Buffer.isBuffer(I))throw w.Errors.INVALID_PASS_PARAM();M=qe.ZipCrypto.decrypt(M,r,I)}var S;switch(r.method){case w.Constants.STORED:if(S=Buffer.alloc(M.length),M.copy(S),_(S))return l&&g&&g(S),S;throw l&&g&&g(S,w.Errors.BAD_CRC()),w.Errors.BAD_CRC();case w.Constants.DEFLATED:var C=new qe.Inflater(M,r.size);if(l)C.inflateAsync(function(x){g&&(_(x)?g(x):g(x,w.Errors.BAD_CRC()))});else{if(S=C.inflate(),!_(S))throw w.Errors.BAD_CRC(`"${T.decode(n)}"`);return S}break;default:throw l&&g&&g(Buffer.alloc(0),w.Errors.UNKNOWN_METHOD()),w.Errors.UNKNOWN_METHOD()}}s(u,"decompress");function f(l,g){if((!i||!i.length)&&Buffer.isBuffer(t))return l&&g&&g(R()),R();if(i.length&&!a){var I;switch(r.method){case w.Constants.STORED:return r.compressedSize=r.size,I=Buffer.alloc(i.length),i.copy(I),l&&g&&g(I),I;default:case w.Constants.DEFLATED:var M=new qe.Deflater(i);if(l)M.deflateAsync(function(C){I=Buffer.alloc(C.length),r.compressedSize=C.length,C.copy(I),g&&g(I)});else{var S=M.deflate();return r.compressedSize=S.length,S}M=null;break}}else if(l&&g)g(Buffer.alloc(0));else return Buffer.alloc(0)}s(f,"compress");function p(l,g){return w.readBigUInt64LE(l,g)}s(p,"readUInt64LE");function h(l){try{for(var g=0,I,M,S;g+4<l.length;)I=l.readUInt16LE(g),g+=2,M=l.readUInt16LE(g),g+=2,S=l.slice(g,g+M),g+=M,j.ID_ZIP64===I&&E(S)}catch{throw w.Errors.EXTRA_FIELD_PARSE_ERROR()}}s(h,"parseExtra");function E(l){var g,I,M,S;l.length>=j.EF_ZIP64_SCOMP&&(g=p(l,j.EF_ZIP64_SUNCOMP),r.size===j.EF_ZIP64_OR_32&&(r.size=g)),l.length>=j.EF_ZIP64_RHO&&(I=p(l,j.EF_ZIP64_SCOMP),r.compressedSize===j.EF_ZIP64_OR_32&&(r.compressedSize=I)),l.length>=j.EF_ZIP64_DSN&&(M=p(l,j.EF_ZIP64_RHO),r.offset===j.EF_ZIP64_OR_32&&(r.offset=M)),l.length>=j.EF_ZIP64_DSN+4&&(S=l.readUInt32LE(j.EF_ZIP64_DSN),r.diskNumStart===j.EF_ZIP64_OR_16&&(r.diskNumStart=S))}return s(E,"parseZip64ExtendedInformation"),{get entryName(){return T.decode(n)},get rawEntryName(){return n},set entryName(l){n=w.toBuffer(l,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 c},set extra(l){c=l,r.extraLength=l.length,h(l)},get comment(){return T.decode(o)},set comment(l){if(o=w.toBuffer(l,T.encode),r.commentLength=o.length,o.length>65535)throw w.Errors.COMMENT_TOO_LONG()},get name(){let l=T.decode(n);return a?l.replace(/[/\\]$/,"").split("/").pop():l.split("/").pop()},get isDirectory(){return a},getCompressedData:s(function(){return f(!1,null)},"getCompressedData"),getCompressedDataAsync:s(function(l){f(!0,l)},"getCompressedDataAsync"),setData:s(function(l){i=w.toBuffer(l,w.decoder.encode),!a&&i.length?(r.size=i.length,r.method=w.Constants.DEFLATED,r.crc=w.crc32(l),r.changed=!0):r.method=w.Constants.STORED},"setData"),getData:s(function(l){return r.changed?i:u(!1,null,l)},"getData"),getDataAsync:s(function(l,g){r.changed?l(i):u(!0,l,g)},"getDataAsync"),set attr(l){r.attr=l},get attr(){return r.attr},set header(l){r.loadFromBinary(l)},get header(){return r},packCentralHeader:s(function(){r.flags_efs=this.efs,r.extraLength=c.length;var l=r.centralHeaderToBinary(),g=w.Constants.CENHDR;return n.copy(l,g),g+=n.length,c.copy(l,g),g+=r.extraLength,o.copy(l,g),l},"packCentralHeader"),packLocalHeader:s(function(){let l=0;r.flags_efs=this.efs,r.extraLocalLength=d.length;let g=r.localHeaderToBinary(),I=Buffer.alloc(g.length+n.length+r.extraLocalLength);return g.copy(I,l),l+=g.length,n.copy(I,l),l+=n.length,d.copy(I,l),l+=d.length,I},"packLocalHeader"),toJSON:s(function(){let l=s(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:l(t),data:l(i)}},"toJSON"),toString:s(function(){return JSON.stringify(this.toJSON(),null," ")},"toString")}}});var ur=W((Ha,dr)=>{var cr=Xe(),co=Ye(),z=le();dr.exports=function(e,t){var r=[],n=Object.create(null),o=Buffer.alloc(0),a=new co.MainHeader,i=!1,c=null;let d=new Set,m=t,{noSort:y,decoder:T}=m;e?u(m.readEntries):i=!0;function R(){let p=new Set;for(let h of Object.keys(n)){let E=h.split("/");if(E.pop(),!!E.length)for(let l=0;l<E.length;l++){let g=E.slice(0,l+1).join("/")+"/";p.add(g)}}for(let h of p)if(!(h in n)){let E=new cr(m);E.entryName=h,E.attr=16,E.temporary=!0,r.push(E),n[E.entryName]=E,d.add(E)}}s(R,"makeTemporaryFolders");function _(){if(i=!0,n=Object.create(null),a.diskEntries>(e.length-a.offset)/z.Constants.CENHDR)throw z.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(a.diskEntries);for(var p=a.offset,h=0;h<r.length;h++){var E=p,l=new cr(m,e);l.header=e.slice(E,E+=z.Constants.CENHDR),l.entryName=e.slice(E,E+=l.header.fileNameLength),l.header.extraLength&&(l.extra=e.slice(E,E+=l.header.extraLength)),l.header.commentLength&&(l.comment=e.slice(E,E+l.header.commentLength)),p+=l.header.centralHeaderSize,r[h]=l,n[l.entryName]=l}d.clear(),R()}s(_,"readEntries");function u(p){var h=e.length-z.Constants.ENDHDR,E=Math.max(0,h-65535),l=E,g=e.length,I=-1,M=0;for(typeof m.trailingSpace=="boolean"&&m.trailingSpace&&(E=0),h;h>=l;h--)if(e[h]===80){if(e.readUInt32LE(h)===z.Constants.ENDSIG){I=h,M=h,g=h+z.Constants.ENDHDR,l=h-z.Constants.END64HDR;continue}if(e.readUInt32LE(h)===z.Constants.END64SIG){l=E;continue}if(e.readUInt32LE(h)===z.Constants.ZIP64SIG){I=h,g=h+z.readBigUInt64LE(e,h+z.Constants.ZIP64SIZE)+z.Constants.ZIP64LEAD;break}}if(I==-1)throw z.Errors.INVALID_FORMAT();a.loadFromBinary(e.slice(I,g)),a.commentLength&&(o=e.slice(M+z.Constants.ENDHDR)),p&&_()}s(u,"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 s(f,"sortEntries"),{get entries(){return i||_(),r.filter(p=>!d.has(p))},get comment(){return T.decode(o)},set comment(p){o=z.toBuffer(p,T.encode),a.commentLength=o.length},getEntryCount:s(function(){return i?r.length:a.diskEntries},"getEntryCount"),forEach:s(function(p){this.entries.forEach(p)},"forEach"),getEntry:s(function(p){return i||_(),n[p]||null},"getEntry"),setEntry:s(function(p){i||_(),r.push(p),n[p.entryName]=p,a.totalEntries=r.length},"setEntry"),deleteFile:s(function(p,h=!0){i||_();let E=n[p];this.getEntryChildren(E,h).map(g=>g.entryName).forEach(this.deleteEntry)},"deleteFile"),deleteEntry:s(function(p){i||_();let h=n[p],E=r.indexOf(h);E>=0&&(r.splice(E,1),delete n[p],a.totalEntries=r.length)},"deleteEntry"),getEntryChildren:s(function(p,h=!0){if(i||_(),typeof p=="object")if(p.isDirectory&&h){let E=[],l=p.entryName;for(let g of r)g.entryName.startsWith(l)&&E.push(g);return E}else return[p];return[]},"getEntryChildren"),getChildCount:s(function(p){if(p&&p.isDirectory){let h=this.getEntryChildren(p);return h.includes(p)?h.length-1:h.length}return 0},"getChildCount"),compressToBuffer:s(function(){i||_(),f();let p=[],h=[],E=0,l=0;a.size=0,a.offset=0;let g=0;for(let S of this.entries){let C=S.getCompressedData();S.header.offset=l;let x=S.packLocalHeader(),v=x.length+C.length;l+=v,p.push(x),p.push(C);let N=S.packCentralHeader();h.push(N),a.size+=N.length,E+=v+N.length,g++}E+=a.mainHeaderSize,a.offset=l,a.totalEntries=g,l=0;let I=Buffer.alloc(E);for(let S of p)S.copy(I,l),l+=S.length;for(let S of h)S.copy(I,l),l+=S.length;let M=a.toBinary();return o&&o.copy(M,M.length-o.length),M.copy(I,l),e=I,i=!1,I},"compressToBuffer"),toAsyncBuffer:s(function(p,h,E,l){try{i||_(),f();let g=[],I=[],M=0,S=0,C=0;a.size=0,a.offset=0;let x=s(function(v){if(v.length>0){let N=v.shift(),G=N.entryName+N.extra.toString();E&&E(G),N.getCompressedDataAsync(function($){l&&l(G),N.header.offset=S;let te=N.packLocalHeader(),Ie=te.length+$.length;S+=Ie,g.push(te),g.push($);let ge=N.packCentralHeader();I.push(ge),a.size+=ge.length,M+=Ie+ge.length,C++,x(v)})}else{M+=a.mainHeaderSize,a.offset=S,a.totalEntries=C,S=0;let N=Buffer.alloc(M);g.forEach(function($){$.copy(N,S),S+=$.length}),I.forEach(function($){$.copy(N,S),S+=$.length});let G=a.toBinary();o&&o.copy(G,G.length-o.length),G.copy(N,S),e=N,i=!1,p(N)}},"compress2Buffer");x(Array.from(this.entries))}catch(g){h(g)}},"toAsyncBuffer")}}});var mr=W((Wa,fr)=>{var L=le(),D=require("path"),uo=Xe(),po=ur(),re=s((...e)=>L.findLast(e,t=>typeof t=="boolean"),"get_Bool"),pr=s((...e)=>L.findLast(e,t=>typeof t=="string"),"get_Str"),fo=s((...e)=>L.findLast(e,t=>typeof t=="function"),"get_Fun"),mo={noSort:!1,readEntries:!1,method:L.Constants.NONE,fs:null};fr.exports=function(e,t){let r=null,n=Object.assign(Object.create(null),mo);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=L.Constants.BUFFER,e=void 0)),Object.assign(n,t);let o=new L(n),a=s(u=>{u.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=L.decoder),e&&typeof e=="string")if(o.fs.existsSync(e))n.method=L.Constants.FILE,n.filename=e,r=o.fs.readFileSync(e);else throw L.Errors.INVALID_FILENAME();let i=new po(r,n),{canonical:c,sanitize:d,zipnamefix:m}=L;function y(u){if(u&&i){var f;if(typeof u=="string"&&(f=i.getEntry(D.posix.normalize(u))),typeof u=="object"&&typeof u.entryName<"u"&&typeof u.header<"u"&&(f=i.getEntry(u.entryName)),f)return f}return null}s(y,"getEntry");function T(u){let{join:f,normalize:p,sep:h}=D.posix;return f(D.isAbsolute(u)?"/":".",p(h+u.split("\\").join(h)+h))}s(T,"fixPath");function R(u){return u instanceof RegExp?(function(f){return function(p){return f.test(p)}})(u):typeof u!="function"?()=>!0:u}s(R,"filenameFilter");let _=s((u,f)=>{let p=f.slice(-1);return p=p===o.sep?o.sep:"",D.relative(u,f)+p},"relativePath");return{readFile:s(function(u,f){var p=y(u);return p&&p.getData(f)||null},"readFile"),childCount:s(function(u){let f=y(u);if(f)return i.getChildCount(f)},"childCount"),readFileAsync:s(function(u,f){var p=y(u);p?p.getDataAsync(f):f(null,"getEntry failed for:"+u)},"readFileAsync"),readAsText:s(function(u,f){var p=y(u);if(p){var h=p.getData();if(h&&h.length)return h.toString(f||"utf8")}return""},"readAsText"),readAsTextAsync:s(function(u,f,p){var h=y(u);h?h.getDataAsync(function(E,l){if(l){f(E,l);return}E&&E.length?f(E.toString(p||"utf8")):f("")}):f("")},"readAsTextAsync"),deleteFile:s(function(u,f=!0){var p=y(u);p&&i.deleteFile(p.entryName,f)},"deleteFile"),deleteEntry:s(function(u){var f=y(u);f&&i.deleteEntry(f.entryName)},"deleteEntry"),addZipComment:s(function(u){i.comment=u},"addZipComment"),getZipComment:s(function(){return i.comment||""},"getZipComment"),addZipEntryComment:s(function(u,f){var p=y(u);p&&(p.comment=f)},"addZipEntryComment"),getZipEntryComment:s(function(u){var f=y(u);return f&&f.comment||""},"getZipEntryComment"),updateFile:s(function(u,f){var p=y(u);p&&p.setData(f)},"updateFile"),addLocalFile:s(function(u,f,p,h){if(o.fs.existsSync(u)){f=f?T(f):"";let E=D.win32.basename(D.win32.normalize(u));f+=p||E;let l=o.fs.statSync(u),g=l.isFile()?o.fs.readFileSync(u):Buffer.alloc(0);l.isDirectory()&&(f+=o.sep),this.addFile(f,g,h,l)}else throw L.Errors.FILE_NOT_FOUND(u)},"addLocalFile"),addLocalFileAsync:s(function(u,f){u=typeof u=="object"?u:{localPath:u};let p=D.resolve(u.localPath),{comment:h}=u,{zipPath:E,zipName:l}=u,g=this;o.fs.stat(p,function(I,M){if(I)return f(I,!1);E=E?T(E):"";let S=D.win32.basename(D.win32.normalize(p));if(E+=l||S,M.isFile())o.fs.readFile(p,function(C,x){return C?f(C,!1):(g.addFile(E,x,h,M),setImmediate(f,void 0,!0))});else if(M.isDirectory())return E+=o.sep,g.addFile(E,Buffer.alloc(0),h,M),setImmediate(f,void 0,!0)})},"addLocalFileAsync"),addLocalFolder:s(function(u,f,p){if(p=R(p),f=f?T(f):"",u=D.normalize(u),o.fs.existsSync(u)){let h=o.findFiles(u),E=this;if(h.length)for(let l of h){let g=D.join(f,_(u,l));p(g)&&E.addLocalFile(l,D.dirname(g))}}else throw L.Errors.FILE_NOT_FOUND(u)},"addLocalFolder"),addLocalFolderAsync:s(function(u,f,p,h){h=R(h),p=p?T(p):"",u=D.normalize(u);var E=this;o.fs.open(u,"r",function(l){if(l&&l.code==="ENOENT")f(void 0,L.Errors.FILE_NOT_FOUND(u));else if(l)f(void 0,l);else{var g=o.findFiles(u),I=-1,M=s(function(){if(I+=1,I<g.length){var S=g[I],C=_(u,S).split("\\").join("/");C=C.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),h(C)?o.fs.stat(S,function(x,v){x&&f(void 0,x),v.isFile()?o.fs.readFile(S,function(N,G){N?f(void 0,N):(E.addFile(p+C,G,"",v),M())}):(E.addFile(p+C+"/",Buffer.alloc(0),"",v),M())}):process.nextTick(()=>{M()})}else f(!0,void 0)},"next");M()}})},"addLocalFolderAsync"),addLocalFolderAsync2:s(function(u,f){let p=this;u=typeof u=="object"?u:{localPath:u};let h=D.resolve(T(u.localPath)),{zipPath:E,filter:l,namefix:g}=u;l instanceof RegExp?l=(function(S){return function(C){return S.test(C)}})(l):typeof l!="function"&&(l=s(function(){return!0},"filter")),E=E?T(E):"",g==="latin1"&&(g=s(S=>S.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),"namefix")),typeof g!="function"&&(g=s(S=>S,"namefix"));let I=s(S=>D.join(E,g(_(h,S))),"relPathFix"),M=s(S=>D.win32.basename(D.win32.normalize(g(S))),"fileNameFix");o.fs.open(h,"r",function(S){S&&S.code==="ENOENT"?f(void 0,L.Errors.FILE_NOT_FOUND(h)):S?f(void 0,S):o.findFilesAsync(h,function(C,x){if(C)return f(C);x=x.filter(v=>l(I(v))),x.length||f(void 0,!1),setImmediate(x.reverse().reduce(function(v,N){return function(G,$){if(G||$===!1)return setImmediate(v,G,!1);p.addLocalFileAsync({localPath:N,zipPath:D.dirname(I(N)),zipName:M(N)},v)}},f))})})},"addLocalFolderAsync2"),addLocalFolderPromise:s(function(u,f){return new Promise((p,h)=>{this.addLocalFolderAsync2(Object.assign({localPath:u},f),(E,l)=>{E&&h(E),l&&p(this)})})},"addLocalFolderPromise"),addFile:s(function(u,f,p,h){u=m(u);let E=y(u),l=E!=null;l||(E=new uo(n),E.entryName=u),E.comment=p||"";let g=typeof h=="object"&&h instanceof o.fs.Stats;g&&(E.header.time=h.mtime);var I=E.isDirectory?16:0;let M=E.isDirectory?16384:32768;return g?M|=4095&h.mode:typeof h=="number"?M|=4095&h:M|=E.isDirectory?493:420,I=(I|M<<16)>>>0,E.attr=I,E.setData(f),l||i.setEntry(E),E},"addFile"),getEntries:s(function(u){return i.password=u,i?i.entries:[]},"getEntries"),getEntry:s(function(u){return y(u)},"getEntry"),getEntryCount:s(function(){return i.getEntryCount()},"getEntryCount"),forEach:s(function(u){return i.forEach(u)},"forEach"),extractEntryTo:s(function(u,f,p,h,E,l){h=re(!1,h),E=re(!1,E),p=re(!0,p),l=pr(E,l);var g=y(u);if(!g)throw L.Errors.NO_ENTRY();var I=c(g.entryName),M=d(f,l&&!g.isDirectory?c(l):p?I:D.basename(I));if(g.isDirectory){var S=i.getEntryChildren(g);return S.forEach(function(v){if(v.isDirectory)return;var N=v.getData();if(!N)throw L.Errors.CANT_EXTRACT_FILE();var G=c(p?v.entryName:v.entryName.substring(g.entryName.length)),$=d(f,G);let te=E?v.header.fileAttr:void 0;o.writeFileTo($,N,h,te)}),!0}var C=g.getData(i.password);if(!C)throw L.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(M)&&!h)throw L.Errors.CANT_OVERRIDE();let x=E?u.header.fileAttr:void 0;return o.writeFileTo(M,C,h,x),!0},"extractEntryTo"),test:s(function(u){if(!i)return!1;for(var f of i.entries)try{if(f.isDirectory)continue;var p=f.getData(u);if(!p)return!1}catch{return!1}return!0},"test"),extractAllTo:s(function(u,f,p,h){if(p=re(!1,p),h=pr(p,h),f=re(!1,f),!i)throw L.Errors.NO_ZIP();let E=[];i.entries.forEach(function(l){var g=d(u,c(l.entryName));if(l.isDirectory){o.makeDir(g),p&&E.push({path:g,attr:l.header.fileAttr});return}var I=l.getData(h);if(!I)throw L.Errors.CANT_EXTRACT_FILE();let M=p?l.header.fileAttr:void 0;o.writeFileTo(g,I,f,M);try{o.fs.utimesSync(g,l.header.time,l.header.time)}catch{}}),a(E)},"extractAllTo"),extractAllToAsync:s(function(u,f,p,h){if(h=fo(f,p,h),p=re(!1,p),f=re(!1,f),!h)return new Promise((C,x)=>{this.extractAllToAsync(u,f,p,function(v){v?x(v):C(this)})});if(!i){h(L.Errors.NO_ZIP());return}u=D.resolve(u);let E=s(C=>d(u,D.normalize(c(C.entryName))),"getPath"),l=s((C,x)=>new Error(C+': "'+x+'"'),"getError"),g=[],I=[];i.entries.forEach(C=>{C.isDirectory?g.push(C):I.push(C)});let M=[];for(let C of g){let x=E(C),v=p?C.header.fileAttr:void 0;try{o.makeDir(x)}catch{h(l("Unable to create folder",x));continue}v&&M.push({path:x,attr:v});try{o.fs.utimesSync(x,C.header.time,C.header.time)}catch{}}let S=s(C=>{if(!C)try{a(M)}catch(x){return h(l("Unable to set folder permissions",x.path||""))}h(C)},"done");I.reverse().reduce(function(C,x){return function(v){if(v)C(v);else{let N=D.normalize(c(x.entryName)),G=d(u,N);x.getDataAsync(function($,te){if(te)C(te);else if(!$)C(L.Errors.CANT_EXTRACT_FILE());else{let Ie=p?x.header.fileAttr:void 0;o.writeFileToAsync(G,$,f,Ie,function(ge){if(!ge)return C(l("Unable to write file",G));o.fs.utimes(G,x.header.time,x.header.time,function(){C()})})}})}}},S)()},"extractAllToAsync"),writeZip:s(function(u,f){if(arguments.length===1&&typeof u=="function"&&(f=u,u=""),!u&&n.filename&&(u=n.filename),!!u){var p=i.compressToBuffer();if(p){var h=o.writeFileTo(u,p,!0);typeof f=="function"&&f(h?null:new Error("failed"),"")}}},"writeZip"),writeZipPromise:s(function(u,f){let{overwrite:p,perm:h}=Object.assign({overwrite:!0},f);return new Promise((E,l)=>{!u&&n.filename&&(u=n.filename),u||l("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(g=>{let I=s(M=>M?E(M):l("ADM-ZIP: Wasn't able to write zip file"),"ret");o.writeFileToAsync(u,g,p,h,I)},l)})},"writeZipPromise"),toBufferPromise:s(function(){return new Promise((u,f)=>{i.toAsyncBuffer(u,f)})},"toBufferPromise"),toBuffer:s(function(u,f,p,h){return typeof u=="function"?(i.toAsyncBuffer(u,f,p,h),null):i.compressToBuffer()},"toBuffer")}}});var Ps={};Cn(Ps,{TestRunMonitor:()=>ze});module.exports=xn(Ps);var Ve=s(e=>new Promise(t=>setTimeout(t,e)),"awaitSleep");function Rt(e=5,t="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"){let r="";for(let n=e;n>0;--n)r+=t[Math.floor(Math.random()*t.length)]??"";return r}s(Rt,"randomString");var ea=require("@playwright/test");var Si=require("@playwright/test");var yi=require("@playwright/test");var fi=require("@playwright/test");var ji=require("@playwright/test");var Fi={openai_gpt_4_1:{model:"gpt-4.1-2025-04-14",type:"openai"},openai_gpt_4_1_mini:{model:"gpt-4.1-mini-2025-04-14",type:"openai"},openai_gpt_4_1_nano:{model:"gpt-4.1-nano-2025-04-14",type:"openai"},gemini_2_0_flash:{model:"gemini-2.0-flash",type:"gemini"},gemini_2_5_pro_exp:{model:"gemini-2.5-pro-exp-03-25",type:"gemini"},gemini_2_5_flash:{model:"gemini-2.5-flash",type:"gemini"},gemini_2_5_pro_preview_05_06:{model:"gemini-2.5-pro-preview-05-06",type:"gemini"},claude_sonnet_4:{model:"claude-sonnet-4@20250514",type:"anthropic-vertexai"},claude_sonnet_4_6:{model:"claude-sonnet-4-6",type:"anthropic-vertexai"},claude_sonnet_5:{model:"claude-sonnet-5",type:"anthropic-vertexai"},claude_opus_4_8:{model:"claude-opus-4-8",type:"anthropic-vertexai"},gemini_2_5_flash_lite:{model:"gemini-2.5-flash-lite",type:"gemini"},gemini_3_5_flash:{model:"gemini-3.5-flash",type:"gemini"},gemini_3_1_flash_lite:{model:"gemini-3.1-flash-lite",type:"gemini"}};var wt=se(je());wt.default.config({path:[`${__dirname}/.env`,`${__dirname}/../../.env`]});var Vn="claude_4",Kn={gemini20flash:{name:"google-vertexai/gemini-2.0-flash",inputTokenLimit:8e5,provider:"gemini",temperature:0},gpt41:{name:"openai/gpt-4.1",inputTokenLimit:8e5,provider:"openai",temperature:0},gemini25flash:{name:"google-vertexai/gemini-2.5-flash",inputTokenLimit:8e5,provider:"gemini",temperature:.7},gemini25flash_lite:{name:"google-vertexai/gemini-2.5-flash-lite",inputTokenLimit:8e5,provider:"gemini",temperature:0},gpt4onano:{name:"openai/gpt-4o-nano",inputTokenLimit:8e5,provider:"openai",temperature:0},gpt41nano:{name:"openai/gpt-4.1-nano",inputTokenLimit:8e5,provider:"openai",temperature:0},gpt41mini:{name:"openai/gpt-4.1-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},o3mini:{name:"openai/o3-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},o4mini:{name:"openai/o4-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},gemini25pro:{name:"google-vertexai/gemini-2.5-pro-preview-05-06",inputTokenLimit:8e5,provider:"gemini",temperature:0},claude37sonnet:{name:"google-vertexai/claude-3-7-sonnet@20250219",inputTokenLimit:15e4,provider:"anthropic",temperature:0},claude4sonnet:{name:"google-vertexai/claude-sonnet-4@20250514",inputTokenLimit:15e4,provider:"anthropic",temperature:1},claudeSonnet46:{name:"google-vertexai/claude-sonnet-4-6",inputTokenLimit:15e4,provider:"anthropic",temperature:1,location:"global"},claudeSonnet5:{name:"google-vertexai/claude-sonnet-5",inputTokenLimit:15e4,provider:"anthropic",temperature:1,location:"global"},claudeOpus48:{name:"google-vertexai/claude-opus-4-8",inputTokenLimit:15e4,provider:"anthropic",temperature:1,location:"global"},gemini35flash:{name:"google-vertexai/gemini-3.5-flash",inputTokenLimit:8e5,provider:"gemini",temperature:0,location:"global"},gemini31flashLite:{name:"google-vertexai/gemini-3.1-flash-lite",inputTokenLimit:8e5,provider:"gemini",temperature:0,location:"global"},gpt4omini:{name:"openai/gpt-4o-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},gpt5mini:{name:"openai/gpt-5-mini",inputTokenLimit:8e5,provider:"openai",temperature:0},gpt5nano:{name:"openai/gpt-5-nano",inputTokenLimit:8e5,provider:"openai",temperature:0}},jn=s(()=>({nodeEnv:process.env.NODE_ENV??"production",selectedModel:{name:Vn},models:Kn,langsmith:{enabled:process.env.LANGSMITH_TRACING==="true",endpoint:process.env.LANGSMITH_ENDPOINT??"",apiKey:process.env.LANGSMITH_API_KEY??"",project:process.env.LANGSMITH_PROJECT??""}}),"make"),U=jn(),zi={claude_4:U.models.claude4sonnet,"claude_3.7":U.models.claude37sonnet,claude_sonnet_4_6:U.models.claudeSonnet46,claude_sonnet_5:U.models.claudeSonnet5,claude_opus_4_8:U.models.claudeOpus48,"gemini_2.5_pro":U.models.gemini25pro,"gemini_2.0_flash":U.models.gemini20flash,"gemini_2.5_flash_lite":U.models.gemini25flash_lite,"gemini_2.5_flash":U.models.gemini25flash,"gemini_3.5_flash":U.models.gemini35flash,"gemini_3.1_flash_lite":U.models.gemini31flashLite,gpt_4o_mini:U.models.gpt4omini,gpt_4o_nano:U.models.gpt4onano,gpt_41_nano:U.models.gpt41nano,gpt_5_mini:U.models.gpt5mini,gpt_5_nano:U.models.gpt5nano,gpt_41_mini:U.models.gpt41mini,gpt_41:U.models.gpt41,o4_mini:U.models.o4mini,o3_mini:U.models.o3mini};var gn=require("child_process"),Se=require("crypto"),P=require("fs"),hn=require("fs/promises"),yn=require("stream/promises"),En=require("http"),Tn=se(require("net")),_n=require("os"),K=require("path");function Zn(e){if(e)return{...e,...e.tests?{tests:e.tests.map(t=>{let{errorMessage:r,...n}=t;return n})}:{}}}s(Zn,"projectReportStatsForTelemetry");function Ot(e,t,r){e.emit({outcome:t,stats:Zn(r)})}s(Ot,"emitReportProcessingStatsTelemetry");var Dt=["script","template"],Lt='<script id="playwrightReportBase64" type="application/zip">',Pt="</script>";var Hr=require("htmlparser2"),Gr=se(mr()),H=require("node:fs"),ne=require("node:path"),Wr=require("node:os"),$r=require("node:crypto");var X=se(require("path")),tt=require("fs");var Qe=require("path"),ve=require("fs");function go(e,t,r=10){let n=e;for(let o=0;o<r;o++){let a=(0,Qe.join)(n,"package.json");if((0,ve.existsSync)(a))try{if(JSON.parse((0,ve.readFileSync)(a,"utf8")).name===t)return n}catch{}n=(0,Qe.join)(n,"..")}}s(go,"findRepositoryRoot");function gr(e,t=10){return go(e,"checksum-customer-engineering-workspace",t)}s(gr,"findCustomerEngineeringRoot");var rt=se(je());var V=s((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 hr(e){if(e===void 0||e.trim()==="")return 5e7;let t=Number(e);return!Number.isInteger(t)||t<0?5e7:t}s(hr,"resolveMaxRRwebBytes");var ho=__dirname,yr=X.join(__dirname,".."),Tr=(0,tt.existsSync)(yr)?yr:ho;(0,rt.config)({path:X.resolve(Tr,".env")});var Er=V(process.env.CHECKSUM_RUNTIME_DEV_MODE);function yo(){let e=__dirname;for(;!(0,tt.existsSync)(X.join(e,"package.json"));)e=X.join(e,"..");return e}s(yo,"findRoot");var Te=yo(),Eo=gr(Te,10);(0,rt.config)({path:[Tr,Eo].filter(e=>!!e).map(e=>X.resolve(e,".env")),override:!1});var et=V(process.env.CHECKSUM_RUNTIME_REPO_MODE),To=et?X.join(Te,"package","pw-report-template.html"):X.join(Te,"pw-report-template.html"),_o=V(process.env.CHECKSUM_DEBUG_ANALYTICS),bo=V(process.env.CHECKSUM_LOG_ANALYTICS_TO_CONSOLE),So=hr(process.env.CHECKSUM_RUNTIME_RRWEB_MAX_BYTES),Ne={isDevMode:Er,isRepoMode:et,CI:!!process.env.CI,checksumRootFolderBypass:et&&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??(Er?"url":"file"),url:process.env.CHECKSUM_RUNTIME_SCRIPT_URL,path:Te+"/checksumlib.js"},runtimeRoot:Te,playwrightReporter:{htmlReportTemplatePath:To},bypassProxyForLocalhost:V(process.env.CHECKSUM_RUNTIME_BYPASS_PROXY_FOR_LOCALHOST),useCLIDebug:V(process.env.CHECKSUM_RUNTIME_USE_CLI_DEBUG),useRemoteDebugging:{enabled:V(process.env.CHECKSUM_RUNTIME_USE_REMOTE_DEBUGGING),port:parseInt(process.env.CHECKSUM_AGENT_RUNTIME_REMOTE_DEBUGGING_PORT??"9500")},testRun:{timeMachine:{headless:!V(process.env.CHECKSUM_RUNTIME_SHOW_RUNTIME_TIME_MACHINE),recordRRwebEventsToFile:V(process.env.CHECKSUM_RUNTIME_RECORD_RRWEB_EVENTS_TO_FILE,{default:!0}),maxRRwebBytes:So},monitoring:{debugAnalytics:_o,logToConsole:bo,segment:{writeKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_WRITE_KEY??"TMuP8uorDj4QzJfNs0gEHDO7kHozVBOo",devWriteKey:process.env.CHECKSUM_RUNTIME_MONITORING_SEGMENT_DEV_WRITE_KEY??"gofHHwvdNHJNmb7KqACUmypZclVHEQ2l"}},autoRecovery:{verboseConsoleLog:V(process.env.CHECKSUM_RUNTIME_AUTO_RECOVERY_CONSOLE_LOG,{default:!1}),sessionTimeout:18e4},disableAutoRecovery:V(process.env.CHECKSUM_RUNTIME_DISABLE_AUTO_RECOVERY),disableHostReports:V(process.env.CHECKSUM_RUNTIME_DISABLE_HOST_REPORTS),disableTimeMachine:V(process.env.CHECKSUM_RUNTIME_DISABLE_TIME_MACHINE),disableRrwebRecording:V(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 Cl=require("@playwright/test/reporter");var ee=require("path");var nt=s((e,t,r)=>`v2:${Io(e)}::${JSON.stringify([...t,r])}`,"computeVariantKey"),Io=s(e=>(e??"").replace(/\\/g,"/"),"normalizeFilePath");var we=require("fs"),B=se(require("typescript"));var ot=5,ce={mint(){return Rt(ot)},parse(e){let t=ce.tryParse(e);if(t===null)throw new TypeError(`Not a usable checksumTestId: ${JSON.stringify(e)}`);return t},tryParse(e){return typeof e!="string"||e.trim()===""?null:e},isSame(e,t){return e===t}};var _r=" - ",br=/(?:\.fix)?\.checksum\.(?:(?:spec|test)\.(?:ts|js|tsx|jsx)|md)$/i,Ro=/^[A-Za-z0-9_-]+$/,Mo=new RegExp(`^[0-9A-Za-z]{${ot}}$`);function Sr(e){return Ao(e).id}s(Sr,"readTestIdFromFileName");function Ao(e){let t=Co(e);if(t===null)return{title:Ir(e),id:null};let r=t.lastIndexOf(_r);if(r===-1)return{title:t,id:Mo.test(t)?ce.tryParse(t):null};let n=t.slice(r+_r.length);return Ro.test(n)?{title:t.slice(0,r),id:ce.tryParse(n)}:{title:t,id:null}}s(Ao,"splitFileName");function Ir(e){let t=e.replace(/\\/g,"/");return t.slice(t.lastIndexOf("/")+1)}s(Ir,"basename");function Co(e){let t=Ir(e);return br.test(t)?t.replace(br,""):null}s(Co,"stemOf");var st=class{static{s(this,"FileContentReader")}read(t,r){if(!(!t||!(0,we.existsSync)(t)))try{let n=(0,we.readFileSync)(t,"utf-8"),o=B.createSourceFile(t,n,B.ScriptTarget.Latest,!0),a=new Map,i=s(c=>{if(B.isCallExpression(c)&&this.isTestCall(c.expression)){let d=c.arguments[0];if(d&&B.isCallExpression(d)&&B.isIdentifier(d.expression)&&d.expression.text==="defineChecksumTest"){let m=this.extractDefineChecksumTestArgs(d);m&&a.set(m.testTitle,m.checksumTestId)}}B.forEachChild(c,i)},"visit");return i(o),r&&a.has(r)?a.get(r):a.size>0?Array.from(a.values())[0]:void 0}catch{return}}isTestCall(t){return B.isIdentifier(t)&&t.text==="test"?!0:B.isPropertyAccessExpression(t)?B.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),i=ce.tryParse(this.extractStringLiteral(o));if(a&&i)return{testTitle:a,checksumTestId:i}}extractStringLiteral(t){if(B.isStringLiteral(t)||B.isNoSubstitutionTemplateLiteral(t))return t.text}},xo=new st;function Rr(e,t){return xo.read(e,t)??Sr(e)??void 0}s(Rr,"extractChecksumTestId");function Oe(e,t){return t.pwTestIdToChecksumTestId[e.playwrightTestId]||(e.filePath!==void 0?Rr(e.filePath,e.title):void 0)}s(Oe,"resolveChecksumTestId");var Mr=s((e,t)=>Object.values(t[e]??{}).some(r=>r.autoRecoveryMetadata?.data?.autoRecovered),"isAutoRecovered"),it=s(e=>typeof e=="number"&&!isNaN(e)?e:0,"getStat");function at(e,t,r){let n=[],o=0,a=0,i=it(t.expected)+it(t.flaky),c=it(t.unexpected);for(let d of e){let m=vo(d,r);n.push(m),m.recovered&&a++,m.bug&&(o++,m.outcome==="expected"||m.outcome==="flaky"?i--:m.outcome==="unexpected"&&c--)}return{passed:i,failed:c,bug:o,recovered:a,tests:n}}s(at,"computeReportStats");function vo(e,t){let r=Oe({playwrightTestId:e.playwrightTestId,filePath:e.filePath,title:e.title},t),n=No(e),o=wo(e.annotations),a=Mr(e.playwrightTestId,t.playwrightIdToMetadata),i=Oo(r,e,t),c=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:nt(e.filePath,e.titlePath,e.title),...e.filePath!==void 0?{filePath:e.filePath}:{},...c!==void 0?{relativeFilePath:c}:{},...e.projectName?{project:e.projectName}:{},...e.errorMessage?{errorMessage:e.errorMessage}:{},...i!==void 0?{usingChecksumTestIdPlaceholder:i}:{}}}s(vo,"rowToTestWithMetadata");function Ar(e,t){let r=e.files,n=s(c=>{let m=Oe({playwrightTestId:c.testId,filePath:c.location.file,title:c.title},t)??`${c.location.file}::${c.title}`,y=nt(c.location.file,c.path??[],c.title);return`${m}::${c.projectName}::${y}`},"keyFor"),o=new Map;for(let c of r)for(let d of c.tests)o.set(n(d),d);let a=new Set(o.values()),i={total:0,expected:0,unexpected:0,flaky:0,skipped:0};for(let c of r){c.tests=c.tests.filter(d=>a.has(d));for(let d of c.tests)i.total++,d.outcome==="expected"?i.expected++:d.outcome==="unexpected"?i.unexpected++:d.outcome==="flaky"?i.flaky++:i.skipped++}e.files=r.filter(c=>c.tests.length>0),e.stats={...e.stats,...i}}s(Ar,"dedupeReportByChecksumTestId");var No=s(e=>e.tags.includes("bug")||e.annotations.some(t=>t.type==="bug")||e.title.includes("@bug"),"detectBug"),wo=s(e=>e.filter(t=>!!t?.type).map(t=>({type:t.type,description:t.description||""})),"normalizeAnnotations"),Oo=s((e,t,r)=>{if(r.checksumTestIdToUsingPlaceholder)return r.pwTestIdToChecksumTestId[t.playwrightTestId]&&r.checksumTestIdToUsingPlaceholder[e]||!1},"computeUsingPlaceholder");var de=s(e=>e.replace(/\\/g,"/"),"toPosix"),Do=s(e=>/^[A-Za-z]:/.test(e),"isWindowsAbsolute"),Cr=s((e,t,r,n)=>{if(!e)return;let o=de(r||t),a=de(e),i=de(n||(0,ee.dirname)(t)),c=(0,ee.isAbsolute)(a)||Do(a)?a:de((0,ee.resolve)(i,a)),d=de((0,ee.relative)(o,c));return d&&!d.startsWith("..")?d:c},"toRelativeFilePath");var xr=require("node:util");var ue=8*1024,_e=`
4
+ \u2026 [truncated]`,Lo=/[\u001b\u0080-\u009f]/g;function lt(e){let t=e.replaceAll("\0","");return Po((0,xr.stripVTControlCharacters)(t))}s(lt,"sanitizeTestErrorMessage");function Po(e){return e.replace(Lo,"")}s(Po,"removeResidualVTControls");function De(e){let t=lt(e);if(Buffer.byteLength(t,"utf8")<=ue)return{value:t,truncated:!1};let r=ue-Buffer.byteLength(_e,"utf8"),n="",o=0;for(let a of t){let i=Buffer.byteLength(a,"utf8");if(o+i>r)break;n+=a,o+=i}return{value:n+_e,truncated:!0}}s(De,"boundTestErrorMessage");var Nr=require("node:crypto");var Uo=new Set(["failed","timedOut","interrupted"]),ct=new WeakMap;function wr(){let e={messages:new Map,ambiguousKeys:new Set,truncatedCount:0,identityConflictCount:0};return ct.set(e,new Map),e}s(wr,"createErrorDetailIndex");function Or(e,t){try{let r=Fo(e);if(!r||ko(r.tests))return!1;for(let n of r.tests){if(!pe(n))continue;let o=Fr(n.projectName),a=n.testId;if(o===void 0||!Le(a))continue;let i=Bo(n);if(!i)continue;let c=Go(i);c.truncated&&(t.truncatedCount+=1),zo(t,Ur(r.fileId,o,a),c.value,$o(i))}return!0}catch{return!1}}s(Or,"addTestFileErrorDetails");function Dr(e){return pe(e)&&Object.prototype.hasOwnProperty.call(e,"fileId")&&Object.prototype.hasOwnProperty.call(e,"tests")}s(Dr,"isTestFileErrorDetailCandidate");function Lr(e,t,r,n){let o=Fr(r);if(!Le(t)||o===void 0||!Le(n))return;let a=Ur(t,o,n);if(!e.ambiguousKeys.has(a))return e.messages.get(a)}s(Lr,"getTestErrorMessage");function Fo(e){if(!pe(e))return;let t=e.fileId,r=e.tests;if(!(!Le(t)||!Array.isArray(r)))return{fileId:t,tests:r}}s(Fo,"parseTestFile");function ko(e){return e.length>0&&!e.some(pe)}s(ko,"hasOnlyMalformedTests");function Bo(e){let t=e.results;if(!Array.isArray(t))return;let r=t.at(-1);if(!pe(r))return;let n=r.status;if(typeof n!="string"||!Uo.has(n))return;let o=r.errors;if(Array.isArray(o))for(let a of o){let i=Ho(a);if(i)return i}}s(Bo,"extractFinalErrorDetail");function Ho(e){if(typeof e=="string"){let n=Pr(e);return n?{message:n}:void 0}if(!pe(e))return;let t=vr(e.message,e.value),r=vr(e.codeframe,e.snippet);return t?!r||t.includes(r)?{message:t}:{message:t,frame:r}:r?{frame:r}:void 0}s(Ho,"normalizeError");function Go(e){let{message:t,frame:r}=e;if(!t)return De(r??"");if(!r)return De(t);let n=Buffer.byteLength(t,"utf8");if(n>ue)return De(t);let o=`
5
5
 
6
6
  `,a=Buffer.byteLength(o,"utf8"),i=Buffer.byteLength(r,"utf8");if(n+a+i<=ue)return{value:`${t}${o}${r}`,truncated:!1};let c=a+Buffer.byteLength(_e,"utf8"),d=ue-n;if(d<c)return{value:t,truncated:!0};let m=Wo(r,d-c);return{value:`${t}${o}${m}${_e}`,truncated:!0}}s(Go,"boundNormalizedErrorDetail");function Wo(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}s(Wo,"utf8Prefix");function $o(e){let t=(0,Nr.createHash)("sha256");return e.message&&t.update(e.message,"utf8"),e.message&&e.frame&&t.update(`
7
7
 
8
- `,"utf8"),e.frame&&t.update(e.frame,"utf8"),t.digest("hex")}s($o,"digestNormalizedErrorDetail");function Pr(e){let t=lt(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,"")}s(Pr,"normalizeErrorText");function zo(e,t,r,n){if(e.ambiguousKeys.has(t))return;let o=ct.get(e);if(o||(o=new Map,ct.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)}s(zo,"addErrorDetail");function Ur(e,t,r){return JSON.stringify([e,t,r])}s(Ur,"createIdentityKey");function vr(...e){for(let t of e){if(typeof t!="string")continue;let r=Pr(t);if(r)return r}}s(vr,"firstMeaningfulString");function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(pe,"isRecord");function Fr(e){return e==null||e===""?"":typeof e=="string"?e:void 0}s(Fr,"normalizeProjectName");function Oe(e){return typeof e=="string"&&e.length>0}s(Oe,"isNonEmptyString");var Vo=s(e=>Number.isSafeInteger(e)&&e>=0?Math.min(e,8388608):0,"effectiveErrorDetailsPayloadBudgetBytes"),Ko=s(e=>Buffer.byteLength(`,"errorMessage":${JSON.stringify(e)}`,"utf8"),"serializedErrorMessagePropertyBytes");function kr(e,t=8388608){let r=Vo(t),n=0,o=e.tests?.map(a=>{if(a.errorMessage===void 0)return a;let i=Ko(a.errorMessage);if(i<=r)return r-=i,a;n+=1;let c={...a};return delete c.errorMessage,c});return{stats:{...e,...o!==void 0?{tests:o}:{}},omittedCount:n}}s(kr,"applyErrorDetailsPayloadBudget");var Br=s(e=>Lt.includes(e),"isPayloadTag"),Zo=s((e,t)=>e.files.flatMap(r=>r.tests.map(n=>{let o=t?Or(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"),Pe=class e{constructor(t,r,n,o={},a={},i,c,d,m={},y){this.reportHTMLFilePath=t;this.testRunUUID=r;this.pwTestIdToChecksumTestId=n;this.playwrightIdToMetadata=o;this.channel=i;this.checksumTestIdToUsingPlaceholder=m;this.playwrightRootDir=y;this.config={hosted:!0,assetsBaseURL:"https://api.checksum.ai/api/test-runs"};this.config={...this.config,...a},this.checksumRoot=c||(0,ne.dirname)((0,ne.dirname)(t)),this.projectRoot=d||this.checksumRoot}static{s(this,"PlaywrightReportProcessor")}static{this.templateCache=null}async process(){let t=0;try{t=(0,H.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,ne.join)((0,Wr.tmpdir)(),`pw-report-${(0,$r.randomUUID)()}.zip`),n=s(()=>{try{(0,H.existsSync)(r)&&(0,H.unlinkSync)(r)}catch{}},"cleanupFile"),o={sigterm:s(()=>{n(),process.exit(143)},"sigterm"),sigint:s(()=>{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 i=Date.now()-a;this.channel.debug("Modifying ZIP file...");let c=Date.now(),d=this.modifyZipFile(r),m=Date.now()-c;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:i,modify_ms:m,write_ms:T,entry_count:d.entryCount,json_entry_count:d.jsonEntryCount,largest_entry_bytes:d.largestEntryBytes,largest_entry_name:d.largestEntryName,error_details_extracted:d.errorDetailsExtracted,error_details_truncated:d.errorDetailsTruncated,error_detail_parse_failures:d.errorDetailParseFailures,error_detail_identity_conflicts:d.errorDetailIdentityConflicts,error_details_payload_budget_omitted:d.errorDetailsPayloadBudgetOmitted}}finally{process.removeListener("SIGTERM",o.sigterm),process.removeListener("SIGINT",o.sigint),process.removeListener("exit",o.exit);try{(0,H.existsSync)(r)&&(0,H.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,i=!1,c=[],d=0,m=(0,H.createWriteStream)(t);m.on("error",_=>{if(!a){a=!0;try{R.destroyed||R.destroy(),T.end()}catch{}n(_)}});let y=s(()=>{if(d<4)return;let _=c.join("");c.length=0,i||(_=_.replace("data:application/zip;base64,",""),i=!0);let u=Math.floor(_.length/4)*4,f=_.slice(0,u),p=_.slice(u);if(p.length>0?(c.push(p),d=p.length):d=0,f.length>0){let h=Buffer.from(f,"base64");m.write(h)}},"flushBuffer"),T=new Hr.Parser({onopentag:s((_,u)=>{Br(_)&&u.id==="playwrightReportBase64"&&(o=!0)},"onopentag"),ontext:s(_=>{o&&(c.push(_),d+=_.length,d>1024*1024&&y())},"ontext"),onclosetag:s(_=>{if(Br(_)&&o&&!a){if(a=!0,d>0){let u=c.join("");if(i||(u=u.replace("data:application/zip;base64,","")),u.length>0){let f=Buffer.from(u,"base64");m.write(f)}}try{R.destroyed||R.destroy()}catch{}m.end(()=>r())}},"onclosetag"),onerror:s(_=>{if(!a){a=!0;try{T.end(),R.destroyed||R.destroy(),m.destroyed||m.destroy()}catch{}n(_)}},"onerror")}),R=(0,H.createReadStream)(this.reportHTMLFilePath,{encoding:"utf8"});R.on("data",_=>T.write(_.toString())),R.on("end",()=>{if(T.end(),!a){a=!0;try{m.destroyed||m.destroy()}catch{}n(new Error("Could not find playwrightReportBase64 in HTML"))}}),R.on("error",_=>{if(!a){a=!0;try{T.end(),m.destroyed||m.destroy()}catch{}n(_)}})})}modifyZipFile(t){let r=new Gr.default(t),n=r.getEntries(),o=wr(),a,i,c=0,d=0,m=0,y="";for(let R of n){if(R.isDirectory||!R.entryName.endsWith(".json"))continue;let _=R.getData().toString("utf8");if(d+=1,_.length>m&&(m=_.length,y=R.entryName),R.entryName==="report.json")a=JSON.parse(_),i=R;else{let u=this.replaceAttachmentPaths(_);R.setData(Buffer.from(u,"utf8"));try{let f=JSON.parse(u);Lr(f)&&!Dr(f,o)&&(c+=1)}catch{c+=1}}}if(!a||!i)throw new Error("report.json not found in ZIP file");this.config.dedupeByChecksumTestId&&Mr(a,{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId}),this.handleReportJSON(a),this.report=a;let T=this.extractStats(a,o);return i.setData(Buffer.from(JSON.stringify(a),"utf8")),r.writeZip(t),{entryCount:n.length,jsonEntryCount:d,largestEntryBytes:m,largestEntryName:y,errorDetailsExtracted:o.messages.size,errorDetailsTruncated:o.truncatedCount,errorDetailParseFailures:c,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,H.copyFileSync)(n,o);let a=(0,H.createWriteStream)(n);await new Promise((i,c)=>{a.on("error",c),a.write(r),a.write(Ot+"data:application/zip;base64,");let d=(0,H.createReadStream)(t,{highWaterMark:3*1024*1024});d.on("data",m=>{let T=(typeof m=="string"?Buffer.from(m):m).toString("base64");a.write(T)||d.pause()}),a.on("drain",()=>{d.resume()}),d.on("end",()=>{a.write(Pt),a.end(()=>i())}),d.on("error",m=>{try{a.destroyed||a.destroy()}catch{}c(m)}),a.on("error",m=>{try{d.destroyed||d.destroy()}catch{}c(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=s(a=>a.some(i=>i.attachments?.some(c=>c.name==="trace")),"hasTrace");for(let a of this.report.files)for(let i of a.tests)if(i.testId===n&&i.projectName===r&&o(i.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,H.readFileSync)(Ne.playwrightReporter.htmlReportTemplatePath,"utf-8")),e.templateCache}getReportsStats(){return this.stats}extractStats(t,r){if(!t.stats)return 0;let n=at(Zo(t,r),t.stats,{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId,playwrightIdToMetadata:this.playwrightIdToMetadata,checksumTestIdToUsingPlaceholder:this.checksumTestIdToUsingPlaceholder,toRelativeFilePath:s(a=>Cr(a,this.checksumRoot,this.projectRoot,this.playwrightRootDir),"toRelativeFilePath")}),o=kr(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,ne.basename)(t)}`:t}handleReportJSON(t){let r={},n=s(o=>{let a=o.testId,i=this.playwrightIdToMetadata[a];i&&(r[a]=i);let c=De({playwrightTestId:o.testId,filePath:o.location.file,title:o.title},{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId});c!==void 0&&(o.checksumTestId=c),o.results.forEach(d=>{this.processAttachments(d.attachments)})},"getChecksumMetadataForPWTestId");t.files.forEach(o=>{o.tests.forEach(n)}),t.checksumMetadata=r}processAttachments(t){t.forEach(n=>this.updateAttachment(n));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 dt={trace:"application/zip","trace-backup-file":"application/zip",har:"application/zip",report:"text/html","rrweb-recording":"application/json"},ql={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},Jo={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"},Xl=Object.fromEntries(Object.entries(Jo).map(e=>e.reverse()));var Ql={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 Ge=require("fs"),ln=require("path"),cn=require("stream");var zr=s(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 ut=require("fs");var Vr="\x1B[31m",Yo="\x1B[33m",qo="\x1B[32m",Xo="\x1B[36m",Qo="\x1B[2m",es="\x1B[1m",be="\x1B[0m",ts=s(()=>{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"),rs=new Set(["severity","message","kind","timestamp","_startedAtMs"]),ns=s(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"),os=s(e=>e==="ERROR"||e==="CRITICAL"?Vr:e==="WARNING"?Yo:qo,"colorForSeverity"),ss=s(e=>{let t=String(e.severity??"INFO"),r=`${os(t)}${t.padEnd(5)}${be}`,n=e.kind?`${Xo}${e.kind}${be}`:"",o=String(e.message??""),a=e.error&&typeof e.error=="object"?(()=>{let y=e.error;return` ${Vr}${y.type??"Error"}: ${y.message??""}${be}`})():"",i=["outcome","test_suite_run_id","status"],c=Object.entries(e).filter(([y,T])=>!rs.has(y)&&T!=null&&y!=="error"&&typeof T!="object"),d=s(y=>{let T=i.indexOf(y);return T===-1?i.length:T},"rank"),m=c.sort(([y],[T])=>d(y)-d(T)).slice(0,8).map(([y,T])=>`${Qo}${y}=${be}${T}`).join(" ");return[r,es+n+be,o,m,a].filter(y=>y&&y.trim()!=="").join(" ")},"formatPretty"),is=s(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"),Kr=s(e=>{let t=ts()?ss(e):ns(is(e));(0,ut.writeSync)(1,t+`
8
+ `,"utf8"),e.frame&&t.update(e.frame,"utf8"),t.digest("hex")}s($o,"digestNormalizedErrorDetail");function Pr(e){let t=lt(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,"")}s(Pr,"normalizeErrorText");function zo(e,t,r,n){if(e.ambiguousKeys.has(t))return;let o=ct.get(e);if(o||(o=new Map,ct.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)}s(zo,"addErrorDetail");function Ur(e,t,r){return JSON.stringify([e,t,r])}s(Ur,"createIdentityKey");function vr(...e){for(let t of e){if(typeof t!="string")continue;let r=Pr(t);if(r)return r}}s(vr,"firstMeaningfulString");function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(pe,"isRecord");function Fr(e){return e==null||e===""?"":typeof e=="string"?e:void 0}s(Fr,"normalizeProjectName");function Le(e){return typeof e=="string"&&e.length>0}s(Le,"isNonEmptyString");var Vo=s(e=>Number.isSafeInteger(e)&&e>=0?Math.min(e,8388608):0,"effectiveErrorDetailsPayloadBudgetBytes"),Ko=s(e=>Buffer.byteLength(`,"errorMessage":${JSON.stringify(e)}`,"utf8"),"serializedErrorMessagePropertyBytes");function kr(e,t=8388608){let r=Vo(t),n=0,o=e.tests?.map(a=>{if(a.errorMessage===void 0)return a;let i=Ko(a.errorMessage);if(i<=r)return r-=i,a;n+=1;let c={...a};return delete c.errorMessage,c});return{stats:{...e,...o!==void 0?{tests:o}:{}},omittedCount:n}}s(kr,"applyErrorDetailsPayloadBudget");var Br=s(e=>Dt.includes(e),"isPayloadTag"),Zo=s((e,t)=>e.files.flatMap(r=>r.tests.map(n=>{let o=t?Lr(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"),Pe=class e{constructor(t,r,n,o={},a={},i,c,d,m={},y){this.reportHTMLFilePath=t;this.testRunUUID=r;this.pwTestIdToChecksumTestId=n;this.playwrightIdToMetadata=o;this.channel=i;this.checksumTestIdToUsingPlaceholder=m;this.playwrightRootDir=y;this.config={hosted:!0,assetsBaseURL:"https://api.checksum.ai/api/test-runs"};this.config={...this.config,...a},this.checksumRoot=c||(0,ne.dirname)((0,ne.dirname)(t)),this.projectRoot=d||this.checksumRoot}static{s(this,"PlaywrightReportProcessor")}static{this.templateCache=null}async process(){let t=0;try{t=(0,H.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,ne.join)((0,Wr.tmpdir)(),`pw-report-${(0,$r.randomUUID)()}.zip`),n=s(()=>{try{(0,H.existsSync)(r)&&(0,H.unlinkSync)(r)}catch{}},"cleanupFile"),o={sigterm:s(()=>{n(),process.exit(143)},"sigterm"),sigint:s(()=>{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 i=Date.now()-a;this.channel.debug("Modifying ZIP file...");let c=Date.now(),d=this.modifyZipFile(r),m=Date.now()-c;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:i,modify_ms:m,write_ms:T,entry_count:d.entryCount,json_entry_count:d.jsonEntryCount,largest_entry_bytes:d.largestEntryBytes,largest_entry_name:d.largestEntryName,error_details_extracted:d.errorDetailsExtracted,error_details_truncated:d.errorDetailsTruncated,error_detail_parse_failures:d.errorDetailParseFailures,error_detail_identity_conflicts:d.errorDetailIdentityConflicts,error_details_payload_budget_omitted:d.errorDetailsPayloadBudgetOmitted}}finally{process.removeListener("SIGTERM",o.sigterm),process.removeListener("SIGINT",o.sigint),process.removeListener("exit",o.exit);try{(0,H.existsSync)(r)&&(0,H.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,i=!1,c=[],d=0,m=(0,H.createWriteStream)(t);m.on("error",_=>{if(!a){a=!0;try{R.destroyed||R.destroy(),T.end()}catch{}n(_)}});let y=s(()=>{if(d<4)return;let _=c.join("");c.length=0,i||(_=_.replace("data:application/zip;base64,",""),i=!0);let u=Math.floor(_.length/4)*4,f=_.slice(0,u),p=_.slice(u);if(p.length>0?(c.push(p),d=p.length):d=0,f.length>0){let h=Buffer.from(f,"base64");m.write(h)}},"flushBuffer"),T=new Hr.Parser({onopentag:s((_,u)=>{Br(_)&&u.id==="playwrightReportBase64"&&(o=!0)},"onopentag"),ontext:s(_=>{o&&(c.push(_),d+=_.length,d>1024*1024&&y())},"ontext"),onclosetag:s(_=>{if(Br(_)&&o&&!a){if(a=!0,d>0){let u=c.join("");if(i||(u=u.replace("data:application/zip;base64,","")),u.length>0){let f=Buffer.from(u,"base64");m.write(f)}}try{R.destroyed||R.destroy()}catch{}m.end(()=>r())}},"onclosetag"),onerror:s(_=>{if(!a){a=!0;try{T.end(),R.destroyed||R.destroy(),m.destroyed||m.destroy()}catch{}n(_)}},"onerror")}),R=(0,H.createReadStream)(this.reportHTMLFilePath,{encoding:"utf8"});R.on("data",_=>T.write(_.toString())),R.on("end",()=>{if(T.end(),!a){a=!0;try{m.destroyed||m.destroy()}catch{}n(new Error("Could not find playwrightReportBase64 in HTML"))}}),R.on("error",_=>{if(!a){a=!0;try{T.end(),m.destroyed||m.destroy()}catch{}n(_)}})})}modifyZipFile(t){let r=new Gr.default(t),n=r.getEntries(),o=wr(),a,i,c=0,d=0,m=0,y="";for(let R of n){if(R.isDirectory||!R.entryName.endsWith(".json"))continue;let _=R.getData().toString("utf8");if(d+=1,_.length>m&&(m=_.length,y=R.entryName),R.entryName==="report.json")a=JSON.parse(_),i=R;else{let u=this.replaceAttachmentPaths(_);R.setData(Buffer.from(u,"utf8"));try{let f=JSON.parse(u);Dr(f)&&!Or(f,o)&&(c+=1)}catch{c+=1}}}if(!a||!i)throw new Error("report.json not found in ZIP file");this.config.dedupeByChecksumTestId&&Ar(a,{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId}),this.handleReportJSON(a),this.report=a;let T=this.extractStats(a,o);return i.setData(Buffer.from(JSON.stringify(a),"utf8")),r.writeZip(t),{entryCount:n.length,jsonEntryCount:d,largestEntryBytes:m,largestEntryName:y,errorDetailsExtracted:o.messages.size,errorDetailsTruncated:o.truncatedCount,errorDetailParseFailures:c,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,H.copyFileSync)(n,o);let a=(0,H.createWriteStream)(n);await new Promise((i,c)=>{a.on("error",c),a.write(r),a.write(Lt+"data:application/zip;base64,");let d=(0,H.createReadStream)(t,{highWaterMark:3*1024*1024});d.on("data",m=>{let T=(typeof m=="string"?Buffer.from(m):m).toString("base64");a.write(T)||d.pause()}),a.on("drain",()=>{d.resume()}),d.on("end",()=>{a.write(Pt),a.end(()=>i())}),d.on("error",m=>{try{a.destroyed||a.destroy()}catch{}c(m)}),a.on("error",m=>{try{d.destroyed||d.destroy()}catch{}c(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=s(a=>a.some(i=>i.attachments?.some(c=>c.name==="trace")),"hasTrace");for(let a of this.report.files)for(let i of a.tests)if(i.testId===n&&i.projectName===r&&o(i.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,H.readFileSync)(Ne.playwrightReporter.htmlReportTemplatePath,"utf-8")),e.templateCache}getReportsStats(){return this.stats}extractStats(t,r){if(!t.stats)return 0;let n=at(Zo(t,r),t.stats,{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId,playwrightIdToMetadata:this.playwrightIdToMetadata,checksumTestIdToUsingPlaceholder:this.checksumTestIdToUsingPlaceholder,toRelativeFilePath:s(a=>Cr(a,this.checksumRoot,this.projectRoot,this.playwrightRootDir),"toRelativeFilePath")}),o=kr(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,ne.basename)(t)}`:t}handleReportJSON(t){let r={},n=s(o=>{let a=o.testId,i=this.playwrightIdToMetadata[a];i&&(r[a]=i);let c=Oe({playwrightTestId:o.testId,filePath:o.location.file,title:o.title},{pwTestIdToChecksumTestId:this.pwTestIdToChecksumTestId});c!==void 0&&(o.checksumTestId=c),o.results.forEach(d=>{this.processAttachments(d.attachments)})},"getChecksumMetadataForPWTestId");t.files.forEach(o=>{o.tests.forEach(n)}),t.checksumMetadata=r}processAttachments(t){t.forEach(n=>this.updateAttachment(n));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 dt={trace:"application/zip","trace-backup-file":"application/zip",har:"application/zip",report:"text/html","rrweb-recording":"application/json"},ql={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},Jo={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"},Xl=Object.fromEntries(Object.entries(Jo).map(e=>e.reverse()));var Ql={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 Ge=require("fs"),ln=require("path"),cn=require("stream");var zr=s(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 ut=require("fs");var Vr="\x1B[31m",Yo="\x1B[33m",qo="\x1B[32m",Xo="\x1B[36m",Qo="\x1B[2m",es="\x1B[1m",be="\x1B[0m",ts=s(()=>{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"),rs=new Set(["severity","message","kind","timestamp","_startedAtMs"]),ns=s(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"),os=s(e=>e==="ERROR"||e==="CRITICAL"?Vr:e==="WARNING"?Yo:qo,"colorForSeverity"),ss=s(e=>{let t=String(e.severity??"INFO"),r=`${os(t)}${t.padEnd(5)}${be}`,n=e.kind?`${Xo}${e.kind}${be}`:"",o=String(e.message??""),a=e.error&&typeof e.error=="object"?(()=>{let y=e.error;return` ${Vr}${y.type??"Error"}: ${y.message??""}${be}`})():"",i=["outcome","test_suite_run_id","status"],c=Object.entries(e).filter(([y,T])=>!rs.has(y)&&T!=null&&y!=="error"&&typeof T!="object"),d=s(y=>{let T=i.indexOf(y);return T===-1?i.length:T},"rank"),m=c.sort(([y],[T])=>d(y)-d(T)).slice(0,8).map(([y,T])=>`${Qo}${y}=${be}${T}`).join(" ");return[r,es+n+be,o,m,a].filter(y=>y&&y.trim()!=="").join(" ")},"formatPretty"),is=s(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"),Kr=s(e=>{let t=ts()?ss(e):ns(is(e));(0,ut.writeSync)(1,t+`
9
9
  `)},"emitEvent");var jr=s(e=>{(0,ut.writeSync)(2,e.endsWith(`
10
10
  `)?e:`${e}
11
- `)},"writeStderrLine");var as=s(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"),ls=s((e,t,r)=>{let n=Date.now(),o={timestamp:new Date().toISOString(),kind:e,...t},a=!1,i={set(c){return Object.assign(o,c),i},emit(c){a||(a=!0,c&&Object.assign(o,c),o.duration_ms===void 0&&(o.duration_ms=Date.now()-n),r(o))}};return i},"startHandle"),cs=s((e={})=>{let t=e.decide??(()=>!0),r=e.deriveMessage??as,n=e.label??"[wide-event]",o=e.sink??(c=>Kr(c)),a=s(c=>{if(!t(c))return;let d={severity:zr(c),message:c.message??r(c),...c};try{o(d)}catch(m){try{jr(`${n} emit failed: ${String(m)}`)}catch{}}},"emit");return{emit:a,emitWideEvent:s((c,d={})=>{a({timestamp:new Date().toISOString(),kind:c,...d})},"emitWideEvent"),wideEvent:s((c,d={})=>ls(c,d,a),"wideEvent"),configureSink:s(c=>{o=c},"configureSink")}},"createWideEvents"),Zr=s(e=>e==="true"||e==="1","truthy"),Jr=s(()=>Zr(process.env.CHECKSUM_WIDE_EVENTS)||Zr(process.env.WIDE_EVENT_PRETTY),"wideEventsEnabled"),pt=cs({decide:s(()=>Jr(),"decide")}),ft=pt.configureSink,fe=s((e,t={})=>pt.wideEvent(e,t),"wideEvent"),oe=s((e,t={})=>{pt.emitWideEvent(e,t)},"emitWideEvent"),J=s(e=>e instanceof Error?{type:e.name,message:e.message}:{type:"UnknownError",message:String(e)},"toErrorField");async function Yr(e,t){let r;try{r=await e.json()}catch{r=void 0}return ds({ok:e.ok,status:e.status,body:r},t)}s(Yr,"assertOkJson");function ds(e,t){let r=e.body&&typeof e.body=="object"?e.body:void 0;if(!e.ok){let o=us(r?.message);throw ps(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}s(ds,"assertJsonBody");function us(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>typeof t=="string").join("; "):""}s(us,"extractMessage");function ps(e,t){return Object.assign(e,{status:t})}s(ps,"withStatus");var Ue=s(e=>typeof e=="number"&&e>=400&&e<500&&e!==408&&e!==429,"isNonRetryableStatus");var Fe={uploadTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_TIMEOUT_MS",fallback:6e5,min:5e3,max:36e5},noProgressAbortMs:{env:"CHECKSUM_RUNTIME_UPLOAD_NO_PROGRESS_MS",fallback:6e4,min:5e3,max:6e5},assetDeadlineMs:{env:"CHECKSUM_RUNTIME_UPLOAD_ASSET_DEADLINE_MS",fallback:12e5,min:3e4,max:54e5},maxAttempts:{env:"CHECKSUM_RUNTIME_UPLOAD_MAX_ATTEMPTS",fallback:6,min:1,max:20},stallTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_STALL_TIMEOUT_MS",fallback:6e5,min:3e4,max:36e5},minProgressBytes:{env:"CHECKSUM_RUNTIME_UPLOAD_MIN_PROGRESS_BYTES",fallback:65536,min:1,max:67108864},finalizeBudgetMs:{env:"CHECKSUM_RUNTIME_UPLOAD_FINALIZE_BUDGET_MS",fallback:18e5,min:6e4,max:54e5},finalizeCeilingMs:{env:"CHECKSUM_RUNTIME_UPLOAD_FINALIZE_CEILING_MS",fallback:24e5,min:12e4,max:72e5},cliHardCapMs:{env:"CHECKSUM_RUNTIME_UPLOAD_CLI_HARD_CAP_MS",fallback:27e5,min:12e4,max:72e5},watchTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_WATCH_TIMEOUT_MS",fallback:12e4,min:5e3,max:18e5},ipcTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_IPC_TIMEOUT_MS",fallback:5e3,min:500,max:6e4},onEndFlushTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_ONEND_FLUSH_TIMEOUT_MS",fallback:5e3,min:500,max:6e4},resumableChunkBytes:{env:"CHECKSUM_RUNTIME_UPLOAD_RESUMABLE_CHUNK_BYTES",fallback:8388608,min:262144,max:268435456},connectTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_CONNECT_TIMEOUT_MS",fallback:1e4,min:1e3,max:6e4},headersTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_HEADERS_TIMEOUT_MS",fallback:3e5,min:5e3,max:18e5},bodyTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_BODY_TIMEOUT_MS",fallback:3e5,min:5e3,max:18e5},maxConcurrentUploads:{env:"CHECKSUM_RUNTIME_UPLOAD_MAX_CONCURRENT",fallback:15,min:1,max:64}};function fs(e,t,r,n){if(e===void 0||e.trim()==="")return t;let o=Number(e);return Number.isInteger(o)?Math.min(n,Math.max(r,o)):t}s(fs,"clampEnvInt");var ms=[["cliHardCapMs",["finalizeCeilingMs"],.9],["finalizeCeilingMs",["finalizeBudgetMs"],1],["finalizeBudgetMs",["stallTimeoutMs","assetDeadlineMs","watchTimeoutMs"],1],["assetDeadlineMs",["uploadTimeoutMs"],1],["uploadTimeoutMs",["noProgressAbortMs"],.5]];function gs(e){let t={...e},r=[];for(let[n,o,a]of ms)for(let i of o){let c=Math.floor(t[n]*a);t[i]>c&&(r.push(`${Fe[i].env} (${t[i]}ms) exceeds its bound under ${Fe[n].env} (${t[n]}ms); using ${c}ms`),t[i]=c)}return{tunables:t,warnings:r}}s(gs,"coerceScopeHierarchy");function mt(e){let t={};for(let r of Object.keys(Fe)){let n=Fe[r];t[r]=fs(e[n.env],n.fallback,n.min,n.max)}return t.resumableChunkBytes=Math.max(1,Math.floor(t.resumableChunkBytes/262144))*262144,gs(t)}s(mt,"resolveUploadTunablesDetailed");function hs(e){return mt(e).tunables}s(hs,"resolveUploadTunables");var qr=hs({});var Xr=new WeakMap,gt=new WeakMap;function Qr(e,t){e.loadedBytes=0,e.committedBytes??=0,e.lastProgress=t,Xr.set(e,e.committedBytes),gt.set(e,0)}s(Qr,"beginUpload");function ht(e){e.loadedBytes=0,gt.set(e,0)}s(ht,"resetAttemptBytes");var en=s(e=>(t,r,n,o)=>{let a=e.get(t)??0;return r-a<n?!1:(t.lastProgress=o,e.set(t,r),!0)},"stamperFor"),ys=en(gt),Es=en(Xr);function yt(e,t,r,n){return e.loadedBytes=t,ys(e,t,r,n)}s(yt,"recordSent");function Et(e,t,r,n){let o=Math.max(e.committedBytes??0,t);return e.committedBytes=o,Es(e,o,r,n)}s(Et,"recordCommitted");var Be=require("fs"),rn=require("stream");function ke(e,{baseMs:t,capMs:r,random:n=Math.random}){let o=Math.min(r,t*2**(e-1));return o/2+n()*(o/2)}s(ke,"jitteredBackoffMs");async function me(e){await e.body?.cancel().catch(()=>{})}s(me,"drainBody");var bt=s(e=>e===200||e===201,"isStored"),nn=s(e=>e===308,"isResumeIncomplete"),Ts=s(e=>e===404||e===410,"isSessionGoneStatus"),on=s((e,t)=>{let r=e?.match(/bytes=0-(\d+)/);return r?Number(r[1])+1:t},"nextOffsetFromRange"),_s=s((e,t,r)=>t<=e?`bytes */${r}`:`bytes ${e}-${t-1}/${r}`,"contentRangeFor");function bs(e,t,r){let n=t,o=new TransformStream({transform(a,i){n+=a.byteLength,r?.(n),i.enqueue(a)}});return rn.Readable.toWeb(e).pipeThrough(o)}s(bs,"countingBody");var Y=class extends Error{constructor(r,n){super(r);this.status=n;this.name="ResumableUploadError"}static{s(this,"ResumableUploadError")}},sn=s(e=>e instanceof Y?e.status:void 0,"statusOf"),Ss=s(e=>{let t=sn(e);return t!==void 0&&Ts(t)},"isSessionGone"),Is=s(e=>Ue(sn(e)),"isPermanent");async function Rs(e,t,r,n){let o=await r(e,{method:"POST",headers:{"x-goog-resumable":"start","Content-Type":t,"Content-Length":"0"},signal:n});if(await me(o),!bt(o.status))throw new Y(`resumable init failed with status ${o.status}`,o.status);let a=o.headers.get("Location");if(!a)throw new Y("resumable init returned no Location");return a}s(Rs,"initResumableSession");async function As(e,t,r,n){let o=await r(e,{method:"PUT",headers:{"Content-Range":`bytes */${t}`},signal:n});if(await me(o),bt(o.status))return{done:!0,offset:t};if(!nn(o.status))throw new Y(`offset query failed with status ${o.status}`,o.status);return{done:!1,offset:on(o.headers.get("Range"),0)}}s(As,"queryCommittedOffset");async function tn(e,t,{offset:r,endExclusive:n},o){let a=Math.max(0,(0,Be.statSync)(e.filePath).size-r),i=Math.min(Math.max(0,n-r),a),c=r+i,d=i>0?(0,Be.createReadStream)(e.filePath,{start:r,end:c-1}):void 0;try{let m={method:"PUT",headers:{"Content-Range":_s(r,c,e.size),"Content-Length":String(i)},duplex:"half",signal:o,...d?{body:bs(d,r,e.onSent)}:{}},y=await e.fetchImpl(t,m);if(await me(y),bt(y.status))return{stored:!0,committed:e.size};if(nn(y.status))return{stored:!1,committed:on(y.headers.get("Range"),r)};throw new Y(`resumable PUT failed with status ${y.status}`,y.status)}finally{d?.destroy()}}s(tn,"putChunk");async function Ms(e,t,r,n){let o=r;for(;o<e.size;){let i=Math.min(o+e.chunkSizeBytes,e.size),{stored:c,committed:d}=await tn(e,t,{offset:o,endExclusive:i},n);if(c){e.onCommitted?.(e.size);return}if(d<=o)throw new Y("resumable PUT made no forward progress");o=d,e.onCommitted?.(o)}let{stored:a}=await tn(e,t,{offset:e.size,endExclusive:e.size},n);if(!a)throw new Y("resumable upload did not finalize");e.onCommitted?.(e.size)}s(Ms,"sendFrom");async function Cs(e,t,r){if(t.url)return t.url;if(!e.target.initUrl)throw new Y("no resumable target provided");return t.url=await Rs(e.target.initUrl,e.contentType,e.fetchImpl,r),t.used=!1,t.url}s(Cs,"openSession");async function xs(e,t,r,n){if(!r)return 0;let o=await As(t,e.size,e.fetchImpl,n);if(!o.done)return e.onCommitted?.(o.offset),o.offset}s(xs,"resumePoint");async function vs(e,t,r){let n=await Cs(e,t,r),o=await xs(e,n,t.used,r);if(t.used=!0,o===void 0){e.onCommitted?.(e.size);return}await Ms(e,n,o,r)}s(vs,"runAttempt");function Ns(e,t,r){return Ss(e)&&t.target.initUrl?(r.url=void 0,r.used=!1,"retry"):Is(e)?"stop":"retry"}s(Ns,"afterFailure");async function an(e){let t={url:e.target.sessionUrl,used:!1},r;for(let n=1;n<=e.maxAttempts&&!(e.now()>=e.deadlineAt);n++)try{await vs(e,t,e.makeSignal());return}catch(o){if(r=o,Ns(o,e,t)==="stop"||n>=e.maxAttempts)break;await e.sleep(ke(n,{baseMs:1e3,capMs:16e3,...e.random?{random:e.random}:{}}))}throw r instanceof Error?r:new Y(`resumable upload failed: ${String(r)}`)}s(an,"uploadResumable");var ws=s(e=>{if(typeof e!="object"||e===null)return"network_error";let t="name"in e&&typeof e.name=="string"?e.name:"";if(t==="TimeoutError")return"timeout";if(t==="AbortError")return"no_progress_abort";let r="cause"in e?e.cause:void 0,n=typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="string"?r.code:void 0;if(n==="UND_ERR_CONNECT_TIMEOUT"||n==="UND_ERR_HEADERS_TIMEOUT"||n==="UND_ERR_BODY_TIMEOUT")return"timeout";if(n!==void 0&&n.length>0)return`network_error:${n}`;let o="message"in e&&typeof e.message=="string"?e.message:"";return o.startsWith("Upload failed with status")?"http_error":o.startsWith("get-upload-url")?"signed_url_error":o.includes("No upload URL")?"signed_url_missing":"network_error"},"classifyUploadError"),Ds=s(e=>Math.max(1e3,Math.min(1e4,Math.floor(e/4))),"noProgressPollMs"),He=class{constructor(t,r,n,o,a=!1,i={start:s(m=>{},"start"),complete:s(m=>{},"complete"),error:s((m,y)=>{},"error")},c,d={}){this.apiBaseURL=t;this.apiKey=r;this.uploadTimeout=n;this.makeGetUploadUrlAPIPath=o;this.isolationMode=a;this.reporter=i;this.sessionId=c;this.SIGNED_URL_TIMEOUT_MS=3e4;this.tunables=d.tunables??qr,this.fetchImpl=d.fetchImpl??globalThis.fetch,this.now=d.now??Date.now,this.MAX_ATTEMPTS=this.tunables.maxAttempts,this.PUT_NO_PROGRESS_ABORT_MS=this.tunables.noProgressAbortMs,this.ASSET_DEADLINE_MS=this.tunables.assetDeadlineMs,this.MIN_PROGRESS_BYTES=this.tunables.minProgressBytes}static{s(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(i=>{setTimeout(()=>{t.complete=!0,t.lastProgress=Date.now(),t.loadedBytes=100,i({statusCode:200,ok:!0,body:"OK"})},10)});return}let{path:r}=t.info,n=this.now()+this.ASSET_DEADLINE_MS,o=fe("asset_upload",{test_suite_run_id:this.sessionId,asset_type:t.info.type,file_name:t.info.fileName??(0,ln.basename)(r),test_id:t.info.testId,project:t.info.project}),a=[];try{let c=(0,Ge.statSync)(r).size;t.sizeBytes=c,Qr(t,this.now()),o.set({size_bytes:c}),this.reporter.start(r);let d;for(let m=1;m<=this.MAX_ATTEMPTS&&!(this.now()>=n);m++){let y={attempt:m};try{let T=this.now();if(await this.getSignedURLForUpload(t),y.signed_url_ms=this.now()-T,!t.uploadURL)throw new Error("No upload URL returned");let R=this.now();y.resumable=t.resumable===!0,t.resumable?await this.putResumable(t,r,c,n):await this.putWithWatchdog(t,r,c),y.put_ms=this.now()-R,y.loaded_bytes=t.loadedBytes,y.committed_bytes=t.committedBytes,a.push(y),this.reporter.complete(r),t.complete=!0,o.emit({outcome:"success",attempt_count:a.length,attempts:a,loaded_bytes:t.loadedBytes,committed_bytes:t.committedBytes});return}catch(T){d=T,y.loaded_bytes=t.loadedBytes,y.committed_bytes=t.committedBytes,y.failure_reason=ws(T),y.error=J(T);let R=Ue(typeof T=="object"&&T!==null&&"status"in T?T.status:void 0);y.non_retryable=R,delete t.uploadURL;let _=R?"non_retryable":t.resumable?"resumable_owns_retries":m>=this.MAX_ATTEMPTS?"max_attempts":this.now()>=n?"asset_deadline":void 0;if(y.retry_stop_reason=_,a.push(y),_)break;await this.backoff(m,n)}}this.reporter.error(r,d),t.error=!0,o.emit({outcome:"error",attempt_count:a.length,attempts:a,loaded_bytes:t.loadedBytes,committed_bytes:t.committedBytes,size_bytes:t.sizeBytes,deadline_exceeded:this.now()>=n,error:J(d)})}catch(i){this.reporter.error(r,i),t.error=!0,o.emit({outcome:"error",failure_reason:"pre_upload",attempt_count:a.length,attempts:a,error:J(i)})}}async putWithWatchdog(t,r,n){let o=t.uploadURL;if(!o)throw new Error("No upload URL returned");let a=new AbortController,i=this.uploadTimeout??void 0;ht(t);let c=this.armNoProgressWatchdog(t,()=>a.abort()),d=i!==void 0?setTimeout(()=>a.abort(new DOMException("upload attempt timeout","TimeoutError")),i):void 0,m=(0,Ge.createReadStream)(r),y=0,T=this.MIN_PROGRESS_BYTES,R=this.now,_=new TransformStream({transform(p,h){y+=p.byteLength,t.sizeBytes=n,yt(t,y,T,R()),h.enqueue(p)}}),u=cn.Readable.toWeb(m).pipeThrough(_),f={method:"PUT",headers:{"Content-Type":dt[t.info.type]??""},body:u,duplex:"half",signal:a.signal};try{let p=await this.fetchImpl(o,f);if(!p.ok)throw await me(p),Object.assign(new Error(`Upload failed with status ${p.status}`),{status:p.status});Et(t,n,this.MIN_PROGRESS_BYTES,this.now()),t.response=Promise.resolve(await p.text())}finally{clearInterval(c),clearTimeout(d),m.destroy()}}armNoProgressWatchdog(t,r){let n=-1,o=this.now();return setInterval(()=>{let a=Math.max(t.loadedBytes??0,t.committedBytes??0);a>n?(n=a,o=this.now()):this.now()-o>this.PUT_NO_PROGRESS_ABORT_MS&&r()},Ds(this.PUT_NO_PROGRESS_ABORT_MS))}async putResumable(t,r,n,o){let a=t.uploadURL;if(!a)throw new Error("No upload URL returned");ht(t);let i=this.uploadTimeout??this.tunables.uploadTimeoutMs,c,d,m=s(()=>(clearInterval(d),c=new AbortController,d=this.armNoProgressWatchdog(t,()=>c?.abort()),c.signal),"armAttempt");try{await an({target:{initUrl:a},filePath:r,size:n,contentType:dt[t.info.type]??"",fetchImpl:this.fetchImpl,makeSignal:s(()=>AbortSignal.any([m(),AbortSignal.timeout(i)]),"makeSignal"),maxAttempts:this.MAX_ATTEMPTS,deadlineAt:o,chunkSizeBytes:this.tunables.resumableChunkBytes,now:this.now,sleep:s(y=>new Promise(T=>setTimeout(T,y)),"sleep"),onSent:s(y=>yt(t,y,this.MIN_PROGRESS_BYTES,this.now()),"onSent"),onCommitted:s(y=>Et(t,y,this.MIN_PROGRESS_BYTES,this.now()),"onCommitted")})}finally{clearInterval(d)}t.response=Promise.resolve("OK")}async backoff(t,r){let n=ke(t,{baseMs:1e3,capMs:16e3}),o=Math.max(0,Math.min(n,r-this.now()));o>0&&await new Promise(a=>setTimeout(a,o))}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)}`,i={Accept:"application/json","Content-Type":"application/json",ChecksumAppCode:this.apiKey},c=await this.fetchImpl(a,{method:"POST",headers:i,body:o,signal:r.signal}),{url:d,resumable:m}=await Yr(c,{resource:"get-upload-url",requiredFields:["url"]});t.uploadURL=d,t.resumable=m===!0}catch(o){throw delete t.uploadURL,o}finally{clearTimeout(n)}}};function We(e,t,r=Date.now()){let n=e.filter(a=>!a.complete&&!a.error);if(n.length===0)return!1;let o=n.reduce((a,i)=>Math.max(a,i.lastProgress??0),0);return o>0&&r-o>t}s(We,"isUploadStalled");function $e(e,t,r){return e!==void 0&&r-e>t}s($e,"hasElapsedSinceTestEnd");function dn(e,t,r){return $e(t.testRunEndTime,t.finalizeBudgetMs,r)?!0:e===void 0?!1:e.complete||e.error?!0:We([e],t.stallTimeoutMs,r)}s(dn,"shouldStopWaitingForReport");function un(e){return e.abandonedAssets.length===0}s(un,"mayCleanUpSources");function Ls(e,t,r){if((t.length===0||We(e.assets,e.stallTimeoutMs,r))&&$e(e.testRunEndTime,e.finalizeBudgetMs,r))return"budget";if($e(e.testRunEndTime,e.finalizeCeilingMs,r))return"budget-ceiling"}s(Ls,"backstopReason");function pn(e,t){let r=e.assets.filter(a=>!a.complete&&!a.error),n=s(a=>({reason:a,abandonedAssets:r}),"decide"),o=Ls(e,r,t);if(o!==void 0)return n(o);if(!(e.processingInProgress||!e.doneWaitingForReport)&&!(r.length>0&&!We(e.assets,e.stallTimeoutMs,t))&&!(e.pendingWatchCount>0&&!$e(e.testRunEndTime,e.watchTimeoutMs,t)))return r.length>0?n("stall"):e.pendingWatchCount>0?n("watch-timeout"):n("complete")}s(pn,"decideFinalize");var fn=require("module");var Os=(0,fn.createRequire)(__filename);function mn(e){let t,r;try{t=Os("undici"),r=new t.Agent({connect:{timeout:e.connectTimeoutMs},headersTimeout:e.headersTimeoutMs,bodyTimeout:e.bodyTimeoutMs,keepAliveTimeout:1e4,keepAliveMaxTimeout:3e4})}catch(o){return oe("monitor_dispatcher_unavailable",{outcome:"error",error:J(o)}),process.emitWarning("@checksum-ai/runtime: undici dispatcher unavailable; upload timeouts fall back to the platform defaults",{detail:String(o)}),globalThis.fetch}let n=t.fetch;return(o,a)=>{let i={...a,dispatcher:r};return n(o,i)}}s(mn,"createMonitorFetch");var St=class{static{s(this,"CLIChannel")}constructor(){}sendToCLI(...t){let r=`{trm}${t.map(n=>n.toString()).join(`,
11
+ `)},"writeStderrLine");var as=s(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"),ls=s((e,t,r)=>{let n=Date.now(),o={timestamp:new Date().toISOString(),kind:e,...t},a=!1,i={set(c){return Object.assign(o,c),i},emit(c){a||(a=!0,c&&Object.assign(o,c),o.duration_ms===void 0&&(o.duration_ms=Date.now()-n),r(o))}};return i},"startHandle"),cs=s((e={})=>{let t=e.decide??(()=>!0),r=e.deriveMessage??as,n=e.label??"[wide-event]",o=e.sink??(c=>Kr(c)),a=s(c=>{if(!t(c))return;let d={severity:zr(c),message:c.message??r(c),...c};try{o(d)}catch(m){try{jr(`${n} emit failed: ${String(m)}`)}catch{}}},"emit");return{emit:a,emitWideEvent:s((c,d={})=>{a({timestamp:new Date().toISOString(),kind:c,...d})},"emitWideEvent"),wideEvent:s((c,d={})=>ls(c,d,a),"wideEvent"),configureSink:s(c=>{o=c},"configureSink")}},"createWideEvents"),Zr=s(e=>e==="true"||e==="1","truthy"),Jr=s(()=>Zr(process.env.CHECKSUM_WIDE_EVENTS)||Zr(process.env.WIDE_EVENT_PRETTY),"wideEventsEnabled"),pt=cs({decide:s(()=>Jr(),"decide")}),ft=pt.configureSink,fe=s((e,t={})=>pt.wideEvent(e,t),"wideEvent"),oe=s((e,t={})=>{pt.emitWideEvent(e,t)},"emitWideEvent"),J=s(e=>e instanceof Error?{type:e.name,message:e.message}:{type:"UnknownError",message:String(e)},"toErrorField");async function Yr(e,t){let r;try{r=await e.json()}catch{r=void 0}return ds({ok:e.ok,status:e.status,body:r},t)}s(Yr,"assertOkJson");function ds(e,t){let r=e.body&&typeof e.body=="object"?e.body:void 0;if(!e.ok){let o=us(r?.message);throw ps(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}s(ds,"assertJsonBody");function us(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>typeof t=="string").join("; "):""}s(us,"extractMessage");function ps(e,t){return Object.assign(e,{status:t})}s(ps,"withStatus");var Ue=s(e=>typeof e=="number"&&e>=400&&e<500&&e!==408&&e!==429,"isNonRetryableStatus");var Fe={uploadTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_TIMEOUT_MS",fallback:6e5,min:5e3,max:36e5},noProgressAbortMs:{env:"CHECKSUM_RUNTIME_UPLOAD_NO_PROGRESS_MS",fallback:6e4,min:5e3,max:6e5},assetDeadlineMs:{env:"CHECKSUM_RUNTIME_UPLOAD_ASSET_DEADLINE_MS",fallback:12e5,min:3e4,max:54e5},maxAttempts:{env:"CHECKSUM_RUNTIME_UPLOAD_MAX_ATTEMPTS",fallback:6,min:1,max:20},stallTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_STALL_TIMEOUT_MS",fallback:6e5,min:3e4,max:36e5},minProgressBytes:{env:"CHECKSUM_RUNTIME_UPLOAD_MIN_PROGRESS_BYTES",fallback:65536,min:1,max:67108864},finalizeBudgetMs:{env:"CHECKSUM_RUNTIME_UPLOAD_FINALIZE_BUDGET_MS",fallback:18e5,min:6e4,max:54e5},finalizeCeilingMs:{env:"CHECKSUM_RUNTIME_UPLOAD_FINALIZE_CEILING_MS",fallback:24e5,min:12e4,max:72e5},cliHardCapMs:{env:"CHECKSUM_RUNTIME_UPLOAD_CLI_HARD_CAP_MS",fallback:27e5,min:12e4,max:72e5},watchTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_WATCH_TIMEOUT_MS",fallback:12e4,min:5e3,max:18e5},ipcTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_IPC_TIMEOUT_MS",fallback:5e3,min:500,max:6e4},onEndFlushTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_ONEND_FLUSH_TIMEOUT_MS",fallback:5e3,min:500,max:6e4},resumableChunkBytes:{env:"CHECKSUM_RUNTIME_UPLOAD_RESUMABLE_CHUNK_BYTES",fallback:8388608,min:262144,max:268435456},connectTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_CONNECT_TIMEOUT_MS",fallback:1e4,min:1e3,max:6e4},headersTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_HEADERS_TIMEOUT_MS",fallback:3e5,min:5e3,max:18e5},bodyTimeoutMs:{env:"CHECKSUM_RUNTIME_UPLOAD_BODY_TIMEOUT_MS",fallback:3e5,min:5e3,max:18e5},maxConcurrentUploads:{env:"CHECKSUM_RUNTIME_UPLOAD_MAX_CONCURRENT",fallback:15,min:1,max:64}};function fs(e,t,r,n){if(e===void 0||e.trim()==="")return t;let o=Number(e);return Number.isInteger(o)?Math.min(n,Math.max(r,o)):t}s(fs,"clampEnvInt");var ms=[["cliHardCapMs",["finalizeCeilingMs"],.9],["finalizeCeilingMs",["finalizeBudgetMs"],1],["finalizeBudgetMs",["stallTimeoutMs","assetDeadlineMs","watchTimeoutMs"],1],["assetDeadlineMs",["uploadTimeoutMs"],1],["uploadTimeoutMs",["noProgressAbortMs"],.5]];function gs(e){let t={...e},r=[];for(let[n,o,a]of ms)for(let i of o){let c=Math.floor(t[n]*a);t[i]>c&&(r.push(`${Fe[i].env} (${t[i]}ms) exceeds its bound under ${Fe[n].env} (${t[n]}ms); using ${c}ms`),t[i]=c)}return{tunables:t,warnings:r}}s(gs,"coerceScopeHierarchy");function mt(e){let t={};for(let r of Object.keys(Fe)){let n=Fe[r];t[r]=fs(e[n.env],n.fallback,n.min,n.max)}return t.resumableChunkBytes=Math.max(1,Math.floor(t.resumableChunkBytes/262144))*262144,gs(t)}s(mt,"resolveUploadTunablesDetailed");function hs(e){return mt(e).tunables}s(hs,"resolveUploadTunables");var qr=hs({});var Xr=new WeakMap,gt=new WeakMap;function Qr(e,t){e.loadedBytes=0,e.committedBytes??=0,e.lastProgress=t,Xr.set(e,e.committedBytes),gt.set(e,0)}s(Qr,"beginUpload");function ht(e){e.loadedBytes=0,gt.set(e,0)}s(ht,"resetAttemptBytes");var en=s(e=>(t,r,n,o)=>{let a=e.get(t)??0;return r-a<n?!1:(t.lastProgress=o,e.set(t,r),!0)},"stamperFor"),ys=en(gt),Es=en(Xr);function yt(e,t,r,n){return e.loadedBytes=t,ys(e,t,r,n)}s(yt,"recordSent");function Et(e,t,r,n){let o=Math.max(e.committedBytes??0,t);return e.committedBytes=o,Es(e,o,r,n)}s(Et,"recordCommitted");var Be=require("fs"),rn=require("stream");function ke(e,{baseMs:t,capMs:r,random:n=Math.random}){let o=Math.min(r,t*2**(e-1));return o/2+n()*(o/2)}s(ke,"jitteredBackoffMs");async function me(e){await e.body?.cancel().catch(()=>{})}s(me,"drainBody");var bt=s(e=>e===200||e===201,"isStored"),nn=s(e=>e===308,"isResumeIncomplete"),Ts=s(e=>e===404||e===410,"isSessionGoneStatus"),on=s((e,t)=>{let r=e?.match(/bytes=0-(\d+)/);return r?Number(r[1])+1:t},"nextOffsetFromRange"),_s=s((e,t,r)=>t<=e?`bytes */${r}`:`bytes ${e}-${t-1}/${r}`,"contentRangeFor");function bs(e,t,r){let n=t,o=new TransformStream({transform(a,i){n+=a.byteLength,r?.(n),i.enqueue(a)}});return rn.Readable.toWeb(e).pipeThrough(o)}s(bs,"countingBody");var Y=class extends Error{constructor(r,n){super(r);this.status=n;this.name="ResumableUploadError"}static{s(this,"ResumableUploadError")}},sn=s(e=>e instanceof Y?e.status:void 0,"statusOf"),Ss=s(e=>{let t=sn(e);return t!==void 0&&Ts(t)},"isSessionGone"),Is=s(e=>Ue(sn(e)),"isPermanent");async function Rs(e,t,r,n){let o=await r(e,{method:"POST",headers:{"x-goog-resumable":"start","Content-Type":t,"Content-Length":"0"},signal:n});if(await me(o),!bt(o.status))throw new Y(`resumable init failed with status ${o.status}`,o.status);let a=o.headers.get("Location");if(!a)throw new Y("resumable init returned no Location");return a}s(Rs,"initResumableSession");async function Ms(e,t,r,n){let o=await r(e,{method:"PUT",headers:{"Content-Range":`bytes */${t}`},signal:n});if(await me(o),bt(o.status))return{done:!0,offset:t};if(!nn(o.status))throw new Y(`offset query failed with status ${o.status}`,o.status);return{done:!1,offset:on(o.headers.get("Range"),0)}}s(Ms,"queryCommittedOffset");async function tn(e,t,{offset:r,endExclusive:n},o){let a=Math.max(0,(0,Be.statSync)(e.filePath).size-r),i=Math.min(Math.max(0,n-r),a),c=r+i,d=i>0?(0,Be.createReadStream)(e.filePath,{start:r,end:c-1}):void 0;try{let m={method:"PUT",headers:{"Content-Range":_s(r,c,e.size),"Content-Length":String(i)},duplex:"half",signal:o,...d?{body:bs(d,r,e.onSent)}:{}},y=await e.fetchImpl(t,m);if(await me(y),bt(y.status))return{stored:!0,committed:e.size};if(nn(y.status))return{stored:!1,committed:on(y.headers.get("Range"),r)};throw new Y(`resumable PUT failed with status ${y.status}`,y.status)}finally{d?.destroy()}}s(tn,"putChunk");async function As(e,t,r,n){let o=r;for(;o<e.size;){let i=Math.min(o+e.chunkSizeBytes,e.size),{stored:c,committed:d}=await tn(e,t,{offset:o,endExclusive:i},n);if(c){e.onCommitted?.(e.size);return}if(d<=o)throw new Y("resumable PUT made no forward progress");o=d,e.onCommitted?.(o)}let{stored:a}=await tn(e,t,{offset:e.size,endExclusive:e.size},n);if(!a)throw new Y("resumable upload did not finalize");e.onCommitted?.(e.size)}s(As,"sendFrom");async function Cs(e,t,r){if(t.url)return t.url;if(!e.target.initUrl)throw new Y("no resumable target provided");return t.url=await Rs(e.target.initUrl,e.contentType,e.fetchImpl,r),t.used=!1,t.url}s(Cs,"openSession");async function xs(e,t,r,n){if(!r)return 0;let o=await Ms(t,e.size,e.fetchImpl,n);if(!o.done)return e.onCommitted?.(o.offset),o.offset}s(xs,"resumePoint");async function vs(e,t,r){let n=await Cs(e,t,r),o=await xs(e,n,t.used,r);if(t.used=!0,o===void 0){e.onCommitted?.(e.size);return}await As(e,n,o,r)}s(vs,"runAttempt");function Ns(e,t,r){return Ss(e)&&t.target.initUrl?(r.url=void 0,r.used=!1,"retry"):Is(e)?"stop":"retry"}s(Ns,"afterFailure");async function an(e){let t={url:e.target.sessionUrl,used:!1},r;for(let n=1;n<=e.maxAttempts&&!(e.now()>=e.deadlineAt);n++)try{await vs(e,t,e.makeSignal());return}catch(o){if(r=o,Ns(o,e,t)==="stop"||n>=e.maxAttempts)break;await e.sleep(ke(n,{baseMs:1e3,capMs:16e3,...e.random?{random:e.random}:{}}))}throw r instanceof Error?r:new Y(`resumable upload failed: ${String(r)}`)}s(an,"uploadResumable");var ws=s(e=>{if(typeof e!="object"||e===null)return"network_error";let t="name"in e&&typeof e.name=="string"?e.name:"";if(t==="TimeoutError")return"timeout";if(t==="AbortError")return"no_progress_abort";let r="cause"in e?e.cause:void 0,n=typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="string"?r.code:void 0;if(n==="UND_ERR_CONNECT_TIMEOUT"||n==="UND_ERR_HEADERS_TIMEOUT"||n==="UND_ERR_BODY_TIMEOUT")return"timeout";if(n!==void 0&&n.length>0)return`network_error:${n}`;let o="message"in e&&typeof e.message=="string"?e.message:"";return o.startsWith("Upload failed with status")?"http_error":o.startsWith("get-upload-url")?"signed_url_error":o.includes("No upload URL")?"signed_url_missing":"network_error"},"classifyUploadError"),Os=s(e=>Math.max(1e3,Math.min(1e4,Math.floor(e/4))),"noProgressPollMs"),He=class{constructor(t,r,n,o,a=!1,i={start:s(m=>{},"start"),complete:s(m=>{},"complete"),error:s((m,y)=>{},"error")},c,d={}){this.apiBaseURL=t;this.apiKey=r;this.uploadTimeout=n;this.makeGetUploadUrlAPIPath=o;this.isolationMode=a;this.reporter=i;this.sessionId=c;this.SIGNED_URL_TIMEOUT_MS=3e4;this.tunables=d.tunables??qr,this.fetchImpl=d.fetchImpl??globalThis.fetch,this.now=d.now??Date.now,this.MAX_ATTEMPTS=this.tunables.maxAttempts,this.PUT_NO_PROGRESS_ABORT_MS=this.tunables.noProgressAbortMs,this.ASSET_DEADLINE_MS=this.tunables.assetDeadlineMs,this.MIN_PROGRESS_BYTES=this.tunables.minProgressBytes}static{s(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(i=>{setTimeout(()=>{t.complete=!0,t.lastProgress=Date.now(),t.loadedBytes=100,i({statusCode:200,ok:!0,body:"OK"})},10)});return}let{path:r}=t.info,n=this.now()+this.ASSET_DEADLINE_MS,o=fe("asset_upload",{test_suite_run_id:this.sessionId,asset_type:t.info.type,file_name:t.info.fileName??(0,ln.basename)(r),test_id:t.info.testId,project:t.info.project}),a=[];try{let c=(0,Ge.statSync)(r).size;t.sizeBytes=c,Qr(t,this.now()),o.set({size_bytes:c}),this.reporter.start(r);let d;for(let m=1;m<=this.MAX_ATTEMPTS&&!(this.now()>=n);m++){let y={attempt:m};try{let T=this.now();if(await this.getSignedURLForUpload(t),y.signed_url_ms=this.now()-T,!t.uploadURL)throw new Error("No upload URL returned");let R=this.now();y.resumable=t.resumable===!0,t.resumable?await this.putResumable(t,r,c,n):await this.putWithWatchdog(t,r,c),y.put_ms=this.now()-R,y.loaded_bytes=t.loadedBytes,y.committed_bytes=t.committedBytes,a.push(y),this.reporter.complete(r),t.complete=!0,o.emit({outcome:"success",attempt_count:a.length,attempts:a,loaded_bytes:t.loadedBytes,committed_bytes:t.committedBytes});return}catch(T){d=T,y.loaded_bytes=t.loadedBytes,y.committed_bytes=t.committedBytes,y.failure_reason=ws(T),y.error=J(T);let R=Ue(typeof T=="object"&&T!==null&&"status"in T?T.status:void 0);y.non_retryable=R,delete t.uploadURL;let _=R?"non_retryable":t.resumable?"resumable_owns_retries":m>=this.MAX_ATTEMPTS?"max_attempts":this.now()>=n?"asset_deadline":void 0;if(y.retry_stop_reason=_,a.push(y),_)break;await this.backoff(m,n)}}this.reporter.error(r,d),t.error=!0,o.emit({outcome:"error",attempt_count:a.length,attempts:a,loaded_bytes:t.loadedBytes,committed_bytes:t.committedBytes,size_bytes:t.sizeBytes,deadline_exceeded:this.now()>=n,error:J(d)})}catch(i){this.reporter.error(r,i),t.error=!0,o.emit({outcome:"error",failure_reason:"pre_upload",attempt_count:a.length,attempts:a,error:J(i)})}}async putWithWatchdog(t,r,n){let o=t.uploadURL;if(!o)throw new Error("No upload URL returned");let a=new AbortController,i=this.uploadTimeout??void 0;ht(t);let c=this.armNoProgressWatchdog(t,()=>a.abort()),d=i!==void 0?setTimeout(()=>a.abort(new DOMException("upload attempt timeout","TimeoutError")),i):void 0,m=(0,Ge.createReadStream)(r),y=0,T=this.MIN_PROGRESS_BYTES,R=this.now,_=new TransformStream({transform(p,h){y+=p.byteLength,t.sizeBytes=n,yt(t,y,T,R()),h.enqueue(p)}}),u=cn.Readable.toWeb(m).pipeThrough(_),f={method:"PUT",headers:{"Content-Type":dt[t.info.type]??""},body:u,duplex:"half",signal:a.signal};try{let p=await this.fetchImpl(o,f);if(!p.ok)throw await me(p),Object.assign(new Error(`Upload failed with status ${p.status}`),{status:p.status});Et(t,n,this.MIN_PROGRESS_BYTES,this.now()),t.response=Promise.resolve(await p.text())}finally{clearInterval(c),clearTimeout(d),m.destroy()}}armNoProgressWatchdog(t,r){let n=-1,o=this.now();return setInterval(()=>{let a=Math.max(t.loadedBytes??0,t.committedBytes??0);a>n?(n=a,o=this.now()):this.now()-o>this.PUT_NO_PROGRESS_ABORT_MS&&r()},Os(this.PUT_NO_PROGRESS_ABORT_MS))}async putResumable(t,r,n,o){let a=t.uploadURL;if(!a)throw new Error("No upload URL returned");ht(t);let i=this.uploadTimeout??this.tunables.uploadTimeoutMs,c,d,m=s(()=>(clearInterval(d),c=new AbortController,d=this.armNoProgressWatchdog(t,()=>c?.abort()),c.signal),"armAttempt");try{await an({target:{initUrl:a},filePath:r,size:n,contentType:dt[t.info.type]??"",fetchImpl:this.fetchImpl,makeSignal:s(()=>AbortSignal.any([m(),AbortSignal.timeout(i)]),"makeSignal"),maxAttempts:this.MAX_ATTEMPTS,deadlineAt:o,chunkSizeBytes:this.tunables.resumableChunkBytes,now:this.now,sleep:s(y=>new Promise(T=>setTimeout(T,y)),"sleep"),onSent:s(y=>yt(t,y,this.MIN_PROGRESS_BYTES,this.now()),"onSent"),onCommitted:s(y=>Et(t,y,this.MIN_PROGRESS_BYTES,this.now()),"onCommitted")})}finally{clearInterval(d)}t.response=Promise.resolve("OK")}async backoff(t,r){let n=ke(t,{baseMs:1e3,capMs:16e3}),o=Math.max(0,Math.min(n,r-this.now()));o>0&&await new Promise(a=>setTimeout(a,o))}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)}`,i={Accept:"application/json","Content-Type":"application/json",ChecksumAppCode:this.apiKey},c=await this.fetchImpl(a,{method:"POST",headers:i,body:o,signal:r.signal}),{url:d,resumable:m}=await Yr(c,{resource:"get-upload-url",requiredFields:["url"]});t.uploadURL=d,t.resumable=m===!0}catch(o){throw delete t.uploadURL,o}finally{clearTimeout(n)}}};function We(e,t,r=Date.now()){let n=e.filter(a=>!a.complete&&!a.error);if(n.length===0)return!1;let o=n.reduce((a,i)=>Math.max(a,i.lastProgress??0),0);return o>0&&r-o>t}s(We,"isUploadStalled");function $e(e,t,r){return e!==void 0&&r-e>t}s($e,"hasElapsedSinceTestEnd");function dn(e,t,r){return $e(t.testRunEndTime,t.finalizeBudgetMs,r)?!0:e===void 0?!1:e.complete||e.error?!0:We([e],t.stallTimeoutMs,r)}s(dn,"shouldStopWaitingForReport");function un(e){return e.abandonedAssets.length===0}s(un,"mayCleanUpSources");function Ds(e,t,r){if((t.length===0||We(e.assets,e.stallTimeoutMs,r))&&$e(e.testRunEndTime,e.finalizeBudgetMs,r))return"budget";if($e(e.testRunEndTime,e.finalizeCeilingMs,r))return"budget-ceiling"}s(Ds,"backstopReason");function pn(e,t){let r=e.assets.filter(a=>!a.complete&&!a.error),n=s(a=>({reason:a,abandonedAssets:r}),"decide"),o=Ds(e,r,t);if(o!==void 0)return n(o);if(!(e.processingInProgress||!e.doneWaitingForReport)&&!(r.length>0&&!We(e.assets,e.stallTimeoutMs,t))&&!(e.pendingWatchCount>0&&!$e(e.testRunEndTime,e.watchTimeoutMs,t)))return r.length>0?n("stall"):e.pendingWatchCount>0?n("watch-timeout"):n("complete")}s(pn,"decideFinalize");var fn=require("module");var Ls=(0,fn.createRequire)(__filename);function mn(e){let t,r;try{t=Ls("undici"),r=new t.Agent({connect:{timeout:e.connectTimeoutMs},headersTimeout:e.headersTimeoutMs,bodyTimeout:e.bodyTimeoutMs,keepAliveTimeout:1e4,keepAliveMaxTimeout:3e4})}catch(o){return oe("monitor_dispatcher_unavailable",{outcome:"error",error:J(o)}),process.emitWarning("@checksum-ai/runtime: undici dispatcher unavailable; upload timeouts fall back to the platform defaults",{detail:String(o)}),globalThis.fetch}let n=t.fetch;return(o,a)=>{let i={...a,dispatcher:r};return n(o,i)}}s(mn,"createMonitorFetch");var St=class{static{s(this,"CLIChannel")}constructor(){}sendToCLI(...t){let r=`{trm}${t.map(n=>n.toString()).join(`,
12
12
  `)}{/trm}`;process.stdout.write(`${r}
13
- `)}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}`)}},ze=class{constructor(t,r=!1){this.config=t;this.isolationMode=r;this.tunablesResolution=mt(process.env);this.tunables=this.tunablesResolution.tunables;this.MAX_UPLOADS=this.tunables.maxConcurrentUploads;this.MONITOR_INTERVAL=2500;this.UPLOAD_TIMEOUT=this.tunables.uploadTimeoutMs;this.UPLOAD_STALL_TIMEOUT=this.tunables.stallTimeoutMs;this.WATCH_TIMEOUT=this.tunables.watchTimeoutMs;this.FINALIZE_BUDGET=this.tunables.finalizeBudgetMs;this.FINALIZE_CEILING=this.tunables.finalizeCeilingMs;this.SHUTDOWN_FLUSH_TIMEOUT=2e3;this.assets=[];this.watchAssets=[];this.processingPaths=new Set;this.doneWaitingForReport=!1;this.processingInProgress=!1;this.pwTestIdToChecksumTestId={};this.checksumTestIdToUsingPlaceholder={};this.progressFlushInFlight=!1;this.stallEventEmitted=!1;this.channel=new St,ft(n=>this.channel.wideEvent(n)),this.testAssetUploader=new He(t.apiURL,t.apiKey,this.UPLOAD_TIMEOUT,()=>`client-api/test-runs/${this.config.sessionId}/get-upload-url`,this.isolationMode,{start:s(n=>this.channel.trace("Upload Start",{filename:n}),"start"),complete:s(n=>{if(!this.reportAsset||n!==this.reportAsset.info.path)try{(0,P.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:s((n,o)=>this.channel.trace("Upload Failed",{filename:n,error:o}),"error")},t.sessionId,{fetchImpl:mn(this.tunables),tunables:this.tunables}),this.uploadMonitorInterval=setInterval(this.monitorUploads.bind(this),this.MONITOR_INTERVAL);for(let n of this.tunablesResolution.warnings)this.channel.debug(`[upload-tunables] ${n}`),oe("upload_tunable_coerced",{warning:n});this.listenForMessages(),this.startServer()}static{s(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"),i=JSON.parse(a);await this.handleReport(i)}catch(a){this.channel.debug("Error JSON parsing report payload, continue without report. Error: "+this.stringify(a)),this.stopWaitingForReport("failed")}else this.stopWaitingForReport("not-requested");this.monitorUploadsCompletion();break;case"shutdown":this.shutdown();break}})()})}async readMetadataFile(t){try{let r=await(0,hn.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,K.dirname)(t);await this.channel.log("Serving report in browser: "+r);let n=Ne.isRepoMode?`yarn playwright show-report ${r}`:`npx playwright show-report ${r}`;(0,gn.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:i,projectRoot:c,playwrightRootDir:d,isUploadReport:m,dedupeByChecksumTestId:y}=t;this.channel.debug(`Handling report ${this.isolationMode?"(isolation mode)":""}`+r),this.uploadReportData((0,K.dirname)(r),m);let T=fe("report_processing",{test_suite_run_id:this.config.sessionId,report_path:r,isolation_mode:this.isolationMode,is_upload_report:!!m});try{let R=await this.readMetadataFile(n),_=new Pe(r,this.config.sessionId,this.pwTestIdToChecksumTestId,R,{hosted:!this.isolationMode,...y?{dedupeByChecksumTestId:y}:{}},this.channel,i,c,this.checksumTestIdToUsingPlaceholder,d),u=this.initAsset({type:"report",path:""});this.reportAsset=u;try{let h=await _.process();u.info.path=_.getProcessedFilePath(),T.set({processed_path:u.info.path,...h}),this.uploadAsset(u)}catch(h){this.channel.debug("Error processing report, "+h.message),u.error=!0,T.set({error:J(h)})}let f=_.getReportsStats();this.stats=f,Dt(T,u.error?"error":"success",f),this.channel.debug("Checking watch assets");let p=this.watchAssets.filter(h=>!(h.type!=="trace"||_.testHasTrace(h.testId??"",h.project??"")));p.length>0&&(this.channel.debug("Removed watch assets - "),this.channel.debug(JSON.stringify(p.map(h=>h.path)))),this.watchAssets=this.watchAssets.filter(h=>h.type!=="trace"||_.testHasTrace(h.testId??"",h.project??""))}catch(R){this.channel.debug("Error processing report, "+this.stringify(R)),this.reportAsset&&(this.reportAsset.error=!0),T.emit({outcome:"error",error:J(R)})}finally{if((a==="always"||a==="on-failure"&&o)&&await this.serveReport(r),n&&(0,P.existsSync)(n))try{(0,P.unlinkSync)(n)}catch(_){console.error(`Error deleting checksum metadata file ${n}: ${_.message}`)}}}uploadReportData(t,r){let n=(0,K.join)(t,"data");try{let o=(0,P.readdirSync)(n),a=r?[".webm"]:[".zip",".webm"],i=o.filter(c=>!a.includes((0,K.extname)(c)));this.channel.debug("Preparing to upload report data files,"+i);for(let c of i)this.channel.debug("Uploading report data file,"+c),this.addAsset({type:"report-data-file",fileName:c,path:`${n}/${c}`})}catch(o){this.channel.debug(`Error reading/adding report data files from dir ${n}`+o.message)}}shutdown(){clearInterval(this.uploadMonitorInterval);try{this.server?.closeAllConnections?.(),this.server?.close?.()}catch{}this.channel.debug("Received shutdown message from CLI"),process.stdout.write("",()=>process.exit(0)),setTimeout(()=>process.exit(0),this.SHUTDOWN_FLUSH_TIMEOUT).unref()}async monitorUploadsCompletion(){let t=Date.now();!this.doneWaitingForReport&&dn(this.reportAsset,{testRunEndTime:this.testRunEndTime,stallTimeoutMs:this.UPLOAD_STALL_TIMEOUT,finalizeBudgetMs:this.FINALIZE_BUDGET},t)&&this.settleReport();let r=pn({assets:this.assets,processingInProgress:this.processingInProgress,doneWaitingForReport:this.doneWaitingForReport,pendingWatchCount:this.watchAssets.length,testRunEndTime:this.testRunEndTime,stallTimeoutMs:this.UPLOAD_STALL_TIMEOUT,watchTimeoutMs:this.WATCH_TIMEOUT,finalizeBudgetMs:this.FINALIZE_BUDGET,finalizeCeilingMs:this.FINALIZE_CEILING},t);if(!r){await Ve(1e3),this.monitorUploadsCompletion();return}this.finalizeRun(r,t)}stopWaitingForReport(t){this.doneWaitingForReport=!0,this.reportOutcome=t}reportAssetOutcome(){return this.reportAsset?.complete?"uploaded":this.reportAsset?.error?"failed":"abandoned"}settleReport(){this.stopWaitingForReport(this.reportAssetOutcome());let t="";try{let r=JSON.stringify(this.stats??{}),n=`checksum-stats-${(0,Se.randomBytes)(8).toString("hex")}.json`;t=(0,K.join)((0,_n.tmpdir)(),n),(0,P.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.reportOutcome==="uploaded"?"true":"false"}:${t}`)}finalizeRun(t,r){t.reason==="stall"&&this.emitStallDetected(t.abandonedAssets,r),t.abandonedAssets.forEach(i=>{i.error=!0});let n=this.assets.some(i=>i.error)?"uploads-complete-with-errors":"uploads-complete",o=this.assets.filter(i=>i.error);oe("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(i=>i.complete).length,errored:o.length,stalled:t.abandonedAssets.length>0,stalled_count:t.abandonedAssets.length,finalize_reason:t.reason,finalize_budget_ms:this.FINALIZE_BUDGET,finalize_ceiling_ms:this.FINALIZE_CEILING,watch_remaining:this.watchAssets.length,report_outcome:this.reportOutcome,upload_finalize_ms:this.testRunEndTime?r-this.testRunEndTime:void 0,errored_assets:o.map(i=>this.assetSnapshot(i,r))});let a=n==="uploads-complete"?{}:{uploadErrors:o.map(i=>{try{return JSON.stringify(i)}catch{return i.info.path}}),watchAssets:this.watchAssets,testRunEndTime:this.testRunEndTime,now:r,finalizeReason:t.reason,abandonedAssets:t.abandonedAssets.map(i=>this.assetSnapshot(i,r))};if(un(t))try{this.cleanUp()}catch(i){this.channel.debug("cleanUp failed (ignored): "+i?.message)}else this.channel.debug(`skipping cleanUp: ${t.abandonedAssets.length} asset(s) abandoned (${t.reason})`);this.channel.event(n,JSON.stringify(a))}assetSnapshot(t,r){return{file_name:t.info.fileName??(0,K.basename)(t.info.path),asset_type:t.info.type,test_id:t.info.testId,loaded_bytes:t.loadedBytes,committed_bytes:t.committedBytes,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,K.dirname)(r.info.path);break}t&&(0,P.rmSync)(t,{recursive:!0,force:!0})}emitStallDetected(t,r){this.channel.log("Uploads are stalled"),!this.stallEventEmitted&&(this.stallEventEmitted=!0,oe("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:t.length,pending_assets:t.map(n=>this.assetSnapshot(n,r))}))}async startServer(){let t=await this.acquirePortNumber();this.channel.event("port",t.toString()),this.server=(0,En.createServer)((r,n)=>{let o=s(i=>{n.writeHead(400,{"Content-Type":"text/plain"}),n.end(i)},"returnErrorWithMessage");if(r.method!=="POST"){n.writeHead(404,{"Content-Type":"text/plain"}),n.end("Method not allowed");return}let a="";r.on("data",i=>{a+=i.toString()}),r.on("end",()=>{let i;try{i=JSON.parse(a)}catch{o("Invalid body");return}let{type:c,payload:d,watch:m}=i;switch(this.channel.debug(`Server received message, ${c}, ${this.stringify(d)}`),c){case"asset":if(!d.path||!d.type){o("Missing arguments");return}m?this.watchAsset(d):this.processAsset(d);break;case"testInfo":if(!d.pwTestId||!d.checksumTestId){o("Missing arguments");return}this.pwTestIdToChecksumTestId[d.pwTestId]=d.checksumTestId,d.usingChecksumTestIdPlaceholder!==void 0&&(this.checksumTestIdToUsingPlaceholder[d.checksumTestId]=d.usingChecksumTestIdPlaceholder);break;case"checksumTestMetadata":{let y=d;if(!y.checksumTestId||!d.data){o("Missing arguments");return}this.channel.event("checksumTestMetadata",JSON.stringify({...y}));break}case"testStats":break;case"playwrightConfig":this.channel.event("playwrightConfig",JSON.stringify(d));break;case"runProgress":this.forwardProgress(d);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=s(()=>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)})}}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=s(async()=>{await this.waitForFileComplete(t.path)&&(this.processAsset(t),this.watchAssets=this.watchAssets.filter(o=>o.path!==t.path))},"waitForCompletion");if((0,P.existsSync)(t.path))r();else{let n=(0,K.dirname)(t.path),o=(0,K.basename)(t.path),a=!1,i=(0,P.watch)(n,(c,d)=>{(async()=>{if(!(d!==o||a))try{this.channel.debug("Watched file changed "+t.path),a=!0,await r()}finally{i.close()}})()})}}waitForFileComplete(t,r=1e3,n=6e4,o=1){return new Promise(a=>{let i=Date.now(),c=0,d=o,m=s(()=>{if(!(0,P.existsSync)(t)){this.channel.debug(`Asset required for upload doesn't exist anymore ${t}`),a(!1);return}let y=(0,P.statSync)(t).size;if(y===c){if(d>0){this.channel.debug(`File size has not changed, verifying stabilization, ${t}, size: ${y}, equalSizeValidationCountLeft: ${d}`),d--,setTimeout(m,r);return}this.channel.debug(`File size has not changed, stabilization verified, ${t}, size: ${y}`),a(!0);return}if(this.channel.debug(`File size changed, waiting for stabilization, ${t}, previous size: ${c}, current size: ${y}`),Date.now()-i>n){this.channel.debug(`Asset required for upload is taking over ${n} ms to write to disk ${t}`),a(!0);return}c=y,setTimeout(m,r)},"checkFile");m()})}processAsset(t){switch(t.type){case"trace":return this.processTrace(t.path,t.testId);case"har":return;case"rrweb-recording":case"esra":case"test-files":return this.addAsset(t);default:return}}async calculateFileSha1Streaming(t){let r=(0,Se.createHash)("sha1"),n=(0,P.createReadStream)(t);return await(0,yn.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 Ve(1e3),n=fe("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,P.renameSync)(t,o);let c="checksum-playwright-trace:"+Date.now().toString()+(0,Se.randomBytes)(1024).toString("hex");(0,P.writeFileSync)(t,c)}let i=await s(async()=>await this.calculateFileSha1Streaming(t)+(0,K.extname)(t),"makePlaywrightHTMLReporterName")();this.channel.debug(`Trace file for test ${r} has been manipulated with file name ${i}, sending for upload...`),this.addAsset({type:"report-data-file",path:o,...r!==void 0?{testId:r}:{},fileName:i}),n.emit({outcome:"success",file_name:i})}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:J(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=Tn.createServer();n.unref(),n.on("error",r),n.listen(0,()=>{let o=n.address().port;n.close(()=>{t(o)})})})}},bn;try{bn=JSON.parse(process.argv[2]??"")}catch(e){console.error("Error starting test run monitor",e),process.exit(1)}new ze(bn,process.argv[3]==="isolated");0&&(module.exports={TestRunMonitor});
13
+ `)}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}`)}},ze=class{constructor(t,r=!1){this.config=t;this.isolationMode=r;this.tunablesResolution=mt(process.env);this.tunables=this.tunablesResolution.tunables;this.MAX_UPLOADS=this.tunables.maxConcurrentUploads;this.MONITOR_INTERVAL=2500;this.UPLOAD_TIMEOUT=this.tunables.uploadTimeoutMs;this.UPLOAD_STALL_TIMEOUT=this.tunables.stallTimeoutMs;this.WATCH_TIMEOUT=this.tunables.watchTimeoutMs;this.FINALIZE_BUDGET=this.tunables.finalizeBudgetMs;this.FINALIZE_CEILING=this.tunables.finalizeCeilingMs;this.SHUTDOWN_FLUSH_TIMEOUT=2e3;this.assets=[];this.watchAssets=[];this.processingPaths=new Set;this.doneWaitingForReport=!1;this.processingInProgress=!1;this.pwTestIdToChecksumTestId={};this.checksumTestIdToUsingPlaceholder={};this.progressFlushInFlight=!1;this.stallEventEmitted=!1;this.channel=new St,ft(n=>this.channel.wideEvent(n)),this.testAssetUploader=new He(t.apiURL,t.apiKey,this.UPLOAD_TIMEOUT,()=>`client-api/test-runs/${this.config.sessionId}/get-upload-url`,this.isolationMode,{start:s(n=>this.channel.trace("Upload Start",{filename:n}),"start"),complete:s(n=>{if(!this.reportAsset||n!==this.reportAsset.info.path)try{(0,P.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:s((n,o)=>this.channel.trace("Upload Failed",{filename:n,error:o}),"error")},t.sessionId,{fetchImpl:mn(this.tunables),tunables:this.tunables}),this.uploadMonitorInterval=setInterval(this.monitorUploads.bind(this),this.MONITOR_INTERVAL);for(let n of this.tunablesResolution.warnings)this.channel.debug(`[upload-tunables] ${n}`),oe("upload_tunable_coerced",{warning:n});this.listenForMessages(),this.startServer()}static{s(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"),i=JSON.parse(a);await this.handleReport(i)}catch(a){this.channel.debug("Error JSON parsing report payload, continue without report. Error: "+this.stringify(a)),this.stopWaitingForReport("failed")}else this.stopWaitingForReport("not-requested");this.monitorUploadsCompletion();break;case"shutdown":this.shutdown();break}})()})}async readMetadataFile(t){try{let r=await(0,hn.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,K.dirname)(t);await this.channel.log("Serving report in browser: "+r);let n=Ne.isRepoMode?`yarn playwright show-report ${r}`:`npx playwright show-report ${r}`;(0,gn.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:i,projectRoot:c,playwrightRootDir:d,isUploadReport:m,dedupeByChecksumTestId:y}=t;this.channel.debug(`Handling report ${this.isolationMode?"(isolation mode)":""}`+r),this.uploadReportData((0,K.dirname)(r),m);let T=fe("report_processing",{test_suite_run_id:this.config.sessionId,report_path:r,isolation_mode:this.isolationMode,is_upload_report:!!m});try{let R=await this.readMetadataFile(n),_=new Pe(r,this.config.sessionId,this.pwTestIdToChecksumTestId,R,{hosted:!this.isolationMode,...y?{dedupeByChecksumTestId:y}:{}},this.channel,i,c,this.checksumTestIdToUsingPlaceholder,d),u=this.initAsset({type:"report",path:""});this.reportAsset=u;try{let h=await _.process();u.info.path=_.getProcessedFilePath(),T.set({processed_path:u.info.path,...h}),this.uploadAsset(u)}catch(h){this.channel.debug("Error processing report, "+h.message),u.error=!0,T.set({error:J(h)})}let f=_.getReportsStats();this.stats=f,Ot(T,u.error?"error":"success",f),this.channel.debug("Checking watch assets");let p=this.watchAssets.filter(h=>!(h.type!=="trace"||_.testHasTrace(h.testId??"",h.project??"")));p.length>0&&(this.channel.debug("Removed watch assets - "),this.channel.debug(JSON.stringify(p.map(h=>h.path)))),this.watchAssets=this.watchAssets.filter(h=>h.type!=="trace"||_.testHasTrace(h.testId??"",h.project??""))}catch(R){this.channel.debug("Error processing report, "+this.stringify(R)),this.reportAsset&&(this.reportAsset.error=!0),T.emit({outcome:"error",error:J(R)})}finally{if((a==="always"||a==="on-failure"&&o)&&await this.serveReport(r),n&&(0,P.existsSync)(n))try{(0,P.unlinkSync)(n)}catch(_){console.error(`Error deleting checksum metadata file ${n}: ${_.message}`)}}}uploadReportData(t,r){let n=(0,K.join)(t,"data");try{let o=(0,P.readdirSync)(n),a=r?[".webm"]:[".zip",".webm"],i=o.filter(c=>!a.includes((0,K.extname)(c)));this.channel.debug("Preparing to upload report data files,"+i);for(let c of i)this.channel.debug("Uploading report data file,"+c),this.addAsset({type:"report-data-file",fileName:c,path:`${n}/${c}`})}catch(o){this.channel.debug(`Error reading/adding report data files from dir ${n}`+o.message)}}shutdown(){clearInterval(this.uploadMonitorInterval);try{this.server?.closeAllConnections?.(),this.server?.close?.()}catch{}this.channel.debug("Received shutdown message from CLI"),process.stdout.write("",()=>process.exit(0)),setTimeout(()=>process.exit(0),this.SHUTDOWN_FLUSH_TIMEOUT).unref()}async monitorUploadsCompletion(){let t=Date.now();!this.doneWaitingForReport&&dn(this.reportAsset,{testRunEndTime:this.testRunEndTime,stallTimeoutMs:this.UPLOAD_STALL_TIMEOUT,finalizeBudgetMs:this.FINALIZE_BUDGET},t)&&this.settleReport();let r=pn({assets:this.assets,processingInProgress:this.processingInProgress,doneWaitingForReport:this.doneWaitingForReport,pendingWatchCount:this.watchAssets.length,testRunEndTime:this.testRunEndTime,stallTimeoutMs:this.UPLOAD_STALL_TIMEOUT,watchTimeoutMs:this.WATCH_TIMEOUT,finalizeBudgetMs:this.FINALIZE_BUDGET,finalizeCeilingMs:this.FINALIZE_CEILING},t);if(!r){await Ve(1e3),this.monitorUploadsCompletion();return}this.finalizeRun(r,t)}stopWaitingForReport(t){this.doneWaitingForReport=!0,this.reportOutcome=t}reportAssetOutcome(){return this.reportAsset?.complete?"uploaded":this.reportAsset?.error?"failed":"abandoned"}settleReport(){this.stopWaitingForReport(this.reportAssetOutcome());let t="";try{let r=JSON.stringify(this.stats??{}),n=`checksum-stats-${(0,Se.randomBytes)(8).toString("hex")}.json`;t=(0,K.join)((0,_n.tmpdir)(),n),(0,P.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.reportOutcome==="uploaded"?"true":"false"}:${t}`)}finalizeRun(t,r){t.reason==="stall"&&this.emitStallDetected(t.abandonedAssets,r),t.abandonedAssets.forEach(i=>{i.error=!0});let n=this.assets.some(i=>i.error)?"uploads-complete-with-errors":"uploads-complete",o=this.assets.filter(i=>i.error);oe("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(i=>i.complete).length,errored:o.length,stalled:t.abandonedAssets.length>0,stalled_count:t.abandonedAssets.length,finalize_reason:t.reason,finalize_budget_ms:this.FINALIZE_BUDGET,finalize_ceiling_ms:this.FINALIZE_CEILING,watch_remaining:this.watchAssets.length,report_outcome:this.reportOutcome,upload_finalize_ms:this.testRunEndTime?r-this.testRunEndTime:void 0,errored_assets:o.map(i=>this.assetSnapshot(i,r))});let a=n==="uploads-complete"?{}:{uploadErrors:o.map(i=>{try{return JSON.stringify(i)}catch{return i.info.path}}),watchAssets:this.watchAssets,testRunEndTime:this.testRunEndTime,now:r,finalizeReason:t.reason,abandonedAssets:t.abandonedAssets.map(i=>this.assetSnapshot(i,r))};if(un(t))try{this.cleanUp()}catch(i){this.channel.debug("cleanUp failed (ignored): "+i?.message)}else this.channel.debug(`skipping cleanUp: ${t.abandonedAssets.length} asset(s) abandoned (${t.reason})`);this.channel.event(n,JSON.stringify(a))}assetSnapshot(t,r){return{file_name:t.info.fileName??(0,K.basename)(t.info.path),asset_type:t.info.type,test_id:t.info.testId,loaded_bytes:t.loadedBytes,committed_bytes:t.committedBytes,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,K.dirname)(r.info.path);break}t&&(0,P.rmSync)(t,{recursive:!0,force:!0})}emitStallDetected(t,r){this.channel.log("Uploads are stalled"),!this.stallEventEmitted&&(this.stallEventEmitted=!0,oe("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:t.length,pending_assets:t.map(n=>this.assetSnapshot(n,r))}))}async startServer(){let t=await this.acquirePortNumber();this.channel.event("port",t.toString()),this.server=(0,En.createServer)((r,n)=>{let o=s(i=>{n.writeHead(400,{"Content-Type":"text/plain"}),n.end(i)},"returnErrorWithMessage");if(r.method!=="POST"){n.writeHead(404,{"Content-Type":"text/plain"}),n.end("Method not allowed");return}let a="";r.on("data",i=>{a+=i.toString()}),r.on("end",()=>{let i;try{i=JSON.parse(a)}catch{o("Invalid body");return}let{type:c,payload:d,watch:m}=i;switch(this.channel.debug(`Server received message, ${c}, ${this.stringify(d)}`),c){case"asset":if(!d.path||!d.type){o("Missing arguments");return}m?this.watchAsset(d):this.processAsset(d);break;case"testInfo":if(!d.pwTestId||!d.checksumTestId){o("Missing arguments");return}this.pwTestIdToChecksumTestId[d.pwTestId]=d.checksumTestId,d.usingChecksumTestIdPlaceholder!==void 0&&(this.checksumTestIdToUsingPlaceholder[d.checksumTestId]=d.usingChecksumTestIdPlaceholder);break;case"checksumTestMetadata":{let y=d;if(!y.checksumTestId||!d.data){o("Missing arguments");return}this.channel.event("checksumTestMetadata",JSON.stringify({...y}));break}case"testStats":break;case"playwrightConfig":this.channel.event("playwrightConfig",JSON.stringify(d));break;case"runProgress":this.forwardProgress(d);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=s(()=>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)})}}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=s(async()=>{await this.waitForFileComplete(t.path)&&(this.processAsset(t),this.watchAssets=this.watchAssets.filter(o=>o.path!==t.path))},"waitForCompletion");if((0,P.existsSync)(t.path))r();else{let n=(0,K.dirname)(t.path),o=(0,K.basename)(t.path),a=!1,i=(0,P.watch)(n,(c,d)=>{(async()=>{if(!(d!==o||a))try{this.channel.debug("Watched file changed "+t.path),a=!0,await r()}finally{i.close()}})()})}}waitForFileComplete(t,r=1e3,n=6e4,o=1){return new Promise(a=>{let i=Date.now(),c=0,d=o,m=s(()=>{if(!(0,P.existsSync)(t)){this.channel.debug(`Asset required for upload doesn't exist anymore ${t}`),a(!1);return}let y=(0,P.statSync)(t).size;if(y===c){if(d>0){this.channel.debug(`File size has not changed, verifying stabilization, ${t}, size: ${y}, equalSizeValidationCountLeft: ${d}`),d--,setTimeout(m,r);return}this.channel.debug(`File size has not changed, stabilization verified, ${t}, size: ${y}`),a(!0);return}if(this.channel.debug(`File size changed, waiting for stabilization, ${t}, previous size: ${c}, current size: ${y}`),Date.now()-i>n){this.channel.debug(`Asset required for upload is taking over ${n} ms to write to disk ${t}`),a(!0);return}c=y,setTimeout(m,r)},"checkFile");m()})}processAsset(t){switch(t.type){case"trace":return this.processTrace(t.path,t.testId);case"har":return;case"rrweb-recording":case"esra":case"test-files":return this.addAsset(t);default:return}}async calculateFileSha1Streaming(t){let r=(0,Se.createHash)("sha1"),n=(0,P.createReadStream)(t);return await(0,yn.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 Ve(1e3),n=fe("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,P.renameSync)(t,o);let c="checksum-playwright-trace:"+Date.now().toString()+(0,Se.randomBytes)(1024).toString("hex");(0,P.writeFileSync)(t,c)}let i=await s(async()=>await this.calculateFileSha1Streaming(t)+(0,K.extname)(t),"makePlaywrightHTMLReporterName")();this.channel.debug(`Trace file for test ${r} has been manipulated with file name ${i}, sending for upload...`),this.addAsset({type:"report-data-file",path:o,...r!==void 0?{testId:r}:{},fileName:i}),n.emit({outcome:"success",file_name:i})}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:J(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=Tn.createServer();n.unref(),n.on("error",r),n.listen(0,()=>{let o=n.address().port;n.close(()=>{t(o)})})})}},bn;try{bn=JSON.parse(process.argv[2]??"")}catch(e){console.error("Error starting test run monitor",e),process.exit(1)}new ze(bn,process.argv[3]==="isolated");0&&(module.exports={TestRunMonitor});