@beyondwork/wb-cli 0.1.37 → 0.1.38

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/out/cli.js CHANGED
@@ -167,7 +167,7 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
167
167
  `).map(e=>e.trim()).join(" ")};xy.O=function(s){return this.inspectOpts.colors=this.useColors,rc.inspect(s,this.inspectOpts)}});var _y=w((W5,gu)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?gu.exports=uy():gu.exports=yy()});var sr,bu,ky,wy,vy,Sy=$(()=>{qo();sr={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},bu={get(s){return{signature:Q.get(s,0),compressedSize:Q.get(s,8),uncompressedSize:Q.get(s,12)}},len:16},ky={get(s){let e=te.get(s,6);return{signature:Q.get(s,0),minVersion:te.get(s,4),dataDescriptor:!!(e&8),compressedMethod:te.get(s,8),compressedSize:Q.get(s,18),uncompressedSize:Q.get(s,22),filenameLength:te.get(s,26),extraFieldLength:te.get(s,28),filename:null}},len:30},wy={get(s){return{signature:Q.get(s,0),nrOfThisDisk:te.get(s,4),nrOfThisDiskWithTheStart:te.get(s,6),nrOfEntriesOnThisDisk:te.get(s,8),nrOfEntriesOfSize:te.get(s,10),sizeOfCd:Q.get(s,12),offsetOfStartOfCd:Q.get(s,16),zipFileCommentLength:te.get(s,20)}},len:22},vy={get(s){let e=te.get(s,8);return{signature:Q.get(s,0),minVersion:te.get(s,6),dataDescriptor:!!(e&8),compressedMethod:te.get(s,10),compressedSize:Q.get(s,20),uncompressedSize:Q.get(s,24),filenameLength:te.get(s,28),extraFieldLength:te.get(s,30),fileCommentLength:te.get(s,32),relativeOffsetOfLocalHeader:Q.get(s,42),filename:null}},len:46}});function Ty(s){let e=new Uint8Array(Q.len);return Q.put(e,0,s),e}function NP(s,e){let t=s.length,r=e.length;if(r>t)return-1;for(let i=0;i<=t-r;i++){let o=!0;for(let n=0;n<r;n++)if(s[i+n]!==e[n]){o=!1;break}if(o)return i}return-1}function OP(s){let e=s.reduce((i,o)=>i+o.length,0),t=new Uint8Array(e),r=0;for(let i of s)t.set(i,r),r+=i.length;return t}var Ey,Lt,xu,qP,oc,rr,$y=$(()=>{qo();Ey=O(_y(),1);Sy();Lt=(0,Ey.default)("tokenizer:inflate"),xu=256*1024,qP=Ty(sr.DataDescriptor),oc=Ty(sr.EndOfCentralDirectory),rr=class s{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(xu)}async isZip(){return await this.peekSignature()===sr.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Q)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16*1024,e.fileInfo.size),r=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(r,{position:e.fileInfo.size-t});for(let i=r.length-4;i>=0;i--)if(r[i]===oc[0]&&r[i+1]===oc[1]&&r[i+2]===oc[2]&&r[i+3]===oc[3])return e.fileInfo.size-t+i;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){Lt("Cannot reading central-directory without random-read support");return}Lt("Reading central-directory...");let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){Lt("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(wy,t),i=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let o=0;o<r.nrOfEntriesOfSize;++o){let n=await this.tokenizer.readToken(vy);if(n.signature!==sr.CentralFileHeader)throw new Error("Expected Central-File-Header signature");n.filename=await this.tokenizer.readToken(new Be(n.filenameLength,"utf-8")),await this.tokenizer.ignore(n.extraFieldLength),await this.tokenizer.ignore(n.fileCommentLength),i.push(n),Lt(`Add central-directory file-entry: n=${o+1}/${i.length}: filename=${i[o].filename}`)}return this.tokenizer.setPosition(e),i}this.tokenizer.setPosition(e)}async unzip(e){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let r=!1;do{let i=await this.readLocalFileHeader();if(!i)break;let o=e(i);r=!!o.stop;let n;if(await this.tokenizer.ignore(i.extraFieldLength),i.dataDescriptor&&i.compressedSize===0){let a=[],c=xu;Lt("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let l=-1;for(;l<0&&c===xu;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),l=NP(this.syncBuffer.subarray(0,c),qP);let d=l>=0?l:c;if(o.handler){let p=new Uint8Array(d);await this.tokenizer.readBuffer(p),a.push(p)}else await this.tokenizer.ignore(d)}Lt(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),o.handler&&await this.inflate(i,OP(a),o.handler)}else o.handler?(Lt(`Reading compressed-file-data: ${i.compressedSize} bytes`),n=new Uint8Array(i.compressedSize),await this.tokenizer.readBuffer(n),await this.inflate(i,n,o.handler)):(Lt(`Ignoring compressed-file-data: ${i.compressedSize} bytes`),await this.tokenizer.ignore(i.compressedSize));if(Lt(`Reading data-descriptor at pos=${this.tokenizer.position}`),i.dataDescriptor&&(await this.tokenizer.readToken(bu)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-bu.len}`)}while(!r)}async iterateOverCentralDirectory(e,t){for(let r of e){let i=t(r);if(i.handler){this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);let o=await this.readLocalFileHeader();if(o){await this.tokenizer.ignore(o.extraFieldLength);let n=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(n),await this.inflate(o,n,i.handler)}}if(i.stop)break}}async inflate(e,t,r){if(e.compressedMethod===0)return r(t);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);Lt(`Decompress filename=${e.filename}, compressed-size=${t.length}`);let i=await s.decompressDeflateRaw(t);return r(i)}static async decompressDeflateRaw(e){let t=new ReadableStream({start(o){o.enqueue(e),o.close()}}),r=new DecompressionStream("deflate-raw"),i=t.pipeThrough(r);try{let n=await new Response(i).arrayBuffer();return new Uint8Array(n)}catch(o){let n=o instanceof Error?`Failed to deflate ZIP entry: ${o.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(n)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(Q);if(e===sr.LocalFileHeader){let t=await this.tokenizer.readToken(ky);return t.filename=await this.tokenizer.readToken(new Be(t.filenameLength,"utf-8")),t}if(e===sr.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var No,Ry=$(()=>{No=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let r=new Uint8Array(1024),i=await e.readBuffer(r,{mayBeLess:!0});if(i===0){t.close();return}t.enqueue(r.subarray(0,i))}}).pipeThrough(new DecompressionStream("gzip"))}}});var Ay=$(()=>{$y();Ry()});function yu(s){let{byteLength:e}=s;if(e===6)return s.getUint16(0)*2**32+s.getUint32(2);if(e===5)return s.getUint8(0)*2**32+s.getUint32(1);if(e===4)return s.getUint32(0);if(e===3)return s.getUint8(0)*2**16+s.getUint16(1);if(e===2)return s.getUint16(0);if(e===1)return s.getUint8(0)}var Y5,Q5,X5,Py=$(()=>{Y5={utf8:new globalThis.TextDecoder("utf8")},Q5=new globalThis.TextEncoder,X5=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"))});function Cy(s,e){if(e==="utf-16le"){let t=[];for(let r=0;r<s.length;r++){let i=s.charCodeAt(r);t.push(i&255,i>>8&255)}return t}if(e==="utf-16be"){let t=[];for(let r=0;r<s.length;r++){let i=s.charCodeAt(r);t.push(i>>8&255,i&255)}return t}return[...s].map(t=>t.charCodeAt(0))}function qy(s,e=0){let t=Number.parseInt(new Be(6).get(s,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let r=256;for(let i=e;i<e+148;i++)r+=s[i];for(let i=e+156;i<e+512;i++)r+=s[i];return t===r}var Ny,Oy=$(()=>{qo();Ny={get:(s,e)=>s[e+3]&127|s[e+2]<<7|s[e+1]<<14|s[e]<<21,len:4}});var Iy,jy,Dy=$(()=>{Iy=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],jy=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"]});function KP(s){let e=s?.streamReader;if(e?.constructor?.name!=="WebStreamByobReader")return s;let{reader:t}=e,r=async()=>{await t.cancel(),t.releaseLock()};return e.close=r,e.abort=async()=>{e.interrupted=!0,await r()},s}function wu(s,e,t){if(!Number.isFinite(s)||s<0||s>e)throw new ss(`${t} has invalid size ${s} (maximum ${e} bytes)`);return s}async function Ps(s,e,{maximumLength:t=at,reason:r="skip"}={}){let i=wu(e,t,r);await s.ignore(i)}async function ku(s,e,t,{maximumLength:r=e.length,reason:i="read"}={}){let o=t?.length??e.length,n=wu(o,r,i);return s.readBuffer(e,{...t,length:n})}async function JP(s,{maximumLength:e=Wt}={}){let i=new ReadableStream({start(l){l.enqueue(s),l.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),o=[],n=0;try{for(;;){let{done:l,value:d}=await i.read();if(l)break;if(n+=d.length,n>e)throw await i.cancel(),new Error(`ZIP entry decompressed data exceeds ${e} bytes`);o.push(d)}}finally{i.releaseLock()}let a=new Uint8Array(n),c=0;for(let l of o)a.set(l,c),c+=l.length;return a}function QP(s,e){if(s.length<nc)return-1;let t=s.length-nc;for(let r=0;r<=t;r++)if(Q.get(s,r)===Yy&&Q.get(s,r+8)===e+r)return r;return-1}function XP(s){return(s.codePointAt(0)&32)!==0}function ZP(s,e){let t=new Uint8Array(e),r=0;for(let i of s)t.set(i,r),r+=i.length;return t}async function eC(s,{shouldBuffer:e,maximumLength:t=Wt}={}){let{syncBuffer:r}=s,{length:i}=r,o=[],n=0;for(;;){let a=await s.tokenizer.peekBuffer(r,{mayBeLess:!0}),c=QP(r.subarray(0,a),n),l=c>=0?0:a===i?Math.min(YP,a-1):0,d=c>=0?c:a-l;if(d===0)break;if(n+=d,n>t)throw new Error(`ZIP entry compressed data exceeds ${t} bytes`);if(e){let p=new Uint8Array(d);await s.tokenizer.readBuffer(p),o.push(p)}else await s.tokenizer.ignore(d);if(c>=0)break}if(Ce(s.tokenizer)||(s.knownSizeDescriptorScannedBytes+=n),!!e)return ZP(o,n)}function tC(s,e){return Ce(s.tokenizer)?Math.max(0,at-(s.tokenizer.position-e)):Math.max(0,Wt-s.knownSizeDescriptorScannedBytes)}async function sC(s,e,{shouldBuffer:t,maximumDescriptorLength:r=Wt}={}){if(e.dataDescriptor&&e.compressedSize===0)return eC(s,{shouldBuffer:t,maximumLength:r});if(!t){await Ps(s.tokenizer,e.compressedSize,{maximumLength:Ce(s.tokenizer)?Wt:s.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}let i=aC(s.tokenizer);if(!Number.isFinite(e.compressedSize)||e.compressedSize<0||e.compressedSize>i)throw new Error(`ZIP entry compressed data exceeds ${i} bytes`);let o=new Uint8Array(e.compressedSize);return await s.tokenizer.readBuffer(o),o}function rC(s,e){let t=s.getReader(),r=0,i=!1,o=!1,n=async a=>{i||o||(o=!0,await t.cancel(a))};return new ReadableStream({async pull(a){if(r>=e){a.close(),await n();return}let{done:c,value:l}=await t.read();if(c||!l){i=!0,a.close();return}let d=e-r;if(l.length>d){a.enqueue(l.subarray(0,d)),r+=d,a.close(),await n();return}a.enqueue(l),r+=l.length},async cancel(a){await n(a)}})}async function Qy(s,e){return new or(e).fromBuffer(s)}async function Xy(s,e){return new or(e).fromBlob(s)}function Hy(s){switch(s=s.toLowerCase(),s){case"application/epub+zip":return{ext:"epub",mime:s};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:s};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:s};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:s};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:s};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:s};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:s};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:s};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:s};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:s};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:s};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:s};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:s};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:s};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:s};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:s};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function Ft(s,e,t){t={offset:0,...t};for(let[r,i]of e.entries())if(t.mask){if(i!==(t.mask[r]&s[r+t.offset]))return!1}else if(i!==s[r+t.offset])return!1;return!0}function vu(s){return Number.isFinite(s)?Math.max(1,Math.trunc(s)):ir}function iC(s,e,t){return t===void 0?s.read(e):(t.throwIfAborted(),new Promise((r,i)=>{let o=()=>{t.removeEventListener("abort",n)},n=()=>{let a=t.reason;o(),(async()=>{try{await s.cancel(a)}catch{}})(),i(a)};t.addEventListener("abort",n,{once:!0}),(async()=>{try{let a=await s.read(e);o(),r(a)}catch(a){o(),i(a)}})()}))}function oC(s){return Number.isFinite(s)?Math.max(0,Math.min(IP,Math.trunc(s))):0}function nC(s){return Number.isFinite(s)?Math.max(0,s):Number.MAX_SAFE_INTEGER}function Ce(s){let e=s.fileInfo.size;return!Number.isFinite(e)||e===Number.MAX_SAFE_INTEGER}function Oo(s,e,t){return Ce(s)&&s.position-e>t}function aC(s){let e=s.fileInfo.size,t=Number.isFinite(e)?Math.max(0,e-s.position):Number.MAX_SAFE_INTEGER;return Math.min(t,jP)}function cC(s){if(s instanceof B||s instanceof ss)return!0;if(!(s instanceof Error))return!1;if(zP.has(s.message)||HP.has(s.code))return!0;for(let e of VP)if(s.message.startsWith(e))return!0;return!1}function Ky(s,e=Wt){let t=[s.compressedSize,s.uncompressedSize];for(let r of t)if(!Number.isFinite(r)||r<0||r>e)return!1;return!0}function lC(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function pC(s,e){e.startsWith("word/")&&(s.hasWordDirectory=!0),e.startsWith("ppt/")&&(s.hasPresentationDirectory=!0),e.startsWith("xl/")&&(s.hasSpreadsheetDirectory=!0),e.startsWith("3D/")&&e.endsWith(".model")&&(s.hasThreeDimensionalModelEntry=!0)}function Jy(s){if(!(!s.hasContentTypesEntry||s.hasUnparseableContentTypes||s.isParsingContentTypes||s.hasParsedContentTypesEntry)){if(s.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(s.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(s.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(s.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function dC(s){let e=s.indexOf('.main+xml"');if(e===-1){let i="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return s.includes(`ContentType="${i}"`)?i:void 0}let t=s.slice(0,e),r=t.lastIndexOf('"');return t.slice(r+1)}async function Zy(s,e){return new or(e).fromTokenizer(s)}var ir,IP,Wt,Ly,jP,at,ac,Fy,DP,LP,Wy,_u,By,My,FP,WP,BP,MP,UP,Uy,Gy,zy,GP,Vy,zP,VP,HP,ss,Yy,nc,YP,or,e_,t_,Su=$(()=>{qo();Xa();Ay();Py();Oy();Dy();ir=4100,IP=ir-2,Wt=1024*1024,Ly=1024,jP=2**31-1,at=16*1024*1024,ac=Wt,Fy=Wt,DP=at,LP=1,Wy=100,_u=at,By=64,My=ac,FP=256,WP=512,BP=at,MP=512,UP=512,Uy=256,Gy=ac,zy=ac,GP=ac,Vy=at,zP=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),VP=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],HP=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]),ss=class extends Error{};Yy=134695760,nc=16,YP=nc-1;rr.prototype.inflate=async function(s,e,t){if(s.compressedMethod===0)return t(e);if(s.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${s.compressedMethod}`);let r=await JP(e,{maximumLength:Wt});return t(r)};rr.prototype.unzip=async function(s){let e=!1,t=0,r=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(Oo(this.tokenizer,r,at))throw new ss(`ZIP stream probing exceeds ${at} bytes`);let i=await this.readLocalFileHeader();if(!i)break;if(t++,t>Ly)throw new Error(`ZIP entry count exceeds ${Ly}`);let o=s(i);e=!!o.stop,await this.tokenizer.ignore(i.extraFieldLength);let n=await sC(this,i,{shouldBuffer:!!o.handler,maximumDescriptorLength:Math.min(Wt,tC(this,r))});if(o.handler&&await this.inflate(i,n,o.handler),i.dataDescriptor){let a=new Uint8Array(nc);if(await this.tokenizer.readBuffer(a),Q.get(a,0)!==Yy)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-a.length}`)}if(Oo(this.tokenizer,r,at))throw new ss(`ZIP stream probing exceeds ${at} bytes`)}while(!e)};or=class s{constructor(e){let t=oC(e?.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:t},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return KP(Kx(e,this.getTokenizerOptions()))}async parseTokenizer(e,t=0){this.detectionReentryCount=t;let r=e.position;for(let i of this.detectors){let o;try{o=await i.detect(e)}catch(n){if(n instanceof B||n instanceof ss)return;throw n}if(o)return o;if(r!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(Jx(t,this.getTokenizerOptions()))}async fromBlob(e){this.options.signal?.throwIfAborted();let t=Yx(e,this.getTokenizerOptions());return this.fromTokenizer(t)}async fromStream(e){this.options.signal?.throwIfAborted();let t=this.createTokenizerFromWebStream(e);return this.fromTokenizer(t)}async toDetectionStream(e,t){let r=vu(t?.sampleSize??ir),i,o,n=e.getReader({mode:"byob"});try{let{value:l,done:d}=await iC(n,new Uint8Array(r),this.options.signal);if(o=l,!d&&l)try{i=await this.fromBuffer(l.subarray(0,r))}catch(p){if(!(p instanceof B))throw p;i=void 0}o=l}finally{n.releaseLock()}let a=new TransformStream({async start(l){l.enqueue(o)},transform(l,d){d.enqueue(l)}}),c=e.pipeThrough(a);return c.fileType=i,c}async detectGzip(e){if(this.gzipProbeDepth>=LP)return{ext:"gz",mime:"application/gzip"};let t=new No(e),r=rC(t.inflate(),DP),i=Ce(e),o,n,a,c;if(i){let l=new AbortController;o=setTimeout(()=>{l.abort(new DOMException(`Operation timed out after ${Wy} ms`,"TimeoutError"))},Wy),n=this.options.signal===void 0?l.signal:AbortSignal.any([this.options.signal,l.signal]),a=new s({...this.options,signal:n}),a.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{c=await(a??this).fromStream(r)}catch(l){if(l?.name==="AbortError"&&n?.reason?.name!=="TimeoutError")throw l}finally{clearTimeout(o),i||this.gzipProbeDepth--}return c?.ext==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(e,t){return Ft(this.buffer,e,t)}checkString(e,t){return this.check(Cy(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(ir),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,Ce(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=Uy?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await Ps(e,6,{maximumLength:6,reason:"ID3 header prefix"});let t=await e.readToken(Ny),r=Ce(e);if(!Number.isFinite(t)||t<0||r&&(t>_u||e.position+t>_u))return;if(e.position+t>e.fileInfo.size)return r?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await Ps(e,t,{maximumLength:r?_u:e.fileInfo.size,reason:"ID3 payload"})}catch(i){if(i instanceof B)return;throw i}return this.detectionReentryCount>=Uy?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let t,r=lC();try{await new rr(e).unzip(i=>{pC(r,i.filename);let o=i.filename==="[Content_Types].xml",n=Jy(r);if(!o&&n)return t=n,{stop:!0};switch(i.filename){case"META-INF/mozilla.rsa":return t={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return t={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return Ky(i,Fy)?{async handler(a){let c=new TextDecoder("utf-8").decode(a).trim();t=Hy(c)},stop:!0}:{};case"[Content_Types].xml":return r.hasContentTypesEntry=!0,Ky(i,Fy)?(r.isParsingContentTypes=!0,{async handler(a){let c=new TextDecoder("utf-8").decode(a),l=dC(c);l&&(t=Hy(l)),r.hasParsedContentTypesEntry=!0,r.isParsingContentTypes=!1},stop:!0}):(r.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(i.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(i){if(!cC(i))throw i;r.isParsingContentTypes&&(r.isParsingContentTypes=!1,r.hasUnparseableContentTypes=!0)}return t??Jy(r)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),Ft(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Ft(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Ft(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Ft(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Ft(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Ft(t,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let t=await this.readTiffHeader(!1);if(t)return t}if(this.check([77,77])){let t=await this.readTiffHeader(!0);if(t)return t}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function t(){let c=await e.peekNumber(ny),l=128,d=0;for(;(c&l)===0&&l!==0;)++d,l>>=1;let p=new Uint8Array(d+1);return await ku(e,p,void 0,{maximumLength:p.length,reason:"EBML field"}),p}async function r(){let c=await t(),l=await t();l[0]^=128>>l.length-1;let d=Math.min(6,l.length),p=new DataView(c.buffer),u=new DataView(l.buffer,l.length-d,d);return{id:yu(p),len:yu(u)}}async function i(c){let l=0;for(;c>0;){if(l++,l>FP||Oo(e,n,at))return;let d=e.position,p=await r();if(p.id===17026){if(p.len>By)return;let u=wu(p.len,By,"EBML DocType");return(await e.readToken(new Be(u))).replaceAll(/\00.*$/g,"")}if(Ce(e)&&(!Number.isFinite(p.len)||p.len<0||p.len>My)||(await Ps(e,p.len,{maximumLength:Ce(e)?My:e.fileInfo.size,reason:"EBML payload"}),--c,e.position<=d))return}}let o=await r(),n=e.position;switch(await i(o.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){let t=fu.get(this.buffer,4),r=er.get(this.buffer,6);if(t>0&&t<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(r>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let t=new Be(4,"latin1").get(this.buffer,2);if(t.match("^d*")&&t>=1e3&&t<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new Be(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
168
168
  `,"\r"," "," ","\0"].some(t=>this.checkString(t,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){let t={ext:"png",mime:"image/png"},r={ext:"apng",mime:"image/apng"};await e.ignore(8);async function i(){return{length:await e.readToken(ay),type:await e.readToken(new Be(4,"latin1"))}}let o=Ce(e),n=e.position,a=0,c=!1;do{if(a++,a>WP||Oo(e,n,BP))break;let l=e.position,d=await i();if(d.length<0)return;if(d.type==="IHDR"){if(d.length!==13)return;c=!0}switch(d.type){case"IDAT":return t;case"acTL":return r;default:if(!c&&d.type!=="CgBI")return;if(o&&d.length>Gy)return c&&XP(d.type)?t:void 0;try{await Ps(e,d.length+4,{maximumLength:o?Gy+4:e.fileInfo.size,reason:"PNG chunk payload"})}catch(p){if(!o&&(p instanceof ss||p instanceof B))return t;throw p}}if(e.position<=l)break}while(e.position+8<e.fileInfo.size);return t}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let t=new Be(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(t){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return t.startsWith("3g")?t.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
169
169
  `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){let t=!1;try{async function r(){let a=new Uint8Array(16);return await ku(e,a,void 0,{maximumLength:a.length,reason:"ASF header GUID"}),{id:a,size:Number(await e.readToken(cy))}}await Ps(e,30,{maximumLength:30,reason:"ASF header prelude"});let i=Ce(e),o=e.position,n=0;for(;e.position+24<e.fileInfo.size&&(n++,!(n>MP||Oo(e,o,at)));){let a=e.position,c=await r(),l=c.size-24;if(!Number.isFinite(l)||l<0){t=!0;break}if(Ft(c.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let d=new Uint8Array(16);if(l-=await ku(e,d,void 0,{maximumLength:d.length,reason:"ASF stream type GUID"}),Ft(d,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(Ft(d,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(i&&l>zy){t=!0;break}if(await Ps(e,l,{maximumLength:i?zy:e.fileInfo.size,reason:"ASF header payload"}),e.position<=a){t=!0;break}}}catch(r){if(r instanceof B||r instanceof ss)Ce(e)&&(t=!0);else throw r}return t?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Be(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let t=new DataView(this.buffer.buffer).getUint32(12,!0);if(t>12&&this.buffer.length>=t+16)try{let r=new TextDecoder().decode(this.buffer.subarray(16,t+16));if(JSON.parse(r).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&qy(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let t="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:t})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:t})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
170
- `,{offset:2,encoding:t})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{this.buffer=new Uint8Array(ir);let t=nC(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,t),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,t),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let r=0;r<=this.options.mpegOffsetTolerance;++r){let i=this.scanMpeg(r);if(i)return i}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?er:te);switch(await this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?er:te);if(!(t>UP)&&!(Ce(this.tokenizer)&&2+t*12>Vy))for(let r=0;r<t;++r){let i=await this.readTiffTag(e);if(i)return i}}async readTiffHeader(e){let t={ext:"tif",mime:"image/tiff"},r=(e?er:te).get(this.buffer,2),i=(e?fu:Q).get(this.buffer,4);if(r===42){if(i>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8){let a=(e?er:te).get(this.buffer,8),c=(e?er:te).get(this.buffer,10);if(a===28&&c===254||a===31&&c===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(Ce(this.tokenizer)&&i>GP)return t;let o=Ce(this.tokenizer)?Vy:this.tokenizer.fileInfo.size;try{await Ps(this.tokenizer,i,{maximumLength:o,reason:"TIFF IFD offset"})}catch(a){if(a instanceof B)return;throw a}let n;try{n=await this.readTiffIFD(e)}catch(a){if(a instanceof B)return;throw a}return n??t}if(r===43)return t}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},e_=new Set(Iy),t_=new Set(jy)});var i_={};Gl(i_,{FileTypeParser:()=>si,fileTypeFromBlob:()=>Xy,fileTypeFromBuffer:()=>Qy,fileTypeFromFile:()=>fC,fileTypeFromStream:()=>mC,fileTypeFromTokenizer:()=>Zy,fileTypeStream:()=>hC,supportedExtensions:()=>e_,supportedMimeTypes:()=>t_});function uC(s){return!(s instanceof RangeError)||s.message!=="offset is out of bounds"||typeof s.stack!="string"?!1:/strtok3[/\\]lib[/\\]stream[/\\]/.test(s.stack)}async function fC(s,e){return new si(e).fromFile(s,e)}async function mC(s,e){return new si(e).fromStream(s)}async function hC(s,e={}){return new si(e).toDetectionStream(s,e)}var s_,Cs,r_,Eu,si,o_=$(()=>{s_=require("node:stream/web"),Cs=require("node:stream"),r_=O(require("node:fs/promises"),1),Eu=require("node:fs");ey();Su();Su();si=class extends or{async fromStream(e){this.options.signal?.throwIfAborted();let t=await(e instanceof s_.ReadableStream?this.createTokenizerFromWebStream(e):Zx(e,this.getTokenizerOptions()));try{return await super.fromTokenizer(t)}catch(r){if(uC(r))return;throw r}finally{e instanceof Cs.Readable&&!e.destroyed&&e.destroy()}}async fromFile(e){this.options.signal?.throwIfAborted();let t=await r_.default.open(e,Eu.constants.O_RDONLY|Eu.constants.O_NONBLOCK),r=await t.stat();if(!r.isFile()){await t.close();return}let i=new Zs(t,{...this.getTokenizerOptions(),fileInfo:{path:e,size:r.size}});return super.fromTokenizer(i)}async toDetectionStream(e,t={}){if(!(e instanceof Cs.Readable))return super.toDetectionStream(e,t);let{sampleSize:r=ir}=t,{signal:i}=this.options,o=vu(r);return i?.throwIfAborted(),new Promise((n,a)=>{let c=!1,l=()=>{e.off("error",p),e.off("readable",m),i?.removeEventListener("abort",u)},d=(h,f)=>{c||(c=!0,l(),h(f))},p=h=>{d(a,h)},u=()=>{e.destroyed||e.destroy(),d(a,i.reason)},m=()=>{(async()=>{try{let h=new Cs.PassThrough,f=Cs.pipeline?(0,Cs.pipeline)(e,h,()=>{}):e.pipe(h),g=e.read(o)??e.read()??new Uint8Array(0);try{h.fileType=await this.fromBuffer(g)}catch(b){b instanceof B?h.fileType=void 0:d(a,b)}d(n,f)}catch(h){d(a,h)}})()};e.on("error",p),e.once("readable",m),i?.addEventListener("abort",u,{once:!0})})}}});var rs=w((f7,g_)=>{"use strict";var m_=["nodebuffer","arraybuffer","fragments"],h_=typeof Blob<"u";h_&&m_.push("blob");g_.exports={BINARY_TYPES:m_,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:h_,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var jo=w((m7,pc)=>{"use strict";var{EMPTY_BUFFER:TC}=rs(),Tu=Buffer[Symbol.species];function $C(s,e){if(s.length===0)return TC;if(s.length===1)return s[0];let t=Buffer.allocUnsafe(e),r=0;for(let i=0;i<s.length;i++){let o=s[i];t.set(o,r),r+=o.length}return r<e?new Tu(t.buffer,t.byteOffset,r):t}function b_(s,e,t,r,i){for(let o=0;o<i;o++)t[r+o]=s[o]^e[o&3]}function x_(s,e){for(let t=0;t<s.length;t++)s[t]^=e[t&3]}function RC(s){return s.length===s.buffer.byteLength?s.buffer:s.buffer.slice(s.byteOffset,s.byteOffset+s.length)}function $u(s){if($u.readOnly=!0,Buffer.isBuffer(s))return s;let e;return s instanceof ArrayBuffer?e=new Tu(s):ArrayBuffer.isView(s)?e=new Tu(s.buffer,s.byteOffset,s.byteLength):(e=Buffer.from(s),$u.readOnly=!1),e}pc.exports={concat:$C,mask:b_,toArrayBuffer:RC,toBuffer:$u,unmask:x_};if(!process.env.WS_NO_BUFFER_UTIL)try{let s=require("bufferutil");pc.exports.mask=function(e,t,r,i,o){o<48?b_(e,t,r,i,o):s.mask(e,t,r,i,o)},pc.exports.unmask=function(e,t){e.length<32?x_(e,t):s.unmask(e,t)}}catch{}});var k_=w((h7,__)=>{"use strict";var y_=Symbol("kDone"),Ru=Symbol("kRun"),Au=class{constructor(e){this[y_]=()=>{this.pending--,this[Ru]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ru]()}[Ru](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[y_])}}};__.exports=Au});var ai=w((g7,E_)=>{"use strict";var Do=require("zlib"),w_=jo(),AC=k_(),{kStatusCode:v_}=rs(),PC=Buffer[Symbol.species],CC=Buffer.from([0,0,255,255]),uc=Symbol("permessage-deflate"),is=Symbol("total-length"),oi=Symbol("callback"),qs=Symbol("buffers"),ni=Symbol("error"),dc,Pu=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!dc){let t=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;dc=new AC(t)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[oi];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(i=>!(t.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>i.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(r=>{let i=t[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=i})}),e}decompress(e,t,r){dc.add(i=>{this._decompress(e,t,(o,n)=>{i(),r(o,n)})})}compress(e,t,r){dc.add(i=>{this._compress(e,t,(o,n)=>{i(),r(o,n)})})}_decompress(e,t,r){let i=this._isServer?"client":"server";if(!this._inflate){let o=`${i}_max_window_bits`,n=typeof this.params[o]!="number"?Do.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=Do.createInflateRaw({...this._options.zlibInflateOptions,windowBits:n}),this._inflate[uc]=this,this._inflate[is]=0,this._inflate[qs]=[],this._inflate.on("error",NC),this._inflate.on("data",S_)}this._inflate[oi]=r,this._inflate.write(e),t&&this._inflate.write(CC),this._inflate.flush(()=>{let o=this._inflate[ni];if(o){this._inflate.close(),this._inflate=null,r(o);return}let n=w_.concat(this._inflate[qs],this._inflate[is]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[is]=0,this._inflate[qs]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,n)})}_compress(e,t,r){let i=this._isServer?"server":"client";if(!this._deflate){let o=`${i}_max_window_bits`,n=typeof this.params[o]!="number"?Do.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=Do.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:n}),this._deflate[is]=0,this._deflate[qs]=[],this._deflate.on("data",qC)}this._deflate[oi]=r,this._deflate.write(e),this._deflate.flush(Do.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=w_.concat(this._deflate[qs],this._deflate[is]);t&&(o=new PC(o.buffer,o.byteOffset,o.length-4)),this._deflate[oi]=null,this._deflate[is]=0,this._deflate[qs]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,o)})}};E_.exports=Pu;function qC(s){this[qs].push(s),this[is]+=s.length}function S_(s){if(this[is]+=s.length,this[uc]._maxPayload<1||this[is]<=this[uc]._maxPayload){this[qs].push(s);return}this[ni]=new RangeError("Max payload size exceeded"),this[ni].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ni][v_]=1009,this.removeListener("data",S_),this.reset()}function NC(s){if(this[uc]._inflate=null,this[ni]){this[oi](this[ni]);return}s[v_]=1007,this[oi](s)}});var ci=w((b7,fc)=>{"use strict";var{isUtf8:T_}=require("buffer"),{hasBlob:OC}=rs(),IC=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function jC(s){return s>=1e3&&s<=1014&&s!==1004&&s!==1005&&s!==1006||s>=3e3&&s<=4999}function Cu(s){let e=s.length,t=0;for(;t<e;)if((s[t]&128)===0)t++;else if((s[t]&224)===192){if(t+1===e||(s[t+1]&192)!==128||(s[t]&254)===192)return!1;t+=2}else if((s[t]&240)===224){if(t+2>=e||(s[t+1]&192)!==128||(s[t+2]&192)!==128||s[t]===224&&(s[t+1]&224)===128||s[t]===237&&(s[t+1]&224)===160)return!1;t+=3}else if((s[t]&248)===240){if(t+3>=e||(s[t+1]&192)!==128||(s[t+2]&192)!==128||(s[t+3]&192)!==128||s[t]===240&&(s[t+1]&240)===128||s[t]===244&&s[t+1]>143||s[t]>244)return!1;t+=4}else return!1;return!0}function DC(s){return OC&&typeof s=="object"&&typeof s.arrayBuffer=="function"&&typeof s.type=="string"&&typeof s.stream=="function"&&(s[Symbol.toStringTag]==="Blob"||s[Symbol.toStringTag]==="File")}fc.exports={isBlob:DC,isValidStatusCode:jC,isValidUTF8:Cu,tokenChars:IC};if(T_)fc.exports.isValidUTF8=function(s){return s.length<24?Cu(s):T_(s)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let s=require("utf-8-validate");fc.exports.isValidUTF8=function(e){return e.length<32?Cu(e):s(e)}}catch{}});var ju=w((x7,N_)=>{"use strict";var{Writable:LC}=require("stream"),$_=ai(),{BINARY_TYPES:FC,EMPTY_BUFFER:R_,kStatusCode:WC,kWebSocket:BC}=rs(),{concat:qu,toArrayBuffer:MC,unmask:UC}=jo(),{isValidStatusCode:GC,isValidUTF8:A_}=ci(),mc=Buffer[Symbol.species],ct=0,P_=1,C_=2,q_=3,Nu=4,Ou=5,hc=6,Iu=class extends LC{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||FC[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[BC]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=ct}_write(e,t,r){if(this._opcode===8&&this._state==ct)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new mc(r.buffer,r.byteOffset+e,r.length-e),new mc(r.buffer,r.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=t.length-e;e>=r.length?t.set(this._buffers.shift(),i):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new mc(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case ct:this.getInfo(e);break;case P_:this.getPayloadLength16(e);break;case C_:this.getPayloadLength64(e);break;case q_:this.getMask();break;case Nu:this.getData(e);break;case Ou:case hc:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((t[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let r=(t[0]&64)===64;if(r&&!this._extensions[$_.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=P_:this._payloadLength===127?this._state=C_:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=q_:this._state=Nu}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Nu}getData(e){let t=R_;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&UC(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}if(this._compressed){this._state=Ou,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[$_.extensionName].decompress(e,this._fin,(i,o)=>{if(i)return t(i);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._fragments.push(o)}this.dataMessage(t),this._state===ct&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=ct;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=qu(r,t):this._binaryType==="arraybuffer"?i=MC(qu(r,t)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=ct):(this._state=hc,setImmediate(()=>{this.emit("message",i,!0),this._state=ct,this.startLoop(e)}))}else{let i=qu(r,t);if(!this._skipUTF8Validation&&!A_(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(o);return}this._state===Ou||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=ct):(this._state=hc,setImmediate(()=>{this.emit("message",i,!1),this._state=ct,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,R_),this.end();else{let r=e.readUInt16BE(0);if(!GC(r)){let o=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(o);return}let i=new mc(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!A_(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=ct;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ct):(this._state=hc,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ct,this.startLoop(t)}))}createError(e,t,r,i,o){this._loop=!1,this._errored=!0;let n=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(n,this.createError),n.code=o,n[WC]=i,n}};N_.exports=Iu});var Fu=w((_7,j_)=>{"use strict";var{Duplex:y7}=require("stream"),{randomFillSync:zC}=require("crypto"),{types:{isUint8Array:VC}}=require("util"),O_=ai(),{EMPTY_BUFFER:HC,kWebSocket:KC,NOOP:JC}=rs(),{isBlob:li,isValidStatusCode:YC}=ci(),{mask:I_,toBuffer:nr}=jo(),lt=Symbol("kByteLength"),QC=Buffer.alloc(4),gc=8*1024,ar,pi=gc,Tt=0,XC=1,ZC=2,Du=class s{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Tt,this.onerror=JC,this[KC]=void 0}static frame(e,t){let r,i=!1,o=2,n=!1;t.mask&&(r=t.maskBuffer||QC,t.generateMask?t.generateMask(r):(pi===gc&&(ar===void 0&&(ar=Buffer.alloc(gc)),zC(ar,0,gc),pi=0),r[0]=ar[pi++],r[1]=ar[pi++],r[2]=ar[pi++],r[3]=ar[pi++]),n=(r[0]|r[1]|r[2]|r[3])===0,o=6);let a;typeof e=="string"?(!t.mask||n)&&t[lt]!==void 0?a=t[lt]:(e=Buffer.from(e),a=e.length):(a=e.length,i=t.mask&&t.readOnly&&!n);let c=a;a>=65536?(o+=8,c=127):a>125&&(o+=2,c=126);let l=Buffer.allocUnsafe(i?a+o:o);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(a,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(a,4,6)),t.mask?(l[1]|=128,l[o-4]=r[0],l[o-3]=r[1],l[o-2]=r[2],l[o-1]=r[3],n?[l,e]:i?(I_(e,r,l,o,a),[l]):(I_(e,r,e,0,a),[l,e])):[l,e]}close(e,t,r,i){let o;if(e===void 0)o=HC;else{if(typeof e!="number"||!YC(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(e,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(o=Buffer.allocUnsafe(2+a),o.writeUInt16BE(e,0),typeof t=="string")o.write(t,2);else if(VC(t))o.set(t,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let n={[lt]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Tt?this.enqueue([this.dispatch,o,!1,n,i]):this.sendFrame(s.frame(o,n),i)}ping(e,t,r){let i,o;if(typeof e=="string"?(i=Buffer.byteLength(e),o=!1):li(e)?(i=e.size,o=!1):(e=nr(e),i=e.length,o=nr.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let n={[lt]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};li(e)?this._state!==Tt?this.enqueue([this.getBlobData,e,!1,n,r]):this.getBlobData(e,!1,n,r):this._state!==Tt?this.enqueue([this.dispatch,e,!1,n,r]):this.sendFrame(s.frame(e,n),r)}pong(e,t,r){let i,o;if(typeof e=="string"?(i=Buffer.byteLength(e),o=!1):li(e)?(i=e.size,o=!1):(e=nr(e),i=e.length,o=nr.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let n={[lt]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};li(e)?this._state!==Tt?this.enqueue([this.getBlobData,e,!1,n,r]):this.getBlobData(e,!1,n,r):this._state!==Tt?this.enqueue([this.dispatch,e,!1,n,r]):this.sendFrame(s.frame(e,n),r)}send(e,t,r){let i=this._extensions[O_.extensionName],o=t.binary?2:1,n=t.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):li(e)?(a=e.size,c=!1):(e=nr(e),a=e.length,c=nr.readOnly),this._firstFragment?(this._firstFragment=!1,n&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(n=a>=i._threshold),this._compress=n):(n=!1,o=0),t.fin&&(this._firstFragment=!0);let l={[lt]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:c,rsv1:n};li(e)?this._state!==Tt?this.enqueue([this.getBlobData,e,this._compress,l,r]):this.getBlobData(e,this._compress,l,r):this._state!==Tt?this.enqueue([this.dispatch,e,this._compress,l,r]):this.dispatch(e,this._compress,l,r)}getBlobData(e,t,r,i){this._bufferedBytes+=r[lt],this._state=ZC,e.arrayBuffer().then(o=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(Lu,this,a,i);return}this._bufferedBytes-=r[lt];let n=nr(o);t?this.dispatch(n,t,r,i):(this._state=Tt,this.sendFrame(s.frame(n,r),i),this.dequeue())}).catch(o=>{process.nextTick(eq,this,o,i)})}dispatch(e,t,r,i){if(!t){this.sendFrame(s.frame(e,r),i);return}let o=this._extensions[O_.extensionName];this._bufferedBytes+=r[lt],this._state=XC,o.compress(e,r.fin,(n,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");Lu(this,c,i);return}this._bufferedBytes-=r[lt],this._state=Tt,r.readOnly=!1,this.sendFrame(s.frame(a,r),i),this.dequeue()})}dequeue(){for(;this._state===Tt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][lt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][lt],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};j_.exports=Du;function Lu(s,e,t){typeof t=="function"&&t(e);for(let r=0;r<s._queue.length;r++){let i=s._queue[r],o=i[i.length-1];typeof o=="function"&&o(e)}}function eq(s,e,t){Lu(s,e,t),s.onerror(e)}});var z_=w((k7,G_)=>{"use strict";var{kForOnEventAttribute:Lo,kListener:Wu}=rs(),D_=Symbol("kCode"),L_=Symbol("kData"),F_=Symbol("kError"),W_=Symbol("kMessage"),B_=Symbol("kReason"),di=Symbol("kTarget"),M_=Symbol("kType"),U_=Symbol("kWasClean"),os=class{constructor(e){this[di]=null,this[M_]=e}get target(){return this[di]}get type(){return this[M_]}};Object.defineProperty(os.prototype,"target",{enumerable:!0});Object.defineProperty(os.prototype,"type",{enumerable:!0});var cr=class extends os{constructor(e,t={}){super(e),this[D_]=t.code===void 0?0:t.code,this[B_]=t.reason===void 0?"":t.reason,this[U_]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[D_]}get reason(){return this[B_]}get wasClean(){return this[U_]}};Object.defineProperty(cr.prototype,"code",{enumerable:!0});Object.defineProperty(cr.prototype,"reason",{enumerable:!0});Object.defineProperty(cr.prototype,"wasClean",{enumerable:!0});var ui=class extends os{constructor(e,t={}){super(e),this[F_]=t.error===void 0?null:t.error,this[W_]=t.message===void 0?"":t.message}get error(){return this[F_]}get message(){return this[W_]}};Object.defineProperty(ui.prototype,"error",{enumerable:!0});Object.defineProperty(ui.prototype,"message",{enumerable:!0});var Fo=class extends os{constructor(e,t={}){super(e),this[L_]=t.data===void 0?null:t.data}get data(){return this[L_]}};Object.defineProperty(Fo.prototype,"data",{enumerable:!0});var tq={addEventListener(s,e,t={}){for(let i of this.listeners(s))if(!t[Lo]&&i[Wu]===e&&!i[Lo])return;let r;if(s==="message")r=function(o,n){let a=new Fo("message",{data:n?o:o.toString()});a[di]=this,bc(e,this,a)};else if(s==="close")r=function(o,n){let a=new cr("close",{code:o,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[di]=this,bc(e,this,a)};else if(s==="error")r=function(o){let n=new ui("error",{error:o,message:o.message});n[di]=this,bc(e,this,n)};else if(s==="open")r=function(){let o=new os("open");o[di]=this,bc(e,this,o)};else return;r[Lo]=!!t[Lo],r[Wu]=e,t.once?this.once(s,r):this.on(s,r)},removeEventListener(s,e){for(let t of this.listeners(s))if(t[Wu]===e&&!t[Lo]){this.removeListener(s,t);break}}};G_.exports={CloseEvent:cr,ErrorEvent:ui,Event:os,EventTarget:tq,MessageEvent:Fo};function bc(s,e,t){typeof s=="object"&&s.handleEvent?s.handleEvent.call(s,t):s.call(e,t)}});var xc=w((w7,V_)=>{"use strict";var{tokenChars:Wo}=ci();function Bt(s,e,t){s[e]===void 0?s[e]=[t]:s[e].push(t)}function sq(s){let e=Object.create(null),t=Object.create(null),r=!1,i=!1,o=!1,n,a,c=-1,l=-1,d=-1,p=0;for(;p<s.length;p++)if(l=s.charCodeAt(p),n===void 0)if(d===-1&&Wo[l]===1)c===-1&&(c=p);else if(p!==0&&(l===32||l===9))d===-1&&c!==-1&&(d=p);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p);let m=s.slice(c,d);l===44?(Bt(e,m,t),t=Object.create(null)):n=m,c=d=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(a===void 0)if(d===-1&&Wo[l]===1)c===-1&&(c=p);else if(l===32||l===9)d===-1&&c!==-1&&(d=p);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p),Bt(t,s.slice(c,d),!0),l===44&&(Bt(e,n,t),t=Object.create(null),n=void 0),c=d=-1}else if(l===61&&c!==-1&&d===-1)a=s.slice(c,p),c=d=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(i){if(Wo[l]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1?c=p:r||(r=!0),i=!1}else if(o)if(Wo[l]===1)c===-1&&(c=p);else if(l===34&&c!==-1)o=!1,d=p;else if(l===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(l===34&&s.charCodeAt(p-1)===61)o=!0;else if(d===-1&&Wo[l]===1)c===-1&&(c=p);else if(c!==-1&&(l===32||l===9))d===-1&&(d=p);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p);let m=s.slice(c,d);r&&(m=m.replace(/\\/g,""),r=!1),Bt(t,a,m),l===44&&(Bt(e,n,t),t=Object.create(null),n=void 0),a=void 0,c=d=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(c===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");d===-1&&(d=p);let u=s.slice(c,d);return n===void 0?Bt(e,u,t):(a===void 0?Bt(t,u,!0):r?Bt(t,a,u.replace(/\\/g,"")):Bt(t,a,u),Bt(e,n,t)),e}function rq(s){return Object.keys(s).map(e=>{let t=s[e];return Array.isArray(t)||(t=[t]),t.map(r=>[e].concat(Object.keys(r).map(i=>{let o=r[i];return Array.isArray(o)||(o=[o]),o.map(n=>n===!0?i:`${i}=${n}`).join("; ")})).join("; ")).join(", ")}).join(", ")}V_.exports={format:rq,parse:sq}});var wc=w((E7,ik)=>{"use strict";var iq=require("events"),oq=require("https"),nq=require("http"),J_=require("net"),aq=require("tls"),{randomBytes:cq,createHash:lq}=require("crypto"),{Duplex:v7,Readable:S7}=require("stream"),{URL:Bu}=require("url"),Ns=ai(),pq=ju(),dq=Fu(),{isBlob:uq}=ci(),{BINARY_TYPES:H_,CLOSE_TIMEOUT:fq,EMPTY_BUFFER:yc,GUID:mq,kForOnEventAttribute:Mu,kListener:hq,kStatusCode:gq,kWebSocket:ye,NOOP:Y_}=rs(),{EventTarget:{addEventListener:bq,removeEventListener:xq}}=z_(),{format:yq,parse:_q}=xc(),{toBuffer:kq}=jo(),Q_=Symbol("kAborted"),Uu=[8,13],ns=["CONNECTING","OPEN","CLOSING","CLOSED"],wq=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,X=class s extends iq{constructor(e,t,r){super(),this._binaryType=H_[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=yc,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=s.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),X_(this,e,t,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){H_.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let i=new pq({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),o=new dq(e,this._extensions,r.generateMask);this._receiver=i,this._sender=o,this._socket=e,i[ye]=this,o[ye]=this,e[ye]=this,i.on("conclude",Eq),i.on("drain",Tq),i.on("error",$q),i.on("message",Rq),i.on("ping",Aq),i.on("pong",Pq),o.onerror=Cq,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",tk),e.on("data",kc),e.on("end",sk),e.on("error",rk),this._readyState=s.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=s.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ns.extensionName]&&this._extensions[Ns.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=s.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==s.CLOSED){if(this.readyState===s.CONNECTING){Je(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===s.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=s.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ek(this)}}pause(){this.readyState===s.CONNECTING||this.readyState===s.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===s.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==s.OPEN){Gu(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||yc,t,r)}pong(e,t,r){if(this.readyState===s.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==s.OPEN){Gu(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||yc,t,r)}resume(){this.readyState===s.CONNECTING||this.readyState===s.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===s.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==s.OPEN){Gu(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[Ns.extensionName]||(i.compress=!1),this._sender.send(e||yc,i,r)}terminate(){if(this.readyState!==s.CLOSED){if(this.readyState===s.CONNECTING){Je(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=s.CLOSING,this._socket.destroy())}}};Object.defineProperty(X,"CONNECTING",{enumerable:!0,value:ns.indexOf("CONNECTING")});Object.defineProperty(X.prototype,"CONNECTING",{enumerable:!0,value:ns.indexOf("CONNECTING")});Object.defineProperty(X,"OPEN",{enumerable:!0,value:ns.indexOf("OPEN")});Object.defineProperty(X.prototype,"OPEN",{enumerable:!0,value:ns.indexOf("OPEN")});Object.defineProperty(X,"CLOSING",{enumerable:!0,value:ns.indexOf("CLOSING")});Object.defineProperty(X.prototype,"CLOSING",{enumerable:!0,value:ns.indexOf("CLOSING")});Object.defineProperty(X,"CLOSED",{enumerable:!0,value:ns.indexOf("CLOSED")});Object.defineProperty(X.prototype,"CLOSED",{enumerable:!0,value:ns.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(s=>{Object.defineProperty(X.prototype,s,{enumerable:!0})});["open","error","close","message"].forEach(s=>{Object.defineProperty(X.prototype,`on${s}`,{enumerable:!0,get(){for(let e of this.listeners(s))if(e[Mu])return e[hq];return null},set(e){for(let t of this.listeners(s))if(t[Mu]){this.removeListener(s,t);break}typeof e=="function"&&this.addEventListener(s,e,{[Mu]:!0})}})});X.prototype.addEventListener=bq;X.prototype.removeEventListener=xq;ik.exports=X;function X_(s,e,t,r){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:fq,protocolVersion:Uu[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(s._autoPong=i.autoPong,s._closeTimeout=i.closeTimeout,!Uu.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Uu.join(", ")})`);let o;if(e instanceof Bu)o=e;else try{o=new Bu(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),s._url=o.href;let n=o.protocol==="wss:",a=o.protocol==="ws+unix:",c;if(o.protocol!=="ws:"&&!n&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!o.pathname?c="The URL's pathname is empty":o.hash&&(c="The URL contains a fragment identifier"),c){let f=new SyntaxError(c);if(s._redirects===0)throw f;_c(s,f);return}let l=n?443:80,d=cq(16).toString("base64"),p=n?oq.request:nq.request,u=new Set,m;if(i.createConnection=i.createConnection||(n?Sq:vq),i.defaultPort=i.defaultPort||l,i.port=o.port||l,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":d,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(m=new Ns({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=yq({[Ns.extensionName]:m.offer()})),t.length){for(let f of t){if(typeof f!="string"||!wq.test(f)||u.has(f))throw new SyntaxError("An invalid or duplicated subprotocol was specified");u.add(f)}i.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),a){let f=i.path.split(":");i.socketPath=f[0],i.path=f[1]}let h;if(i.followRedirects){if(s._redirects===0){s._originalIpc=a,s._originalSecure=n,s._originalHostOrSocketPath=a?i.socketPath:o.host;let f=r&&r.headers;if(r={...r,headers:{}},f)for(let[g,b]of Object.entries(f))r.headers[g.toLowerCase()]=b}else if(s.listenerCount("redirect")===0){let f=a?s._originalIpc?i.socketPath===s._originalHostOrSocketPath:!1:s._originalIpc?!1:o.host===s._originalHostOrSocketPath;(!f||s._originalSecure&&!n)&&(delete i.headers.authorization,delete i.headers.cookie,f||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),h=s._req=p(i),s._redirects&&s.emit("redirect",s.url,h)}else h=s._req=p(i);i.timeout&&h.on("timeout",()=>{Je(s,h,"Opening handshake has timed out")}),h.on("error",f=>{h===null||h[Q_]||(h=s._req=null,_c(s,f))}),h.on("response",f=>{let g=f.headers.location,b=f.statusCode;if(g&&i.followRedirects&&b>=300&&b<400){if(++s._redirects>i.maxRedirects){Je(s,h,"Maximum redirects exceeded");return}h.abort();let x;try{x=new Bu(g,e)}catch{let _=new SyntaxError(`Invalid URL: ${g}`);_c(s,_);return}X_(s,x,t,r)}else s.emit("unexpected-response",h,f)||Je(s,h,`Unexpected server response: ${f.statusCode}`)}),h.on("upgrade",(f,g,b)=>{if(s.emit("upgrade",f),s.readyState!==X.CONNECTING)return;h=s._req=null;let x=f.headers.upgrade;if(x===void 0||x.toLowerCase()!=="websocket"){Je(s,g,"Invalid Upgrade header");return}let y=lq("sha1").update(d+mq).digest("base64");if(f.headers["sec-websocket-accept"]!==y){Je(s,g,"Invalid Sec-WebSocket-Accept header");return}let _=f.headers["sec-websocket-protocol"],k;if(_!==void 0?u.size?u.has(_)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":u.size&&(k="Server sent no subprotocol"),k){Je(s,g,k);return}_&&(s._protocol=_);let S=f.headers["sec-websocket-extensions"];if(S!==void 0){if(!m){Je(s,g,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let T;try{T=_q(S)}catch{Je(s,g,"Invalid Sec-WebSocket-Extensions header");return}let E=Object.keys(T);if(E.length!==1||E[0]!==Ns.extensionName){Je(s,g,"Server indicated an extension that was not requested");return}try{m.accept(T[Ns.extensionName])}catch{Je(s,g,"Invalid Sec-WebSocket-Extensions header");return}s._extensions[Ns.extensionName]=m}s.setSocket(g,b,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(h,s):h.end()}function _c(s,e){s._readyState=X.CLOSING,s._errorEmitted=!0,s.emit("error",e),s.emitClose()}function vq(s){return s.path=s.socketPath,J_.connect(s)}function Sq(s){return s.path=void 0,!s.servername&&s.servername!==""&&(s.servername=J_.isIP(s.host)?"":s.host),aq.connect(s)}function Je(s,e,t){s._readyState=X.CLOSING;let r=new Error(t);Error.captureStackTrace(r,Je),e.setHeader?(e[Q_]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(_c,s,r)):(e.destroy(r),e.once("error",s.emit.bind(s,"error")),e.once("close",s.emitClose.bind(s)))}function Gu(s,e,t){if(e){let r=uq(e)?e.size:kq(e).length;s._socket?s._sender._bufferedBytes+=r:s._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${s.readyState} (${ns[s.readyState]})`);process.nextTick(t,r)}}function Eq(s,e){let t=this[ye];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=s,t._socket[ye]!==void 0&&(t._socket.removeListener("data",kc),process.nextTick(Z_,t._socket),s===1005?t.close():t.close(s,e))}function Tq(){let s=this[ye];s.isPaused||s._socket.resume()}function $q(s){let e=this[ye];e._socket[ye]!==void 0&&(e._socket.removeListener("data",kc),process.nextTick(Z_,e._socket),e.close(s[gq])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",s))}function K_(){this[ye].emitClose()}function Rq(s,e){this[ye].emit("message",s,e)}function Aq(s){let e=this[ye];e._autoPong&&e.pong(s,!this._isServer,Y_),e.emit("ping",s)}function Pq(s){this[ye].emit("pong",s)}function Z_(s){s.resume()}function Cq(s){let e=this[ye];e.readyState!==X.CLOSED&&(e.readyState===X.OPEN&&(e._readyState=X.CLOSING,ek(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",s)))}function ek(s){s._closeTimer=setTimeout(s._socket.destroy.bind(s._socket),s._closeTimeout)}function tk(){let s=this[ye];if(this.removeListener("close",tk),this.removeListener("data",kc),this.removeListener("end",sk),s._readyState=X.CLOSING,!this._readableState.endEmitted&&!s._closeFrameReceived&&!s._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);s._receiver.write(e)}s._receiver.end(),this[ye]=void 0,clearTimeout(s._closeTimer),s._receiver._writableState.finished||s._receiver._writableState.errorEmitted?s.emitClose():(s._receiver.on("error",K_),s._receiver.on("finish",K_))}function kc(s){this[ye]._receiver.write(s)||this.pause()}function sk(){let s=this[ye];s._readyState=X.CLOSING,s._receiver.end(),this.end()}function rk(){let s=this[ye];this.removeListener("error",rk),this.on("error",Y_),s&&(s._readyState=X.CLOSING,this.destroy())}});var ck=w(($7,ak)=>{"use strict";var T7=wc(),{Duplex:qq}=require("stream");function ok(s){s.emit("close")}function Nq(){!this.destroyed&&this._writableState.finished&&this.destroy()}function nk(s){this.removeListener("error",nk),this.destroy(),this.listenerCount("error")===0&&this.emit("error",s)}function Oq(s,e){let t=!0,r=new qq({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return s.on("message",function(o,n){let a=!n&&r._readableState.objectMode?o.toString():o;r.push(a)||s.pause()}),s.once("error",function(o){r.destroyed||(t=!1,r.destroy(o))}),s.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,o){if(s.readyState===s.CLOSED){o(i),process.nextTick(ok,r);return}let n=!1;s.once("error",function(c){n=!0,o(c)}),s.once("close",function(){n||o(i),process.nextTick(ok,r)}),t&&s.terminate()},r._final=function(i){if(s.readyState===s.CONNECTING){s.once("open",function(){r._final(i)});return}s._socket!==null&&(s._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(s._socket.once("finish",function(){i()}),s.close()))},r._read=function(){s.isPaused&&s.resume()},r._write=function(i,o,n){if(s.readyState===s.CONNECTING){s.once("open",function(){r._write(i,o,n)});return}s.send(i,n)},r.on("end",Nq),r.on("error",nk),r}ak.exports=Oq});var zu=w((R7,lk)=>{"use strict";var{tokenChars:Iq}=ci();function jq(s){let e=new Set,t=-1,r=-1,i=0;for(i;i<s.length;i++){let n=s.charCodeAt(i);if(r===-1&&Iq[n]===1)t===-1&&(t=i);else if(i!==0&&(n===32||n===9))r===-1&&t!==-1&&(r=i);else if(n===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let a=s.slice(t,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let o=s.slice(t,i);if(e.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return e.add(o),e}lk.exports={parse:jq}});var gk=w((P7,hk)=>{"use strict";var Dq=require("events"),vc=require("http"),{Duplex:A7}=require("stream"),{createHash:Lq}=require("crypto"),pk=xc(),lr=ai(),Fq=zu(),Wq=wc(),{CLOSE_TIMEOUT:Bq,GUID:Mq,kWebSocket:Uq}=rs(),Gq=/^[+/0-9A-Za-z]{22}==$/,dk=0,uk=1,mk=2,Vu=class extends Dq{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Bq,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Wq,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=vc.createServer((r,i)=>{let o=vc.STATUS_CODES[426];i.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),i.end(o)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=zq(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,o,n)=>{this.handleUpgrade(i,o,n,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=dk}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===mk){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Bo,this);return}if(e&&this.once("close",e),this._state!==uk)if(this._state=uk,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Bo,this):process.nextTick(Bo,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Bo(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,i){t.on("error",fk);let o=e.headers["sec-websocket-key"],n=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){pr(this,e,t,405,"Invalid HTTP method");return}if(n===void 0||n.toLowerCase()!=="websocket"){pr(this,e,t,400,"Invalid Upgrade header");return}if(o===void 0||!Gq.test(o)){pr(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){pr(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Mo(t,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=Fq.parse(c)}catch{pr(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let d=e.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&d!==void 0){let u=new lr({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let m=pk.parse(d);m[lr.extensionName]&&(u.accept(m[lr.extensionName]),p[lr.extensionName]=u)}catch{pr(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let u={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(u,(m,h,f,g)=>{if(!m)return Mo(t,h||401,f,g);this.completeUpgrade(p,o,l,e,t,r,i)});return}if(!this.options.verifyClient(u))return Mo(t,401)}this.completeUpgrade(p,o,l,e,t,r,i)}completeUpgrade(e,t,r,i,o,n,a){if(!o.readable||!o.writable)return o.destroy();if(o[Uq])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>dk)return Mo(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Lq("sha1").update(t+Mq).digest("base64")}`],d=new this.options.WebSocket(null,void 0,this.options);if(r.size){let p=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;p&&(l.push(`Sec-WebSocket-Protocol: ${p}`),d._protocol=p)}if(e[lr.extensionName]){let p=e[lr.extensionName].params,u=pk.format({[lr.extensionName]:[p]});l.push(`Sec-WebSocket-Extensions: ${u}`),d._extensions=e}this.emit("headers",l,i),o.write(l.concat(`\r
170
+ `,{offset:2,encoding:t})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{this.buffer=new Uint8Array(ir);let t=nC(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,t),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,t),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let r=0;r<=this.options.mpegOffsetTolerance;++r){let i=this.scanMpeg(r);if(i)return i}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?er:te);switch(await this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?er:te);if(!(t>UP)&&!(Ce(this.tokenizer)&&2+t*12>Vy))for(let r=0;r<t;++r){let i=await this.readTiffTag(e);if(i)return i}}async readTiffHeader(e){let t={ext:"tif",mime:"image/tiff"},r=(e?er:te).get(this.buffer,2),i=(e?fu:Q).get(this.buffer,4);if(r===42){if(i>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8){let a=(e?er:te).get(this.buffer,8),c=(e?er:te).get(this.buffer,10);if(a===28&&c===254||a===31&&c===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(Ce(this.tokenizer)&&i>GP)return t;let o=Ce(this.tokenizer)?Vy:this.tokenizer.fileInfo.size;try{await Ps(this.tokenizer,i,{maximumLength:o,reason:"TIFF IFD offset"})}catch(a){if(a instanceof B)return;throw a}let n;try{n=await this.readTiffIFD(e)}catch(a){if(a instanceof B)return;throw a}return n??t}if(r===43)return t}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},e_=new Set(Iy),t_=new Set(jy)});var i_={};Gl(i_,{FileTypeParser:()=>si,fileTypeFromBlob:()=>Xy,fileTypeFromBuffer:()=>Qy,fileTypeFromFile:()=>fC,fileTypeFromStream:()=>mC,fileTypeFromTokenizer:()=>Zy,fileTypeStream:()=>hC,supportedExtensions:()=>e_,supportedMimeTypes:()=>t_});function uC(s){return!(s instanceof RangeError)||s.message!=="offset is out of bounds"||typeof s.stack!="string"?!1:/strtok3[/\\]lib[/\\]stream[/\\]/.test(s.stack)}async function fC(s,e){return new si(e).fromFile(s,e)}async function mC(s,e){return new si(e).fromStream(s)}async function hC(s,e={}){return new si(e).toDetectionStream(s,e)}var s_,Cs,r_,Eu,si,o_=$(()=>{s_=require("node:stream/web"),Cs=require("node:stream"),r_=O(require("node:fs/promises"),1),Eu=require("node:fs");ey();Su();Su();si=class extends or{async fromStream(e){this.options.signal?.throwIfAborted();let t=await(e instanceof s_.ReadableStream?this.createTokenizerFromWebStream(e):Zx(e,this.getTokenizerOptions()));try{return await super.fromTokenizer(t)}catch(r){if(uC(r))return;throw r}finally{e instanceof Cs.Readable&&!e.destroyed&&e.destroy()}}async fromFile(e){this.options.signal?.throwIfAborted();let t=await r_.default.open(e,Eu.constants.O_RDONLY|Eu.constants.O_NONBLOCK),r=await t.stat();if(!r.isFile()){await t.close();return}let i=new Zs(t,{...this.getTokenizerOptions(),fileInfo:{path:e,size:r.size}});return super.fromTokenizer(i)}async toDetectionStream(e,t={}){if(!(e instanceof Cs.Readable))return super.toDetectionStream(e,t);let{sampleSize:r=ir}=t,{signal:i}=this.options,o=vu(r);return i?.throwIfAborted(),new Promise((n,a)=>{let c=!1,l=()=>{e.off("error",p),e.off("readable",m),i?.removeEventListener("abort",u)},d=(h,f)=>{c||(c=!0,l(),h(f))},p=h=>{d(a,h)},u=()=>{e.destroyed||e.destroy(),d(a,i.reason)},m=()=>{(async()=>{try{let h=new Cs.PassThrough,f=Cs.pipeline?(0,Cs.pipeline)(e,h,()=>{}):e.pipe(h),g=e.read(o)??e.read()??new Uint8Array(0);try{h.fileType=await this.fromBuffer(g)}catch(b){b instanceof B?h.fileType=void 0:d(a,b)}d(n,f)}catch(h){d(a,h)}})()};e.on("error",p),e.once("readable",m),i?.addEventListener("abort",u,{once:!0})})}}});var rs=w((fL,g_)=>{"use strict";var m_=["nodebuffer","arraybuffer","fragments"],h_=typeof Blob<"u";h_&&m_.push("blob");g_.exports={BINARY_TYPES:m_,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:h_,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var jo=w((mL,pc)=>{"use strict";var{EMPTY_BUFFER:TC}=rs(),Tu=Buffer[Symbol.species];function $C(s,e){if(s.length===0)return TC;if(s.length===1)return s[0];let t=Buffer.allocUnsafe(e),r=0;for(let i=0;i<s.length;i++){let o=s[i];t.set(o,r),r+=o.length}return r<e?new Tu(t.buffer,t.byteOffset,r):t}function b_(s,e,t,r,i){for(let o=0;o<i;o++)t[r+o]=s[o]^e[o&3]}function x_(s,e){for(let t=0;t<s.length;t++)s[t]^=e[t&3]}function RC(s){return s.length===s.buffer.byteLength?s.buffer:s.buffer.slice(s.byteOffset,s.byteOffset+s.length)}function $u(s){if($u.readOnly=!0,Buffer.isBuffer(s))return s;let e;return s instanceof ArrayBuffer?e=new Tu(s):ArrayBuffer.isView(s)?e=new Tu(s.buffer,s.byteOffset,s.byteLength):(e=Buffer.from(s),$u.readOnly=!1),e}pc.exports={concat:$C,mask:b_,toArrayBuffer:RC,toBuffer:$u,unmask:x_};if(!process.env.WS_NO_BUFFER_UTIL)try{let s=require("bufferutil");pc.exports.mask=function(e,t,r,i,o){o<48?b_(e,t,r,i,o):s.mask(e,t,r,i,o)},pc.exports.unmask=function(e,t){e.length<32?x_(e,t):s.unmask(e,t)}}catch{}});var k_=w((hL,__)=>{"use strict";var y_=Symbol("kDone"),Ru=Symbol("kRun"),Au=class{constructor(e){this[y_]=()=>{this.pending--,this[Ru]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ru]()}[Ru](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[y_])}}};__.exports=Au});var ai=w((gL,E_)=>{"use strict";var Do=require("zlib"),w_=jo(),AC=k_(),{kStatusCode:v_}=rs(),PC=Buffer[Symbol.species],CC=Buffer.from([0,0,255,255]),uc=Symbol("permessage-deflate"),is=Symbol("total-length"),oi=Symbol("callback"),qs=Symbol("buffers"),ni=Symbol("error"),dc,Pu=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!dc){let t=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;dc=new AC(t)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[oi];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(i=>!(t.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>i.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(r=>{let i=t[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=i})}),e}decompress(e,t,r){dc.add(i=>{this._decompress(e,t,(o,n)=>{i(),r(o,n)})})}compress(e,t,r){dc.add(i=>{this._compress(e,t,(o,n)=>{i(),r(o,n)})})}_decompress(e,t,r){let i=this._isServer?"client":"server";if(!this._inflate){let o=`${i}_max_window_bits`,n=typeof this.params[o]!="number"?Do.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=Do.createInflateRaw({...this._options.zlibInflateOptions,windowBits:n}),this._inflate[uc]=this,this._inflate[is]=0,this._inflate[qs]=[],this._inflate.on("error",NC),this._inflate.on("data",S_)}this._inflate[oi]=r,this._inflate.write(e),t&&this._inflate.write(CC),this._inflate.flush(()=>{let o=this._inflate[ni];if(o){this._inflate.close(),this._inflate=null,r(o);return}let n=w_.concat(this._inflate[qs],this._inflate[is]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[is]=0,this._inflate[qs]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,n)})}_compress(e,t,r){let i=this._isServer?"server":"client";if(!this._deflate){let o=`${i}_max_window_bits`,n=typeof this.params[o]!="number"?Do.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=Do.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:n}),this._deflate[is]=0,this._deflate[qs]=[],this._deflate.on("data",qC)}this._deflate[oi]=r,this._deflate.write(e),this._deflate.flush(Do.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=w_.concat(this._deflate[qs],this._deflate[is]);t&&(o=new PC(o.buffer,o.byteOffset,o.length-4)),this._deflate[oi]=null,this._deflate[is]=0,this._deflate[qs]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,o)})}};E_.exports=Pu;function qC(s){this[qs].push(s),this[is]+=s.length}function S_(s){if(this[is]+=s.length,this[uc]._maxPayload<1||this[is]<=this[uc]._maxPayload){this[qs].push(s);return}this[ni]=new RangeError("Max payload size exceeded"),this[ni].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ni][v_]=1009,this.removeListener("data",S_),this.reset()}function NC(s){if(this[uc]._inflate=null,this[ni]){this[oi](this[ni]);return}s[v_]=1007,this[oi](s)}});var ci=w((bL,fc)=>{"use strict";var{isUtf8:T_}=require("buffer"),{hasBlob:OC}=rs(),IC=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function jC(s){return s>=1e3&&s<=1014&&s!==1004&&s!==1005&&s!==1006||s>=3e3&&s<=4999}function Cu(s){let e=s.length,t=0;for(;t<e;)if((s[t]&128)===0)t++;else if((s[t]&224)===192){if(t+1===e||(s[t+1]&192)!==128||(s[t]&254)===192)return!1;t+=2}else if((s[t]&240)===224){if(t+2>=e||(s[t+1]&192)!==128||(s[t+2]&192)!==128||s[t]===224&&(s[t+1]&224)===128||s[t]===237&&(s[t+1]&224)===160)return!1;t+=3}else if((s[t]&248)===240){if(t+3>=e||(s[t+1]&192)!==128||(s[t+2]&192)!==128||(s[t+3]&192)!==128||s[t]===240&&(s[t+1]&240)===128||s[t]===244&&s[t+1]>143||s[t]>244)return!1;t+=4}else return!1;return!0}function DC(s){return OC&&typeof s=="object"&&typeof s.arrayBuffer=="function"&&typeof s.type=="string"&&typeof s.stream=="function"&&(s[Symbol.toStringTag]==="Blob"||s[Symbol.toStringTag]==="File")}fc.exports={isBlob:DC,isValidStatusCode:jC,isValidUTF8:Cu,tokenChars:IC};if(T_)fc.exports.isValidUTF8=function(s){return s.length<24?Cu(s):T_(s)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let s=require("utf-8-validate");fc.exports.isValidUTF8=function(e){return e.length<32?Cu(e):s(e)}}catch{}});var ju=w((xL,N_)=>{"use strict";var{Writable:LC}=require("stream"),$_=ai(),{BINARY_TYPES:FC,EMPTY_BUFFER:R_,kStatusCode:WC,kWebSocket:BC}=rs(),{concat:qu,toArrayBuffer:MC,unmask:UC}=jo(),{isValidStatusCode:GC,isValidUTF8:A_}=ci(),mc=Buffer[Symbol.species],ct=0,P_=1,C_=2,q_=3,Nu=4,Ou=5,hc=6,Iu=class extends LC{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||FC[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[BC]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=ct}_write(e,t,r){if(this._opcode===8&&this._state==ct)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new mc(r.buffer,r.byteOffset+e,r.length-e),new mc(r.buffer,r.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=t.length-e;e>=r.length?t.set(this._buffers.shift(),i):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new mc(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case ct:this.getInfo(e);break;case P_:this.getPayloadLength16(e);break;case C_:this.getPayloadLength64(e);break;case q_:this.getMask();break;case Nu:this.getData(e);break;case Ou:case hc:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((t[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let r=(t[0]&64)===64;if(r&&!this._extensions[$_.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=P_:this._payloadLength===127?this._state=C_:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=q_:this._state=Nu}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Nu}getData(e){let t=R_;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&UC(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}if(this._compressed){this._state=Ou,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[$_.extensionName].decompress(e,this._fin,(i,o)=>{if(i)return t(i);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._fragments.push(o)}this.dataMessage(t),this._state===ct&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=ct;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=qu(r,t):this._binaryType==="arraybuffer"?i=MC(qu(r,t)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=ct):(this._state=hc,setImmediate(()=>{this.emit("message",i,!0),this._state=ct,this.startLoop(e)}))}else{let i=qu(r,t);if(!this._skipUTF8Validation&&!A_(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(o);return}this._state===Ou||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=ct):(this._state=hc,setImmediate(()=>{this.emit("message",i,!1),this._state=ct,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,R_),this.end();else{let r=e.readUInt16BE(0);if(!GC(r)){let o=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(o);return}let i=new mc(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!A_(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=ct;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ct):(this._state=hc,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ct,this.startLoop(t)}))}createError(e,t,r,i,o){this._loop=!1,this._errored=!0;let n=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(n,this.createError),n.code=o,n[WC]=i,n}};N_.exports=Iu});var Fu=w((_L,j_)=>{"use strict";var{Duplex:yL}=require("stream"),{randomFillSync:zC}=require("crypto"),{types:{isUint8Array:VC}}=require("util"),O_=ai(),{EMPTY_BUFFER:HC,kWebSocket:KC,NOOP:JC}=rs(),{isBlob:li,isValidStatusCode:YC}=ci(),{mask:I_,toBuffer:nr}=jo(),lt=Symbol("kByteLength"),QC=Buffer.alloc(4),gc=8*1024,ar,pi=gc,Tt=0,XC=1,ZC=2,Du=class s{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Tt,this.onerror=JC,this[KC]=void 0}static frame(e,t){let r,i=!1,o=2,n=!1;t.mask&&(r=t.maskBuffer||QC,t.generateMask?t.generateMask(r):(pi===gc&&(ar===void 0&&(ar=Buffer.alloc(gc)),zC(ar,0,gc),pi=0),r[0]=ar[pi++],r[1]=ar[pi++],r[2]=ar[pi++],r[3]=ar[pi++]),n=(r[0]|r[1]|r[2]|r[3])===0,o=6);let a;typeof e=="string"?(!t.mask||n)&&t[lt]!==void 0?a=t[lt]:(e=Buffer.from(e),a=e.length):(a=e.length,i=t.mask&&t.readOnly&&!n);let c=a;a>=65536?(o+=8,c=127):a>125&&(o+=2,c=126);let l=Buffer.allocUnsafe(i?a+o:o);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(a,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(a,4,6)),t.mask?(l[1]|=128,l[o-4]=r[0],l[o-3]=r[1],l[o-2]=r[2],l[o-1]=r[3],n?[l,e]:i?(I_(e,r,l,o,a),[l]):(I_(e,r,e,0,a),[l,e])):[l,e]}close(e,t,r,i){let o;if(e===void 0)o=HC;else{if(typeof e!="number"||!YC(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(e,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(o=Buffer.allocUnsafe(2+a),o.writeUInt16BE(e,0),typeof t=="string")o.write(t,2);else if(VC(t))o.set(t,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let n={[lt]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Tt?this.enqueue([this.dispatch,o,!1,n,i]):this.sendFrame(s.frame(o,n),i)}ping(e,t,r){let i,o;if(typeof e=="string"?(i=Buffer.byteLength(e),o=!1):li(e)?(i=e.size,o=!1):(e=nr(e),i=e.length,o=nr.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let n={[lt]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};li(e)?this._state!==Tt?this.enqueue([this.getBlobData,e,!1,n,r]):this.getBlobData(e,!1,n,r):this._state!==Tt?this.enqueue([this.dispatch,e,!1,n,r]):this.sendFrame(s.frame(e,n),r)}pong(e,t,r){let i,o;if(typeof e=="string"?(i=Buffer.byteLength(e),o=!1):li(e)?(i=e.size,o=!1):(e=nr(e),i=e.length,o=nr.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let n={[lt]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};li(e)?this._state!==Tt?this.enqueue([this.getBlobData,e,!1,n,r]):this.getBlobData(e,!1,n,r):this._state!==Tt?this.enqueue([this.dispatch,e,!1,n,r]):this.sendFrame(s.frame(e,n),r)}send(e,t,r){let i=this._extensions[O_.extensionName],o=t.binary?2:1,n=t.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):li(e)?(a=e.size,c=!1):(e=nr(e),a=e.length,c=nr.readOnly),this._firstFragment?(this._firstFragment=!1,n&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(n=a>=i._threshold),this._compress=n):(n=!1,o=0),t.fin&&(this._firstFragment=!0);let l={[lt]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:c,rsv1:n};li(e)?this._state!==Tt?this.enqueue([this.getBlobData,e,this._compress,l,r]):this.getBlobData(e,this._compress,l,r):this._state!==Tt?this.enqueue([this.dispatch,e,this._compress,l,r]):this.dispatch(e,this._compress,l,r)}getBlobData(e,t,r,i){this._bufferedBytes+=r[lt],this._state=ZC,e.arrayBuffer().then(o=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(Lu,this,a,i);return}this._bufferedBytes-=r[lt];let n=nr(o);t?this.dispatch(n,t,r,i):(this._state=Tt,this.sendFrame(s.frame(n,r),i),this.dequeue())}).catch(o=>{process.nextTick(eq,this,o,i)})}dispatch(e,t,r,i){if(!t){this.sendFrame(s.frame(e,r),i);return}let o=this._extensions[O_.extensionName];this._bufferedBytes+=r[lt],this._state=XC,o.compress(e,r.fin,(n,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");Lu(this,c,i);return}this._bufferedBytes-=r[lt],this._state=Tt,r.readOnly=!1,this.sendFrame(s.frame(a,r),i),this.dequeue()})}dequeue(){for(;this._state===Tt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][lt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][lt],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};j_.exports=Du;function Lu(s,e,t){typeof t=="function"&&t(e);for(let r=0;r<s._queue.length;r++){let i=s._queue[r],o=i[i.length-1];typeof o=="function"&&o(e)}}function eq(s,e,t){Lu(s,e,t),s.onerror(e)}});var z_=w((kL,G_)=>{"use strict";var{kForOnEventAttribute:Lo,kListener:Wu}=rs(),D_=Symbol("kCode"),L_=Symbol("kData"),F_=Symbol("kError"),W_=Symbol("kMessage"),B_=Symbol("kReason"),di=Symbol("kTarget"),M_=Symbol("kType"),U_=Symbol("kWasClean"),os=class{constructor(e){this[di]=null,this[M_]=e}get target(){return this[di]}get type(){return this[M_]}};Object.defineProperty(os.prototype,"target",{enumerable:!0});Object.defineProperty(os.prototype,"type",{enumerable:!0});var cr=class extends os{constructor(e,t={}){super(e),this[D_]=t.code===void 0?0:t.code,this[B_]=t.reason===void 0?"":t.reason,this[U_]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[D_]}get reason(){return this[B_]}get wasClean(){return this[U_]}};Object.defineProperty(cr.prototype,"code",{enumerable:!0});Object.defineProperty(cr.prototype,"reason",{enumerable:!0});Object.defineProperty(cr.prototype,"wasClean",{enumerable:!0});var ui=class extends os{constructor(e,t={}){super(e),this[F_]=t.error===void 0?null:t.error,this[W_]=t.message===void 0?"":t.message}get error(){return this[F_]}get message(){return this[W_]}};Object.defineProperty(ui.prototype,"error",{enumerable:!0});Object.defineProperty(ui.prototype,"message",{enumerable:!0});var Fo=class extends os{constructor(e,t={}){super(e),this[L_]=t.data===void 0?null:t.data}get data(){return this[L_]}};Object.defineProperty(Fo.prototype,"data",{enumerable:!0});var tq={addEventListener(s,e,t={}){for(let i of this.listeners(s))if(!t[Lo]&&i[Wu]===e&&!i[Lo])return;let r;if(s==="message")r=function(o,n){let a=new Fo("message",{data:n?o:o.toString()});a[di]=this,bc(e,this,a)};else if(s==="close")r=function(o,n){let a=new cr("close",{code:o,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[di]=this,bc(e,this,a)};else if(s==="error")r=function(o){let n=new ui("error",{error:o,message:o.message});n[di]=this,bc(e,this,n)};else if(s==="open")r=function(){let o=new os("open");o[di]=this,bc(e,this,o)};else return;r[Lo]=!!t[Lo],r[Wu]=e,t.once?this.once(s,r):this.on(s,r)},removeEventListener(s,e){for(let t of this.listeners(s))if(t[Wu]===e&&!t[Lo]){this.removeListener(s,t);break}}};G_.exports={CloseEvent:cr,ErrorEvent:ui,Event:os,EventTarget:tq,MessageEvent:Fo};function bc(s,e,t){typeof s=="object"&&s.handleEvent?s.handleEvent.call(s,t):s.call(e,t)}});var xc=w((wL,V_)=>{"use strict";var{tokenChars:Wo}=ci();function Bt(s,e,t){s[e]===void 0?s[e]=[t]:s[e].push(t)}function sq(s){let e=Object.create(null),t=Object.create(null),r=!1,i=!1,o=!1,n,a,c=-1,l=-1,d=-1,p=0;for(;p<s.length;p++)if(l=s.charCodeAt(p),n===void 0)if(d===-1&&Wo[l]===1)c===-1&&(c=p);else if(p!==0&&(l===32||l===9))d===-1&&c!==-1&&(d=p);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p);let m=s.slice(c,d);l===44?(Bt(e,m,t),t=Object.create(null)):n=m,c=d=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(a===void 0)if(d===-1&&Wo[l]===1)c===-1&&(c=p);else if(l===32||l===9)d===-1&&c!==-1&&(d=p);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p),Bt(t,s.slice(c,d),!0),l===44&&(Bt(e,n,t),t=Object.create(null),n=void 0),c=d=-1}else if(l===61&&c!==-1&&d===-1)a=s.slice(c,p),c=d=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(i){if(Wo[l]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1?c=p:r||(r=!0),i=!1}else if(o)if(Wo[l]===1)c===-1&&(c=p);else if(l===34&&c!==-1)o=!1,d=p;else if(l===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(l===34&&s.charCodeAt(p-1)===61)o=!0;else if(d===-1&&Wo[l]===1)c===-1&&(c=p);else if(c!==-1&&(l===32||l===9))d===-1&&(d=p);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1&&(d=p);let m=s.slice(c,d);r&&(m=m.replace(/\\/g,""),r=!1),Bt(t,a,m),l===44&&(Bt(e,n,t),t=Object.create(null),n=void 0),a=void 0,c=d=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(c===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");d===-1&&(d=p);let u=s.slice(c,d);return n===void 0?Bt(e,u,t):(a===void 0?Bt(t,u,!0):r?Bt(t,a,u.replace(/\\/g,"")):Bt(t,a,u),Bt(e,n,t)),e}function rq(s){return Object.keys(s).map(e=>{let t=s[e];return Array.isArray(t)||(t=[t]),t.map(r=>[e].concat(Object.keys(r).map(i=>{let o=r[i];return Array.isArray(o)||(o=[o]),o.map(n=>n===!0?i:`${i}=${n}`).join("; ")})).join("; ")).join(", ")}).join(", ")}V_.exports={format:rq,parse:sq}});var wc=w((EL,ik)=>{"use strict";var iq=require("events"),oq=require("https"),nq=require("http"),J_=require("net"),aq=require("tls"),{randomBytes:cq,createHash:lq}=require("crypto"),{Duplex:vL,Readable:SL}=require("stream"),{URL:Bu}=require("url"),Ns=ai(),pq=ju(),dq=Fu(),{isBlob:uq}=ci(),{BINARY_TYPES:H_,CLOSE_TIMEOUT:fq,EMPTY_BUFFER:yc,GUID:mq,kForOnEventAttribute:Mu,kListener:hq,kStatusCode:gq,kWebSocket:ye,NOOP:Y_}=rs(),{EventTarget:{addEventListener:bq,removeEventListener:xq}}=z_(),{format:yq,parse:_q}=xc(),{toBuffer:kq}=jo(),Q_=Symbol("kAborted"),Uu=[8,13],ns=["CONNECTING","OPEN","CLOSING","CLOSED"],wq=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,X=class s extends iq{constructor(e,t,r){super(),this._binaryType=H_[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=yc,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=s.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),X_(this,e,t,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){H_.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let i=new pq({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),o=new dq(e,this._extensions,r.generateMask);this._receiver=i,this._sender=o,this._socket=e,i[ye]=this,o[ye]=this,e[ye]=this,i.on("conclude",Eq),i.on("drain",Tq),i.on("error",$q),i.on("message",Rq),i.on("ping",Aq),i.on("pong",Pq),o.onerror=Cq,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",tk),e.on("data",kc),e.on("end",sk),e.on("error",rk),this._readyState=s.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=s.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ns.extensionName]&&this._extensions[Ns.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=s.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==s.CLOSED){if(this.readyState===s.CONNECTING){Je(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===s.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=s.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ek(this)}}pause(){this.readyState===s.CONNECTING||this.readyState===s.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===s.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==s.OPEN){Gu(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||yc,t,r)}pong(e,t,r){if(this.readyState===s.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==s.OPEN){Gu(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||yc,t,r)}resume(){this.readyState===s.CONNECTING||this.readyState===s.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===s.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==s.OPEN){Gu(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[Ns.extensionName]||(i.compress=!1),this._sender.send(e||yc,i,r)}terminate(){if(this.readyState!==s.CLOSED){if(this.readyState===s.CONNECTING){Je(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=s.CLOSING,this._socket.destroy())}}};Object.defineProperty(X,"CONNECTING",{enumerable:!0,value:ns.indexOf("CONNECTING")});Object.defineProperty(X.prototype,"CONNECTING",{enumerable:!0,value:ns.indexOf("CONNECTING")});Object.defineProperty(X,"OPEN",{enumerable:!0,value:ns.indexOf("OPEN")});Object.defineProperty(X.prototype,"OPEN",{enumerable:!0,value:ns.indexOf("OPEN")});Object.defineProperty(X,"CLOSING",{enumerable:!0,value:ns.indexOf("CLOSING")});Object.defineProperty(X.prototype,"CLOSING",{enumerable:!0,value:ns.indexOf("CLOSING")});Object.defineProperty(X,"CLOSED",{enumerable:!0,value:ns.indexOf("CLOSED")});Object.defineProperty(X.prototype,"CLOSED",{enumerable:!0,value:ns.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(s=>{Object.defineProperty(X.prototype,s,{enumerable:!0})});["open","error","close","message"].forEach(s=>{Object.defineProperty(X.prototype,`on${s}`,{enumerable:!0,get(){for(let e of this.listeners(s))if(e[Mu])return e[hq];return null},set(e){for(let t of this.listeners(s))if(t[Mu]){this.removeListener(s,t);break}typeof e=="function"&&this.addEventListener(s,e,{[Mu]:!0})}})});X.prototype.addEventListener=bq;X.prototype.removeEventListener=xq;ik.exports=X;function X_(s,e,t,r){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:fq,protocolVersion:Uu[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(s._autoPong=i.autoPong,s._closeTimeout=i.closeTimeout,!Uu.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Uu.join(", ")})`);let o;if(e instanceof Bu)o=e;else try{o=new Bu(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),s._url=o.href;let n=o.protocol==="wss:",a=o.protocol==="ws+unix:",c;if(o.protocol!=="ws:"&&!n&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!o.pathname?c="The URL's pathname is empty":o.hash&&(c="The URL contains a fragment identifier"),c){let f=new SyntaxError(c);if(s._redirects===0)throw f;_c(s,f);return}let l=n?443:80,d=cq(16).toString("base64"),p=n?oq.request:nq.request,u=new Set,m;if(i.createConnection=i.createConnection||(n?Sq:vq),i.defaultPort=i.defaultPort||l,i.port=o.port||l,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":d,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(m=new Ns({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=yq({[Ns.extensionName]:m.offer()})),t.length){for(let f of t){if(typeof f!="string"||!wq.test(f)||u.has(f))throw new SyntaxError("An invalid or duplicated subprotocol was specified");u.add(f)}i.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),a){let f=i.path.split(":");i.socketPath=f[0],i.path=f[1]}let h;if(i.followRedirects){if(s._redirects===0){s._originalIpc=a,s._originalSecure=n,s._originalHostOrSocketPath=a?i.socketPath:o.host;let f=r&&r.headers;if(r={...r,headers:{}},f)for(let[g,b]of Object.entries(f))r.headers[g.toLowerCase()]=b}else if(s.listenerCount("redirect")===0){let f=a?s._originalIpc?i.socketPath===s._originalHostOrSocketPath:!1:s._originalIpc?!1:o.host===s._originalHostOrSocketPath;(!f||s._originalSecure&&!n)&&(delete i.headers.authorization,delete i.headers.cookie,f||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),h=s._req=p(i),s._redirects&&s.emit("redirect",s.url,h)}else h=s._req=p(i);i.timeout&&h.on("timeout",()=>{Je(s,h,"Opening handshake has timed out")}),h.on("error",f=>{h===null||h[Q_]||(h=s._req=null,_c(s,f))}),h.on("response",f=>{let g=f.headers.location,b=f.statusCode;if(g&&i.followRedirects&&b>=300&&b<400){if(++s._redirects>i.maxRedirects){Je(s,h,"Maximum redirects exceeded");return}h.abort();let x;try{x=new Bu(g,e)}catch{let _=new SyntaxError(`Invalid URL: ${g}`);_c(s,_);return}X_(s,x,t,r)}else s.emit("unexpected-response",h,f)||Je(s,h,`Unexpected server response: ${f.statusCode}`)}),h.on("upgrade",(f,g,b)=>{if(s.emit("upgrade",f),s.readyState!==X.CONNECTING)return;h=s._req=null;let x=f.headers.upgrade;if(x===void 0||x.toLowerCase()!=="websocket"){Je(s,g,"Invalid Upgrade header");return}let y=lq("sha1").update(d+mq).digest("base64");if(f.headers["sec-websocket-accept"]!==y){Je(s,g,"Invalid Sec-WebSocket-Accept header");return}let _=f.headers["sec-websocket-protocol"],k;if(_!==void 0?u.size?u.has(_)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":u.size&&(k="Server sent no subprotocol"),k){Je(s,g,k);return}_&&(s._protocol=_);let S=f.headers["sec-websocket-extensions"];if(S!==void 0){if(!m){Je(s,g,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let T;try{T=_q(S)}catch{Je(s,g,"Invalid Sec-WebSocket-Extensions header");return}let E=Object.keys(T);if(E.length!==1||E[0]!==Ns.extensionName){Je(s,g,"Server indicated an extension that was not requested");return}try{m.accept(T[Ns.extensionName])}catch{Je(s,g,"Invalid Sec-WebSocket-Extensions header");return}s._extensions[Ns.extensionName]=m}s.setSocket(g,b,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(h,s):h.end()}function _c(s,e){s._readyState=X.CLOSING,s._errorEmitted=!0,s.emit("error",e),s.emitClose()}function vq(s){return s.path=s.socketPath,J_.connect(s)}function Sq(s){return s.path=void 0,!s.servername&&s.servername!==""&&(s.servername=J_.isIP(s.host)?"":s.host),aq.connect(s)}function Je(s,e,t){s._readyState=X.CLOSING;let r=new Error(t);Error.captureStackTrace(r,Je),e.setHeader?(e[Q_]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(_c,s,r)):(e.destroy(r),e.once("error",s.emit.bind(s,"error")),e.once("close",s.emitClose.bind(s)))}function Gu(s,e,t){if(e){let r=uq(e)?e.size:kq(e).length;s._socket?s._sender._bufferedBytes+=r:s._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${s.readyState} (${ns[s.readyState]})`);process.nextTick(t,r)}}function Eq(s,e){let t=this[ye];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=s,t._socket[ye]!==void 0&&(t._socket.removeListener("data",kc),process.nextTick(Z_,t._socket),s===1005?t.close():t.close(s,e))}function Tq(){let s=this[ye];s.isPaused||s._socket.resume()}function $q(s){let e=this[ye];e._socket[ye]!==void 0&&(e._socket.removeListener("data",kc),process.nextTick(Z_,e._socket),e.close(s[gq])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",s))}function K_(){this[ye].emitClose()}function Rq(s,e){this[ye].emit("message",s,e)}function Aq(s){let e=this[ye];e._autoPong&&e.pong(s,!this._isServer,Y_),e.emit("ping",s)}function Pq(s){this[ye].emit("pong",s)}function Z_(s){s.resume()}function Cq(s){let e=this[ye];e.readyState!==X.CLOSED&&(e.readyState===X.OPEN&&(e._readyState=X.CLOSING,ek(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",s)))}function ek(s){s._closeTimer=setTimeout(s._socket.destroy.bind(s._socket),s._closeTimeout)}function tk(){let s=this[ye];if(this.removeListener("close",tk),this.removeListener("data",kc),this.removeListener("end",sk),s._readyState=X.CLOSING,!this._readableState.endEmitted&&!s._closeFrameReceived&&!s._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);s._receiver.write(e)}s._receiver.end(),this[ye]=void 0,clearTimeout(s._closeTimer),s._receiver._writableState.finished||s._receiver._writableState.errorEmitted?s.emitClose():(s._receiver.on("error",K_),s._receiver.on("finish",K_))}function kc(s){this[ye]._receiver.write(s)||this.pause()}function sk(){let s=this[ye];s._readyState=X.CLOSING,s._receiver.end(),this.end()}function rk(){let s=this[ye];this.removeListener("error",rk),this.on("error",Y_),s&&(s._readyState=X.CLOSING,this.destroy())}});var ck=w(($L,ak)=>{"use strict";var TL=wc(),{Duplex:qq}=require("stream");function ok(s){s.emit("close")}function Nq(){!this.destroyed&&this._writableState.finished&&this.destroy()}function nk(s){this.removeListener("error",nk),this.destroy(),this.listenerCount("error")===0&&this.emit("error",s)}function Oq(s,e){let t=!0,r=new qq({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return s.on("message",function(o,n){let a=!n&&r._readableState.objectMode?o.toString():o;r.push(a)||s.pause()}),s.once("error",function(o){r.destroyed||(t=!1,r.destroy(o))}),s.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,o){if(s.readyState===s.CLOSED){o(i),process.nextTick(ok,r);return}let n=!1;s.once("error",function(c){n=!0,o(c)}),s.once("close",function(){n||o(i),process.nextTick(ok,r)}),t&&s.terminate()},r._final=function(i){if(s.readyState===s.CONNECTING){s.once("open",function(){r._final(i)});return}s._socket!==null&&(s._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(s._socket.once("finish",function(){i()}),s.close()))},r._read=function(){s.isPaused&&s.resume()},r._write=function(i,o,n){if(s.readyState===s.CONNECTING){s.once("open",function(){r._write(i,o,n)});return}s.send(i,n)},r.on("end",Nq),r.on("error",nk),r}ak.exports=Oq});var zu=w((RL,lk)=>{"use strict";var{tokenChars:Iq}=ci();function jq(s){let e=new Set,t=-1,r=-1,i=0;for(i;i<s.length;i++){let n=s.charCodeAt(i);if(r===-1&&Iq[n]===1)t===-1&&(t=i);else if(i!==0&&(n===32||n===9))r===-1&&t!==-1&&(r=i);else if(n===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let a=s.slice(t,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let o=s.slice(t,i);if(e.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return e.add(o),e}lk.exports={parse:jq}});var gk=w((PL,hk)=>{"use strict";var Dq=require("events"),vc=require("http"),{Duplex:AL}=require("stream"),{createHash:Lq}=require("crypto"),pk=xc(),lr=ai(),Fq=zu(),Wq=wc(),{CLOSE_TIMEOUT:Bq,GUID:Mq,kWebSocket:Uq}=rs(),Gq=/^[+/0-9A-Za-z]{22}==$/,dk=0,uk=1,mk=2,Vu=class extends Dq{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Bq,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Wq,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=vc.createServer((r,i)=>{let o=vc.STATUS_CODES[426];i.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),i.end(o)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=zq(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,o,n)=>{this.handleUpgrade(i,o,n,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=dk}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===mk){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Bo,this);return}if(e&&this.once("close",e),this._state!==uk)if(this._state=uk,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Bo,this):process.nextTick(Bo,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Bo(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,i){t.on("error",fk);let o=e.headers["sec-websocket-key"],n=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){pr(this,e,t,405,"Invalid HTTP method");return}if(n===void 0||n.toLowerCase()!=="websocket"){pr(this,e,t,400,"Invalid Upgrade header");return}if(o===void 0||!Gq.test(o)){pr(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){pr(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Mo(t,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=Fq.parse(c)}catch{pr(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let d=e.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&d!==void 0){let u=new lr({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let m=pk.parse(d);m[lr.extensionName]&&(u.accept(m[lr.extensionName]),p[lr.extensionName]=u)}catch{pr(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let u={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(u,(m,h,f,g)=>{if(!m)return Mo(t,h||401,f,g);this.completeUpgrade(p,o,l,e,t,r,i)});return}if(!this.options.verifyClient(u))return Mo(t,401)}this.completeUpgrade(p,o,l,e,t,r,i)}completeUpgrade(e,t,r,i,o,n,a){if(!o.readable||!o.writable)return o.destroy();if(o[Uq])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>dk)return Mo(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Lq("sha1").update(t+Mq).digest("base64")}`],d=new this.options.WebSocket(null,void 0,this.options);if(r.size){let p=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;p&&(l.push(`Sec-WebSocket-Protocol: ${p}`),d._protocol=p)}if(e[lr.extensionName]){let p=e[lr.extensionName].params,u=pk.format({[lr.extensionName]:[p]});l.push(`Sec-WebSocket-Extensions: ${u}`),d._extensions=e}this.emit("headers",l,i),o.write(l.concat(`\r
171
171
  `).join(`\r
172
172
  `)),o.removeListener("error",fk),d.setSocket(o,n,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on("close",()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Bo,this)})),a(d,i)}};hk.exports=Vu;function zq(s,e){for(let t of Object.keys(e))s.on(t,e[t]);return function(){for(let r of Object.keys(e))s.removeListener(r,e[r])}}function Bo(s){s._state=mk,s.emit("close")}function fk(){this.destroy()}function Mo(s,e,t,r){t=t||vc.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t),...r},s.once("finish",s.destroy),s.end(`HTTP/1.1 ${e} ${vc.STATUS_CODES[e]}\r
173
173
  `+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
@@ -216,7 +216,7 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
216
216
  `)?"":`
217
217
  `;ee.writeFileSync(e,t+o+i.join(`
218
218
  `)+`
219
- `)}async function p_(s){return await gC(s,"manifest.yaml","manifest.yaml")}async function gC(s,e,t){if(!I.existsSync(s))return C.join(s,t);let i=(await I.promises.readdir(s)).find(o=>o.endsWith(e));return i?C.join(s,i):C.join(s,t)}function re(s){let e=C.basename(s).toLowerCase(),t="",r=!1;for(let i of e)i>="a"&&i<="z"||i>="0"&&i<="9"||i==="."||i==="-"?(t+=i,r=!1):r||(t+="_",r=!0);return t=t.replace(/^_+|_+$/g,"").replace(/^\.+/,""),t===""&&(t="file"),t}function bC(s,e){let t=C.posix.normalize(e.replaceAll("\\","/"));if(C.posix.isAbsolute(t)||t===".."||t.startsWith("../"))throw new Error(`invalid asset path: ${e}`);return C.posix.join(s.replaceAll("\\","/"),t)}function lc(s,e){let t=C.join(s,e+".py");if(I.existsSync(t))return t;if(!I.existsSync(s))return null;let i=I.readdirSync(s).find(o=>o.endsWith(".py"));return i?C.join(s,i):null}var xC=/\.[cm]?ts$/;async function yC(s,e="text/plain"){let{fileTypeFromFile:t}=await Promise.resolve().then(()=>(o_(),i_)),r=C.basename(s),i=(await t(s))?.mime;i||(i=xC.test(r)?"text/plain":n_.lookup(r)||e);let o=I.readFileSync(s);return kC(o)?{content_type:i,text:o.toString("utf8")}:{content_type:i,data:o.toString("base64")}}function _C(s){return s.text!==void 0?s.text.trim()==="":!s.data}function d_(s){try{let e=I.statSync(s);return e.size===0||e.size<4096&&I.readFileSync(s,"utf8").trim()===""}catch{return!1}}function kC(s){try{return new TextDecoder("utf-8",{fatal:!0}).decode(s),!0}catch{return!1}}var u_=new Set(["node_modules",".git","bun.lock","pnpm-lock.yaml","__pycache__"]),wC=new Set([Eo,To,Ba,So,Ma,".gitignore"]);async function ri(s,e,t){let r=d=>t?.add(C.resolve(d)),i=d=>(r(d),I.readFileSync(d,"utf8")),o=await p_(s);if(!I.existsSync(o)){e.error(`Manifest file ${o} not found`);return}let n=i(o),a=(0,a_.parse)(n);a.state="modified",a.updated_at=new Date().toISOString();let c=async(d,p,u,m)=>{let h=C.join(d,u);if(!I.existsSync(h))return;let f=p,g=f[u]=f[u]??{};await l(h,"",g,m),Object.keys(g).length===0&&delete f[u]};for(let d of a.modules??[]){let p=C.join(s,re(d.name));if(!I.existsSync(p)){e.error(`Module directory ${p} not found`);return}for(let u of d.tasks??[]){let m=re(u.name),h=C.join(p,m);if(!I.existsSync(h)){e.error(`Task directory ${h} not found`);continue}if(u.action.type==="code"||u.action.type==="python"){let f=lc(h,m);if(!f){e.error(`Task file for ${u.name} not found under ${h}`);return}u.action.value=i(f)}await c(h,u,"assets","text/plain"),await c(h,u,"design_docs","text/markdown")}if(d.tests&&d.tests.length>0){let u=new Map;for(let m of d.tests){let h=re(m.name),f=u.get(h);if(f!==void 0)throw new Error(`duplicate normalized test filename "${h}.py" in module "${d.name}": "${m.name}" conflicts with "${f}"`);u.set(h,m.name)}for(let m of d.tests){let h=re(m.name),f=C.join(p,"tests",h+".py");I.existsSync(f)&&(m.value=i(f))}}await c(p,d,"design_docs","text/markdown")}for(let[d,p]of[["library.py","library"],["schema.yaml","schema"],["logo.svg","logo"]]){let u=C.join(s,d);I.existsSync(u)&&!d_(u)&&(a[p]=i(u))}async function l(d,p,u,m="text/plain"){let h=I.readdirSync(d);for(let f of h){if(u_.has(f))continue;let g=C.join(d,f);if(await SC(g,e))continue;let b=I.lstatSync(g);if(b.isSymbolicLink()){e.log(`Skipping symbolic link in workblock assets: ${g}`);continue}let x=C.posix.join(p.replaceAll("\\","/"),f);if(b.isDirectory()){await l(g,x,u,m);continue}let y=await yC(g,m);if(_C(y)){e.log(`Empty file not stored by the platform, left out: ${g}`);continue}u[x]=y,r(g)}}for(let d of["react_components","python"]){if(!I.existsSync(C.join(s,d)))continue;let p=a[d]=a[d]??{};await l(C.join(s,d),"",p),Object.keys(p).length===0&&delete a[d]}return await c(s,a,"design_docs","text/markdown"),a}function Io(s){let e=s.split("/");return wC.has(e[0])||e.some(t=>u_.has(t))}function f_(s,e,t,r){let i=new Map;for(let c of e.modules??[])i.set(re(c.name),{name:c.name,tasks:new Map((c.tasks??[]).map(l=>[re(l.name),l.name]))});let o="not part of the workblock",n=c=>{let[l,d,p,...u]=c.split("/"),m=i.get(l);if(d===void 0||l==="react_components"||l==="python"||l==="design_docs")return o;if(!m)return`no module in manifest.yaml maps to the directory ${l}/`;if(d==="design_docs")return o;let h=p!==void 0&&u.length===0&&p.endsWith(".py");if(d==="tests")return h?`add a test named ${JSON.stringify(p.slice(0,-3))} under tests: of module ${JSON.stringify(m.name)} in manifest.yaml`:o;let f=m.tasks.get(d);return f?h?`only the task file of ${JSON.stringify(f)} is read; shared code goes in python/<name>.py or library.py`:o:`no task in module ${JSON.stringify(m.name)} maps to the directory ${l}/${d}/; add a task entry to manifest.yaml or delete it`},a=[];for(let c of r){let l=C.join(s,c);if(Io(c)||t.has(C.resolve(l)))continue;let d=I.lstatSync(l).isSymbolicLink()?"a symbolic link, which is never pushed":d_(l)?"an empty file; the platform stores none, so it is not pushed":n(c);a.push({path:c,hint:d})}return a}function vC(s){let e=s;for(I.statSync(e).isDirectory()||(e=C.dirname(e));e!==C.parse(e).root;){let t=C.join(e,".gitignore"),r=C.join(e,".git");if(I.existsSync(r))return I.existsSync(t)?e:null;e=C.dirname(e)}return null}async function SC(s,e){try{let t=vC(s);if(!t)return!1;let r=C.join(t,".gitignore"),i=I.readFileSync(r,"utf8"),o=C.relative(t,s),n=(0,c_.default)();return n.add(i),n.ignores(o)}catch(t){return e.log(`Error checking gitignore status: ${t}`),!1}}function cc(s,e){return C.relative(s,e).split(C.sep).join("/")}function EC(s,e,t,r){let i=C.resolve(s),o=[];for(let n of e??[]){if(t.has(n))continue;let a=C.relative(i,n);if(!a||a.startsWith("..")||C.isAbsolute(a))continue;I.rmSync(n,{force:!0}),o.push(a.split(C.sep).join("/"));let c=C.dirname(n);for(;c!==i&&c.startsWith(i+C.sep)&&!r.has(c)&&!(!I.existsSync(c)||I.readdirSync(c).length>0);)I.rmdirSync(c),c=C.dirname(c)}return o.sort()}async function ii(s,e,t,r={}){let i=await p_(s),o=C.resolve(s),n=[],a=(y,_,k=!1)=>{n.push({file:y,key:_,binary:k})},c=(y,_)=>{if(_)for(let[k,S]of Object.entries(_)){let T=bC(y.replaceAll("\\","/"),k),E=C.normalize(T);S.data&&(a(E,S.data,!0),delete S.data),S.text&&(a(E,S.text),delete S.text)}},l=(y,_)=>{_&&c(C.join(y,"design_docs"),_)},d=JSON.parse(JSON.stringify(e)),p=[];delete d.updated_at,delete d.state,delete d.actor,delete d.branch_user,delete d.storing;for(let y of d.modules??[]){let _=C.join(s,re(y.name));p.push(_);for(let k of y.tasks??[]){let S=k.action.type==="typescript";if(k.action.type!=="code"&&k.action.type!=="python"&&!S)continue;let T=re(k.name),E=C.join(_,T);if(!S){let P=lc(E,T)??C.join(E,`${T}.py`);a(P,k.action.value??"")}k.assets&&c(C.join(_,T,"assets"),k.assets),delete k.created_at,delete k.updated_at,S||delete k.action.value,delete k.assets,l(E,k.design_docs),delete k.design_docs}if(y.tests&&y.tests.length>0){let k=new Map;for(let S of y.tests){let T=re(S.name),E=k.get(T);if(E!==void 0)throw new Error(`duplicate normalized test filename "${T}.py" in module "${y.name}": "${S.name}" conflicts with "${E}"`);if(k.set(T,S.name),S.value&&S.value.trim()!==""){let v=C.join(_,"tests",T+".py");a(v,S.value),delete S.value}}}l(_,y.design_docs),delete y.design_docs}d.library&&a(C.join(s,"library.py"),d.library),d.schema&&a(C.join(s,"schema.yaml"),d.schema),d.logo&&a(C.join(s,"logo.svg"),d.logo),d.react_components&&c(C.join(s,"react_components"),d.react_components),d.python&&c(C.join(s,"python"),d.python),l(s,d.design_docs);let u=new Set([i,...n.map(y=>y.file)].map(y=>C.resolve(y)));for(let y of p)if(u.has(C.resolve(y)))throw new Error(`module directory "${cc(o,C.resolve(y))}" collides with a workblock file`);let m=await Promise.all(n.map(async({file:y,key:_,binary:k})=>{let S=await t.getBlob(_);return{file:y,bytes:k?Buffer.from(S,"base64"):Buffer.from(S,"utf8")}}));for(let y of p)I.mkdirSync(y,{recursive:!0});let h=EC(s,r.previouslyRead,u,new Set(p.map(y=>C.resolve(y)))),f=new Map;for(let{file:y,bytes:_}of m)f.set(cc(o,C.resolve(y)),_),!(r.sent?.get(C.resolve(y))?.equals(_)||I.existsSync(y)&&I.readFileSync(y).equals(_))&&(I.mkdirSync(C.dirname(y),{recursive:!0}),I.writeFileSync(y,_));let g=JSON.parse(JSON.stringify(d));delete g.updated_at,delete g.state,delete g.branch_user,delete g.storing,delete g.actor,delete g.library,delete g.logo,delete g.react_components,delete g.python,delete g.schema,delete g.design_docs;let b=Buffer.from((0,l_.stringify)(g),"utf8");return f.set(cc(o,C.resolve(i)),b),r.sent?.get(C.resolve(i))?.equals(b)||I.existsSync(i)&&I.readFileSync(i).equals(b)||I.writeFileSync(i,b),{written:[...u].map(y=>cc(o,y)).sort(),contents:f,removed:h}}var Ku=require("crypto"),Ye=O(require("fs")),$t=O(require("path"));var Vq=O(ck(),1),Hq=O(xc(),1),Kq=O(ai(),1),Jq=O(ju(),1),Yq=O(Fu(),1),Qq=O(zu(),1),bk=O(wc(),1),Xq=O(gk(),1);var Sc=bk.default;var Ec=class{constructor(e,t){this.client=e,this.analyticsClient=t??null}async acceptThreadWorkblock(e,t){return await this.requestWithTracking("accept_thread_workblock",e,t)}async acceptTos(e,t){return await this.requestWithTracking("accept_tos",e,t)}async addGroupMember(e,t){return await this.requestWithTracking("add_group_member",e,t)}async applyWorkblockDeployedUpdates(e,t){return await this.requestWithTracking("apply_workblock_deployed_updates",e,t)}async applyWorkblockVersionUpdates(e,t){return await this.requestWithTracking("apply_workblock_version_updates",e,t)}async approveLearningData(e,t){return await this.requestWithTracking("approve_learning_data",e,t)}async askAgent(e,t){return await this.requestWithTracking("ask_agent",e,t)}async assign(e,t){return await this.requestWithTracking("assign",e,t)}async assignEditStream(e,t){return await this.requestWithTracking("assign_edit_stream",e,t)}async assignWorkBlockRuns(e,t){return await this.requestWithTracking("assign_work_block_runs",e,t)}async authzSchemaApply(e,t){return await this.requestWithTracking("authz_schema_apply",e,t)}async authzSchemaDraftEmitAwarenessEvent(e,t){return await this.requestWithTracking("authz_schema_draft_emit_awareness_event",e,t)}async authzSchemaDraftEmitEvent(e,t){return await this.requestWithTracking("authz_schema_draft_emit_event",e,t)}async authzSchemaForceApply(e,t){return await this.requestWithTracking("authz_schema_force_apply",e,t)}async authzSchemaGrantRoleMembership(e,t){return await this.requestWithTracking("authz_schema_grant_role_membership",e,t)}async authzSchemaInitializeForWorkblock(e,t){return await this.requestWithTracking("authz_schema_initialize_for_workblock",e,t)}async authzSchemaPropose(e,t){return await this.requestWithTracking("authz_schema_propose",e,t)}async authzSchemaRevokeRoleMembership(e,t){return await this.requestWithTracking("authz_schema_revoke_role_membership",e,t)}async bulkTagLearningExamples(e,t){return await this.requestWithTracking("bulk_tag_learning_examples",e,t)}async cancelAgent(e,t){return await this.requestWithTracking("cancel_agent",e,t)}async cancelChild(e,t){return await this.requestWithTracking("cancel_child",e,t)}async cancelWb(e,t){return await this.requestWithTracking("cancel_wb",e,t)}async changelogMarkSeen(e,t){return await this.requestWithTracking("changelog_mark_seen",e,t)}async chatQueue(e,t){return await this.requestWithTracking("chat_queue",e,t)}async closeStream(e,t){return await this.requestWithTracking("close_stream",e,t)}async completeChild(e,t){return await this.requestWithTracking("complete_child",e,t)}async completeCredentialOauth(e,t){return await this.requestWithTracking("complete_credential_oauth",e,t)}async completeRunCredentialOauth(e,t){return await this.requestWithTracking("complete_run_credential_oauth",e,t)}async continueFromMessage(e,t){return await this.requestWithTracking("continue_from_message",e,t)}async continueUi(e,t){return await this.requestWithTracking("continue_ui",e,t)}async convertLegacyStream(e,t){return await this.requestWithTracking("convert_legacy_stream",e,t)}async createAccessToken(e,t){return await this.requestWithTracking("create_access_token",e,t)}async createCredential(e,t){return await this.requestWithTracking("create_credential",e,t)}async createGroup(e,t){return await this.requestWithTracking("create_group",e,t)}async createOauthClient(e,t){return await this.requestWithTracking("create_oauth_client",e,t)}async createOauthRegistrationToken(e,t){return await this.requestWithTracking("create_oauth_registration_token",e,t)}async createStream(e,t){return await this.requestWithTracking("create_stream",e,t)}async createStudioWorkspace(e,t){return await this.requestWithTracking("create_studio_workspace",e,t)}async createUser(e,t){return await this.requestWithTracking("create_user",e,t)}async createWorkblock(e,t){return await this.requestWithTracking("create_workblock",e,t)}async createWorkblockSchedule(e,t){return await this.requestWithTracking("create_workblock_schedule",e,t)}async createWorkblockVersion(e,t){return await this.requestWithTracking("create_workblock_version",e,t)}async createWorkblockVersionUpdate(e,t){return await this.requestWithTracking("create_workblock_version_update",e,t)}async deleteAccessToken(e,t){return await this.requestWithTracking("delete_access_token",e,t)}async deleteAllWorkblockRegistrationEvents(e,t){return await this.requestWithTracking("delete_all_workblock_registration_events",e,t)}async deleteCredential(e,t){return await this.requestWithTracking("delete_credential",e,t)}async deleteGroup(e,t){return await this.requestWithTracking("delete_group",e,t)}async deleteLearningExample(e,t){return await this.requestWithTracking("delete_learning_example",e,t)}async deleteOauthClient(e,t){return await this.requestWithTracking("delete_oauth_client",e,t)}async deleteSpace(e,t){return await this.requestWithTracking("delete_space",e,t)}async deleteStudioWorkspace(e,t){return await this.requestWithTracking("delete_studio_workspace",e,t)}async deleteWorkblock(e,t){return await this.requestWithTracking("delete_workblock",e,t)}async deleteWorkblockBranch(e,t){return await this.requestWithTracking("delete_workblock_branch",e,t)}async deleteWorkblockRegistration(e,t){return await this.requestWithTracking("delete_workblock_registration",e,t)}async deleteWorkblockRegistrationEvent(e,t){return await this.requestWithTracking("delete_workblock_registration_event",e,t)}async deleteWorkblockRunDataTruncation(e,t){return await this.requestWithTracking("delete_workblock_run_data_truncation",e,t)}async deleteWorkblockSchedule(e,t){return await this.requestWithTracking("delete_workblock_schedule",e,t)}async deployWorkblockVersion(e,t){return await this.requestWithTracking("deploy_workblock_version",e,t)}async disableWorkblockRegistration(e,t){return await this.requestWithTracking("disable_workblock_registration",e,t)}async discardPermissionRequest(e,t){return await this.requestWithTracking("discard_permission_request",e,t)}async dismissNotification(e,t){return await this.requestWithTracking("dismiss_notification",e,t)}async enableWorkblockRegistration(e,t){return await this.requestWithTracking("enable_workblock_registration",e,t)}async ensureStreamBranchHead(e,t){return await this.requestWithTracking("ensure_stream_branch_head",e,t)}async getEditStream(e,t){return await this.requestWithTracking("get_edit_stream",e,t)}async getSpaceStream(e,t){return await this.requestWithTracking("get_space_stream",e,t)}async help(e,t){return await this.requestWithTracking("help",e,t)}async initiateCredentialOauth(e,t){return await this.requestWithTracking("initiate_credential_oauth",e,t)}async initiateTaskCredentialOauth(e,t){return await this.requestWithTracking("initiate_task_credential_oauth",e,t)}async insertTasks(e,t){return await this.requestWithTracking("insert_tasks",e,t)}async installWorkblock(e,t){return await this.requestWithTracking("install_workblock",e,t)}async interruptChild(e,t){return await this.requestWithTracking("interrupt_child",e,t)}async invokeWorkblockTask(e,t){return await this.requestWithTracking("invoke_workblock_task",e,t)}async join(e,t){return await this.requestWithTracking("join",e,t)}async leave(e,t){return await this.requestWithTracking("leave",e,t)}async markAllNotificationsRead(e,t){return await this.requestWithTracking("mark_all_notifications_read",e,t)}async markNotificationRead(e,t){return await this.requestWithTracking("mark_notification_read",e,t)}async mergeWorkblockBranch(e,t){return await this.requestWithTracking("merge_workblock_branch",e,t)}async messageChild(e,t){return await this.requestWithTracking("message_child",e,t)}async peekWorkblockRegistrationEvents(e,t){return await this.requestWithTracking("peek_workblock_registration_events",e,t)}async permissionsGrant(e,t){return await this.requestWithTracking("permissions_grant",e,t)}async permissionsRevoke(e,t){return await this.requestWithTracking("permissions_revoke",e,t)}async publishToRegistry(e,t){return await this.requestWithTracking("publish_to_registry",e,t)}async recreateEditStream(e,t){return await this.requestWithTracking("recreate_edit_stream",e,t)}async reembedValidationSet(e,t){return await this.requestWithTracking("reembed_validation_set",e,t)}async registerWorkblockEvent(e,t){return await this.requestWithTracking("register_workblock_event",e,t)}async registrySearch(e,t){return await this.requestWithTracking("registry_search",e,t)}async registrySetParameters(e,t){return await this.requestWithTracking("registry_set_parameters",e,t)}async registrySetTags(e,t){return await this.requestWithTracking("registry_set_tags",e,t)}async rejectLearningData(e,t){return await this.requestWithTracking("reject_learning_data",e,t)}async rejectThreadWorkblock(e,t){return await this.requestWithTracking("reject_thread_workblock",e,t)}async remixWorkblockV2(e,t){return await this.requestWithTracking("remix_workblock_v2",e,t)}async removeGroupMember(e,t){return await this.requestWithTracking("remove_group_member",e,t)}async removeThread(e,t){return await this.requestWithTracking("remove_thread",e,t)}async requestPermission(e,t){return await this.requestWithTracking("request_permission",e,t)}async resetTask(e,t){return await this.requestWithTracking("reset_task",e,t)}async resetWorkblockBranch(e,t){return await this.requestWithTracking("reset_workblock_branch",e,t)}async resolveWorkblockMergeConflicts(e,t){return await this.requestWithTracking("resolve_workblock_merge_conflicts",e,t)}async restartStudioWorkspaceThread(e,t){return await this.requestWithTracking("restart_studio_workspace_thread",e,t)}async restartWorkblock(e,t){return await this.requestWithTracking("restart_workblock",e,t)}async resumeRetry(e,t){return await this.requestWithTracking("resume_retry",e,t)}async revertWorkblockCommit(e,t){return await this.requestWithTracking("revert_workblock_commit",e,t)}async revokeAllOauthConsents(e,t){return await this.requestWithTracking("revoke_all_oauth_consents",e,t)}async revokeOauthConsent(e,t){return await this.requestWithTracking("revoke_oauth_consent",e,t)}async revokeOauthRegistrationToken(e,t){return await this.requestWithTracking("revoke_oauth_registration_token",e,t)}async rotateOauthClientSecret(e,t){return await this.requestWithTracking("rotate_oauth_client_secret",e,t)}async runModule(e,t){return await this.requestWithTracking("run_module",e,t)}async runSingleTask(e,t){return await this.requestWithTracking("run_single_task",e,t)}async runSubgraph(e,t){return await this.requestWithTracking("run_subgraph",e,t)}async runTask(e,t){return await this.requestWithTracking("run_task",e,t)}async runWorkblockReplayTests(e,t){return await this.requestWithTracking("run_workblock_replay_tests",e,t)}async runtimeAuthzAttachRole(e,t){return await this.requestWithTracking("runtime_authz_attach_role",e,t)}async runtimeAuthzDeleteRelation(e,t){return await this.requestWithTracking("runtime_authz_delete_relation",e,t)}async runtimeAuthzDetachRole(e,t){return await this.requestWithTracking("runtime_authz_detach_role",e,t)}async runtimeAuthzStoreRelation(e,t){return await this.requestWithTracking("runtime_authz_store_relation",e,t)}async sendMessage(e,t){return await this.requestWithTracking("send_message",e,t)}async setActiveWorkblockSetting(e,t){return await this.requestWithTracking("set_active_workblock_setting",e,t)}async setAutoApproveConfig(e,t){return await this.requestWithTracking("set_auto_approve_config",e,t)}async setConsumptionLimits(e,t){return await this.requestWithTracking("set_consumption_limits",e,t)}async setEditing(e,t){return await this.requestWithTracking("set_editing",e,t)}async setKeepOpenOnComplete(e,t){return await this.requestWithTracking("set_keep_open_on_complete",e,t)}async setLegalHold(e,t){return await this.requestWithTracking("set_legal_hold",e,t)}async setLogging(e,t){return await this.requestWithTracking("set_logging",e,t)}async setOauthClientEnabled(e,t){return await this.requestWithTracking("set_oauth_client_enabled",e,t)}async setRetentionPolicy(e,t){return await this.requestWithTracking("set_retention_policy",e,t)}async setStudioWorkspaceArchived(e,t){return await this.requestWithTracking("set_studio_workspace_archived",e,t)}async setStudioWorkspaceThread(e,t){return await this.requestWithTracking("set_studio_workspace_thread",e,t)}async setUserSetting(e,t){return await this.requestWithTracking("set_user_setting",e,t)}async setWorkBlock(e,t){return await this.requestWithTracking("set_work_block",e,t)}async setWorkBlockV2(e,t){return await this.requestWithTracking("set_work_block_v2",e,t)}async setWorkblockCommitMessage(e,t){return await this.requestWithTracking("set_workblock_commit_message",e,t)}async setWorkblockRunDataTruncation(e,t){return await this.requestWithTracking("set_workblock_run_data_truncation",e,t)}async setWorkblockSchedulePaused(e,t){return await this.requestWithTracking("set_workblock_schedule_paused",e,t)}async startBranchThread(e,t){return await this.requestWithTracking("start_branch_thread",e,t)}async startWb(e,t){return await this.requestWithTracking("start_wb",e,t)}async storeWorkBlock(e,t){return await this.requestWithTracking("store_work_block",e,t)}async switchStreamBranch(e,t){return await this.requestWithTracking("switch_stream_branch",e,t)}async syncWorkblock(e,t){return await this.requestWithTracking("sync_workblock",e,t)}async syncWorkblockVersion(e,t){return await this.requestWithTracking("sync_workblock_version",e,t)}async temporalCancelWorkflow(e,t){return await this.requestWithTracking("temporal_cancel_workflow",e,t)}async temporalResetWorkflow(e,t){return await this.requestWithTracking("temporal_reset_workflow",e,t)}async temporalSignalWorkflow(e,t){return await this.requestWithTracking("temporal_signal_workflow",e,t)}async temporalTerminateWorkflow(e,t){return await this.requestWithTracking("temporal_terminate_workflow",e,t)}async transcribeAudio(e,t){return await this.requestWithTracking("transcribe_audio",e,t)}async triggerWorkblockSchedule(e,t){return await this.requestWithTracking("trigger_workblock_schedule",e,t)}async uninstallWorkblock(e,t){return await this.requestWithTracking("uninstall_workblock",e,t)}async updateAccessToken(e,t){return await this.requestWithTracking("update_access_token",e,t)}async updateAccount(e,t){return await this.requestWithTracking("update_account",e,t)}async updateCredential(e,t){return await this.requestWithTracking("update_credential",e,t)}async updateGroup(e,t){return await this.requestWithTracking("update_group",e,t)}async updateLearningExample(e,t){return await this.requestWithTracking("update_learning_example",e,t)}async updateOauthClient(e,t){return await this.requestWithTracking("update_oauth_client",e,t)}async updateProfile(e,t){return await this.requestWithTracking("update_profile",e,t)}async updateStudioWorkspaceTitle(e,t){return await this.requestWithTracking("update_studio_workspace_title",e,t)}async updateTask(e,t){return await this.requestWithTracking("update_task",e,t)}async updateUser(e,t){return await this.requestWithTracking("update_user",e,t)}async updateWorkblockSchedule(e,t){return await this.requestWithTracking("update_workblock_schedule",e,t)}async upsertSpace(e,t){return await this.requestWithTracking("upsert_space",e,t)}async addLearningData(e,t){return await this.client.sendMessage({type:"add_learning_data",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDiffVersions(e,t){return await this.client.sendMessage({type:"authz_schema_diff_versions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftGetEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_get_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftSubscribeAwarenessEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_subscribe_awareness_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftSubscribeDraftReplacedEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_subscribe_draft_replaced_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftSubscribeEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_subscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftSubscribeValidationEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_subscribe_validation_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftUnsubscribeAwarenessEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_unsubscribe_awareness_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftUnsubscribeDraftReplacedEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_unsubscribe_draft_replaced_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftUnsubscribeEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_unsubscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftUnsubscribeValidationEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_unsubscribe_validation_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGet(e,t){return await this.client.sendMessage({type:"authz_schema_get",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGetAppliedEnvelope(e,t){return await this.client.sendMessage({type:"authz_schema_get_applied_envelope",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGetDraftState(e,t){return await this.client.sendMessage({type:"authz_schema_get_draft_state",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGetForWorkblock(e,t){return await this.client.sendMessage({type:"authz_schema_get_for_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGetVersion(e,t){return await this.client.sendMessage({type:"authz_schema_get_version",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaImpactReport(e,t){return await this.client.sendMessage({type:"authz_schema_impact_report",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaListOrphanedResources(e,t){return await this.client.sendMessage({type:"authz_schema_list_orphaned_resources",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaListRoleMemberships(e,t){return await this.client.sendMessage({type:"authz_schema_list_role_memberships",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaListVersions(e,t){return await this.client.sendMessage({type:"authz_schema_list_versions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaPreviewValidation(e,t){return await this.client.sendMessage({type:"authz_schema_preview_validation",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaQueryAudit(e,t){return await this.client.sendMessage({type:"authz_schema_query_audit",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaValidate(e,t){return await this.client.sendMessage({type:"authz_schema_validate",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async batchCheckWorkblockMergeability(e,t){return await this.client.sendMessage({type:"batch_check_workblock_mergeability",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async batchGetEvents(e,t){return await this.client.sendMessage({type:"batch_get_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async changelogList(e,t){return await this.client.sendMessage({type:"changelog_list",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkChild(e,t){return await this.client.sendMessage({type:"check_child",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkCredential(e,t){return await this.client.sendMessage({type:"check_credential",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkPermission(e,t){return await this.client.sendMessage({type:"check_permission",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkStreamAccess(e,t){return await this.client.sendMessage({type:"check_stream_access",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkWorkblockBranchMergeability(e,t){return await this.client.sendMessage({type:"check_workblock_branch_mergeability",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async closeWorkblockRunDataSession(e,t){return await this.client.sendMessage({type:"close_workblock_run_data_session",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async consoleLog(e,t){return await this.client.sendMessage({type:"console_log",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async countWorkblockRegistrationEvents(e,t){return await this.client.sendMessage({type:"count_workblock_registration_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async createWorkblockTokenUrl(e,t){return await this.client.sendMessage({type:"create_workblock_token_url",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async diffWorkblockReplayTest(e,t){return await this.client.sendMessage({type:"diff_workblock_replay_test",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async discoverCredentialOauth(e,t){return await this.client.sendMessage({type:"discover_credential_oauth",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async evaluateWorkblockRunDataTransformQuery(e,t){return await this.client.sendMessage({type:"evaluate_workblock_run_data_transform_query",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async findLearningDuplicates(e,t){return await this.client.sendMessage({type:"find_learning_duplicates",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async findStudioWorkspaceOnBranch(e,t){return await this.client.sendMessage({type:"find_studio_workspace_on_branch",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAccount(e,t){return await this.client.sendMessage({type:"get_account",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getActiveWorkblockSetting(e,t){return await this.client.sendMessage({type:"get_active_workblock_setting",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAffectedRunsCount(e,t){return await this.client.sendMessage({type:"get_affected_runs_count",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAgentTurn(e,t){return await this.client.sendMessage({type:"get_agent_turn",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAutoApproveConfig(e,t){return await this.client.sendMessage({type:"get_auto_approve_config",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAvailableModels(e,t){return await this.client.sendMessage({type:"get_available_models",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getBaseWorkblockVersion(e,t){return await this.client.sendMessage({type:"get_base_workblock_version",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getConsumptionStatus(e,t){return await this.client.sendMessage({type:"get_consumption_status",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getCredentialForEdit(e,t){return await this.client.sendMessage({type:"get_credential_for_edit",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getDefaultWorkblockRegistration(e,t){return await this.client.sendMessage({type:"get_default_workblock_registration",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getDocsContent(e,t){return await this.client.sendMessage({type:"get_docs_content",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getEditStreamId(e,t){return await this.client.sendMessage({type:"get_edit_stream_id",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getEvents(e,t){return await this.client.sendMessage({type:"get_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getInstalledWorkblock(e,t){return await this.client.sendMessage({type:"get_installed_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getLearningExample(e,t){return await this.client.sendMessage({type:"get_learning_example",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getLearningExamples(e,t){return await this.client.sendMessage({type:"get_learning_examples",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getLlmRawCall(e,t){return await this.client.sendMessage({type:"get_llm_raw_call",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getLoginHistory(e,t){return await this.client.sendMessage({type:"get_login_history",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getPendingLearningData(e,t){return await this.client.sendMessage({type:"get_pending_learning_data",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getRegistryWorkblock(e,t){return await this.client.sendMessage({type:"get_registry_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getRegistryWorkblockInfo(e,t){return await this.client.sendMessage({type:"get_registry_workblock_info",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getReplayTestRunState(e,t){return await this.client.sendMessage({type:"get_replay_test_run_state",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getRetentionPolicy(e,t){return await this.client.sendMessage({type:"get_retention_policy",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getSpace(e,t){return await this.client.sendMessage({type:"get_space",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getStream(e,t){return await this.client.sendMessage({type:"get_stream",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getStudioWorkspace(e,t){return await this.client.sendMessage({type:"get_studio_workspace",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getStudioWorkspacePresence(e,t){return await this.client.sendMessage({type:"get_studio_workspace_presence",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getTaskLogs(e,t){return await this.client.sendMessage({type:"get_task_logs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getTimelineAffectedCount(e,t){return await this.client.sendMessage({type:"get_timeline_affected_count",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getTimelineEventTypes(e,t){return await this.client.sendMessage({type:"get_timeline_event_types",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getTos(e,t){return await this.client.sendMessage({type:"get_tos",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getUserSetting(e,t){return await this.client.sendMessage({type:"get_user_setting",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getUsers(e,t){return await this.client.sendMessage({type:"get_users",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkBlockRuns(e,t){return await this.client.sendMessage({type:"get_work_block_runs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblock(e,t){return await this.client.sendMessage({type:"get_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockBranchInfo(e,t){return await this.client.sendMessage({type:"get_workblock_branch_info",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockCommitLog(e,t){return await this.client.sendMessage({type:"get_workblock_commit_log",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockCommitPatch(e,t){return await this.client.sendMessage({type:"get_workblock_commit_patch",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockDataSchema(e,t){return await this.client.sendMessage({type:"get_workblock_data_schema",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockFileContent(e,t){return await this.client.sendMessage({type:"get_workblock_file_content",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsConsumption(e,t){return await this.client.sendMessage({type:"get_workblock_operations_consumption",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsCurrent(e,t){return await this.client.sendMessage({type:"get_workblock_operations_current",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsFailures(e,t){return await this.client.sendMessage({type:"get_workblock_operations_failures",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsOutcomes(e,t){return await this.client.sendMessage({type:"get_workblock_operations_outcomes",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsRuns(e,t){return await this.client.sendMessage({type:"get_workblock_operations_runs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockRun(e,t){return await this.client.sendMessage({type:"get_workblock_run",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockRunDataSchemaVersionDetails(e,t){return await this.client.sendMessage({type:"get_workblock_run_data_schema_version_details",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockRunInputs(e,t){return await this.client.sendMessage({type:"get_workblock_run_inputs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockRunResult(e,t){return await this.client.sendMessage({type:"get_workblock_run_result",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockSchedule(e,t){return await this.client.sendMessage({type:"get_workblock_schedule",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockTaskErrors(e,t){return await this.client.sendMessage({type:"get_workblock_task_errors",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockUi(e,t){return await this.client.sendMessage({type:"get_workblock_ui",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockUpstream(e,t){return await this.client.sendMessage({type:"get_workblock_upstream",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockV2(e,t){return await this.client.sendMessage({type:"get_workblock_v2",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockVersion(e,t){return await this.client.sendMessage({type:"get_workblock_version",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async inspectFile(e,t){return await this.client.sendMessage({type:"inspect_file",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async invokeTask(e,t){return await this.client.sendMessage({type:"invoke_task",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listAccessTokens(e,t){return await this.client.sendMessage({type:"list_access_tokens",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listApprovedLearningSets(e,t){return await this.client.sendMessage({type:"list_approved_learning_sets",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listCategories(e,t){return await this.client.sendMessage({type:"list_categories",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listCredentialTypes(e,t){return await this.client.sendMessage({type:"list_credential_types",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listCredentials(e,t){return await this.client.sendMessage({type:"list_credentials",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listGroupMembers(e,t){return await this.client.sendMessage({type:"list_group_members",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listGroups(e,t){return await this.client.sendMessage({type:"list_groups",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listInstalledWorkblocks(e,t){return await this.client.sendMessage({type:"list_installed_workblocks",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLearningDataSets(e,t){return await this.client.sendMessage({type:"list_learning_data_sets",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLearningExamples(e,t){return await this.client.sendMessage({type:"list_learning_examples",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLearningExamplesByScore(e,t){return await this.client.sendMessage({type:"list_learning_examples_by_score",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLearningSetsForWorkblock(e,t){return await this.client.sendMessage({type:"list_learning_sets_for_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLlmRawCalls(e,t){return await this.client.sendMessage({type:"list_llm_raw_calls",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listMyOauthConsents(e,t){return await this.client.sendMessage({type:"list_my_oauth_consents",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listMyPermissionRequests(e,t){return await this.client.sendMessage({type:"list_my_permission_requests",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listNotifications(e,t){return await this.client.sendMessage({type:"list_notifications",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listOauthClients(e,t){return await this.client.sendMessage({type:"list_oauth_clients",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listOauthRegistrationTokens(e,t){return await this.client.sendMessage({type:"list_oauth_registration_tokens",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listOwnedRegistryWorkblocks(e,t){return await this.client.sendMessage({type:"list_owned_registry_workblocks",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listPendingLearningData(e,t){return await this.client.sendMessage({type:"list_pending_learning_data",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listQdrantCollections(e,t){return await this.client.sendMessage({type:"list_qdrant_collections",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listRegistryWorkblocks(e,t){return await this.client.sendMessage({type:"list_registry_workblocks",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listRowstoreCollections(e,t){return await this.client.sendMessage({type:"list_rowstore_collections",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listSpaces(e,t){return await this.client.sendMessage({type:"list_spaces",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listStudioWorkspaces(e,t){return await this.client.sendMessage({type:"list_studio_workspaces",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockBranches(e,t){return await this.client.sendMessage({type:"list_workblock_branches",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockDefinitions(e,t){return await this.client.sendMessage({type:"list_workblock_definitions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockRegistrations(e,t){return await this.client.sendMessage({type:"list_workblock_registrations",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockRunDataSchemaVersions(e,t){return await this.client.sendMessage({type:"list_workblock_run_data_schema_versions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockRunDataTruncations(e,t){return await this.client.sendMessage({type:"list_workblock_run_data_truncations",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockSchedules(e,t){return await this.client.sendMessage({type:"list_workblock_schedules",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockVersions(e,t){return await this.client.sendMessage({type:"list_workblock_versions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async permissionsCheck(e,t){return await this.client.sendMessage({type:"permissions_check",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async permissionsDefinitions(e,t){return await this.client.sendMessage({type:"permissions_definitions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async permissionsListSubjects(e,t){return await this.client.sendMessage({type:"permissions_list_subjects",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async permissionsLookupResources(e,t){return await this.client.sendMessage({type:"permissions_lookup_resources",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async previewContinueFromMessage(e,t){return await this.client.sendMessage({type:"preview_continue_from_message",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async queryAuditLog(e,t){return await this.client.sendMessage({type:"query_audit_log",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async queryWorkblockRunData(e,t){return await this.client.sendMessage({type:"query_workblock_run_data",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async repeatDone(e,t){return await this.client.sendMessage({type:"repeat_done",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async resolveWorkblockByTask(e,t){return await this.client.sendMessage({type:"resolve_workblock_by_task",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async resolveWorkblockContent(e,t){return await this.client.sendMessage({type:"resolve_workblock_content",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async runtimeAuthzCheck(e,t){return await this.client.sendMessage({type:"runtime_authz_check",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async runtimeAuthzLookupResources(e,t){return await this.client.sendMessage({type:"runtime_authz_lookup_resources",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async runtimeAuthzLookupSubjects(e,t){return await this.client.sendMessage({type:"runtime_authz_lookup_subjects",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async sandboxTest(e,t){return await this.client.sendMessage({type:"sandbox_test",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async sandboxTestResponse(e,t){return await this.client.sendMessage({type:"sandbox_test_response",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async searchLearningExamples(e,t){return await this.client.sendMessage({type:"search_learning_examples",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async sendTaskProgress(e,t){return await this.client.sendMessage({type:"send_task_progress",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async sendTaskRunEvent(e,t){return await this.client.sendMessage({type:"send_task_run_event",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async setAgentComplete(e,t){return await this.client.sendMessage({type:"set_agent_complete",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async setWorkblockRunDataTransformQuery(e,t){return await this.client.sendMessage({type:"set_workblock_run_data_transform_query",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async startChild(e,t){return await this.client.sendMessage({type:"start_child",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalExportHistory(e,t){return await this.client.sendMessage({type:"temporal_export_history",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalGetStack(e,t){return await this.client.sendMessage({type:"temporal_get_stack",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalGetWorkflow(e,t){return await this.client.sendMessage({type:"temporal_get_workflow",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalListWorkflowTypes(e,t){return await this.client.sendMessage({type:"temporal_list_workflow_types",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalQueryWorkflow(e,t){return await this.client.sendMessage({type:"temporal_query_workflow",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalSearchWorkflows(e,t){return await this.client.sendMessage({type:"temporal_search_workflows",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalStreamHistory(e,t){return await this.client.sendMessage({type:"temporal_stream_history",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async upsertMemo(e,t){return await this.client.sendMessage({type:"upsert_memo",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async validateTask(e,t){return await this.client.sendMessage({type:"validate_task",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async validateWorkblock(e,t){return await this.client.sendMessage({type:"validate_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async wbRunTest(e,t){return await this.client.sendMessage({type:"wb_run_test",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsEmitEvent(e,t){return await this.client.sendMessage({type:"yjs_emit_event",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsGetEvents(e,t){return await this.client.sendMessage({type:"yjs_get_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsResetEvents(e,t){return await this.client.sendMessage({type:"yjs_reset_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsStreamEmitEvent(e,t){return await this.client.sendMessage({type:"yjs_stream_emit_event",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsStreamSubscribeEvents(e,t){return await this.client.sendMessage({type:"yjs_stream_subscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsStreamUnsubscribeEvents(e,t){return await this.client.sendMessage({type:"yjs_stream_unsubscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsSubscribeEvents(e,t){return await this.client.sendMessage({type:"yjs_subscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsUnsubscribeEvents(e,t){return await this.client.sendMessage({type:"yjs_unsubscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async requestWithTracking(e,t,r){let i=Date.now(),o={options_streamId:r?.streamId,options_threadId:r?.threadId,...this.sanitizeForAnalytics(t)};try{let n=await this.client.sendMessage({type:e,stream_id:r?.streamId,thread_id:r?.threadId,timeout:r?.timeoutSeconds,task_id:r?.taskId,model:r?.model,reasoning_effort:r?.reasoningEffort,request:t});return this.trackEventSafely(`user-action/${e}`,{...o,success:!0,duration:Date.now()-i}),n}catch(n){throw this.trackEventSafely(`user-action/${e}`,{...o,success:!1,duration:Date.now()-i,errorType:n instanceof Error?n.name:"Unknown"}),n}}trackEventSafely(e,t){try{this.analyticsClient?.track?.(e,t)}catch(r){console.error("Analytics tracking failed:",r)}}sanitizeForAnalytics(e){if(!e||typeof e!="object")return{hasContent:!!e};let t={};for(let[r,i]of Object.entries(e))(r.endsWith("_id")||r.endsWith("_ids")||r==="id")&&(t[r]=i);return t}};var dr=class extends Error{code;constructor(e,t){super(e),this.name="BwWebsocketError",this.code=t}},Os=180,ur=class{streamHandlers=[];eventHandlers=[];currentUserHandlers=[];onDisconnect=[];errorHandlers=[];connectionErrorHandlers=[];ws=null;store={};SequenceID=0;connected;blobURL;token;tokenSource;lastCleanup=0;requestTimeoutMs=3e4;connectionHost;connectionUrl;lastConnectionError;closing=!1;debug;currentUser;requests=new Ec({sendMessage:e=>this.send(e)});constructor(e=!1){this.debug=e}addStreamHandler(e){this.streamHandlers.push(e)}addEventHandler(e){this.eventHandlers.push(e)}addCurrentUserHandler(e){this.currentUserHandlers.push(e)}addErrorHandler(e){this.errorHandlers.push(e)}addConnectionErrorHandler(e){this.connectionErrorHandlers.push(e)}addOnDisconnect(e){this.onDisconnect.push(e)}useTokenSource(e){this.tokenSource=e}close(){this.closing=!0,this.ws?.close()}connect(e,t){this.connectionHost=e,this.lastConnectionError=void 0,this.connected=!1,this.closing=!1,e.indexOf("://")===-1&&(e=`https://${e}`),this.token=t;let r=new URL(e);r.protocol==="ws:"?r.protocol="http:":r.protocol==="wss:"&&(r.protocol="https:"),!r.hostname.startsWith("api.")&&!r.hostname.startsWith("localhost")&&(r.hostname=`api.${r.hostname}`),r.pathname=r.pathname.replace("/workblocks/streams",""),r.pathname.endsWith("/")&&(r.pathname=r.pathname.slice(0,-1)),r.pathname=r.pathname+"/blobs",this.blobURL=r.toString();let i=new URL(e);switch(i.protocol){case"https:":i.protocol="wss:";break;case"http:":i.protocol="ws:";break}!i.hostname.startsWith("api.")&&!i.hostname.startsWith("localhost")&&(i.hostname=`api.${i.hostname}`),i.pathname.endsWith("/streams")||(i.pathname="/workblocks/streams"),this.connectionUrl=i.toString();let o=new Sc(i.toString(),{headers:{Authorization:`Bearer ${t}`}});this.ws=o,o.on("open",()=>{this.ws===o&&(this.connected=!0,this.lastConnectionError=void 0)}),o.on("unexpected-response",(n,a)=>{this.ws===o&&this.reportConnectionError(`Unexpected server response: ${a.statusCode}`,a.statusCode),o.terminate()}),o.on("message",n=>{if(this.ws!==o)return;let a=JSON.parse(n.toString());if(this.debug&&console.error("Received message","type"in a?a.type:"error","reply_to"in a?a.reply_to:void 0),"reply_to"in a){if(a.reply_to===void 0)return;let c=this.store[a.reply_to];c&&(delete this.store[a.reply_to],clearTimeout(c.timeoutHandle),"error"in a?c.reject(new dr(a.error,a.error_type??"")):c.resolve(a.response));return}if("error"in a){this.errorHandlers.forEach(c=>c(a.error));return}a.type==="streams"?this.handleListStreams(a.response):a.type==="events"?this.handleEvents(a.response).catch(c=>{console.error(c)}):a.type==="whoami"&&this.handleCurrentUser(a.response)}),o.on("close",(n,a)=>{this.ws===o&&(this.connected||this.closing||this.lastConnectionError||this.reportConnectionError(`Connection closed before it was established. Code: ${n}, Reason: ${a||"none"}`),this.rejectAllPending(new Error(`WebSocket disconnected. Code: ${n}, Reason: ${a}`)),this.onDisconnect.forEach(c=>c()))}),o.on("error",async n=>{this.ws===o&&(this.connected||this.closing||this.lastConnectionError||this.reportConnectionError(n.message),this.rejectAllPending(new Error(`WebSocket error: ${n.message}`)))})}waitForOpen(){if(this.connected)return Promise.resolve();let e=this.ws;return e?e.readyState===Sc.OPEN?(this.connected=!0,Promise.resolve()):new Promise((t,r)=>{let i=()=>{c(),t()},o=l=>{c(),r(new Error(`WebSocket error: ${l.message}`))},n=(l,d)=>{c(),r(new Error(`WebSocket error: Unexpected server response: ${d.statusCode}`))},a=(l,d)=>{c(),r(new Error(`WebSocket disconnected. Code: ${l}, Reason: ${d}`))},c=()=>{e.removeListener("open",i),e.removeListener("error",o),e.removeListener("unexpected-response",n),e.removeListener("close",a)};e.on("open",i),e.on("error",o),e.on("unexpected-response",n),e.on("close",a)}):Promise.reject(new Error("WebSocket not connected"))}fetchWithCache(e,t){return fetch(e,t)}async _send(e,t){return this.ws&&this.ws.readyState===Sc.OPEN?(this.SequenceID++,new Promise((r,i)=>{let o=this.SequenceID,n=t??this.requestTimeoutMs,a=setTimeout(()=>{let c=this.store[o];c&&(delete this.store[o],c.reject(new Error(`Request timed out after ${n}ms${c.type?` (type=${c.type})`:""}`)))},n);this.store[o]={resolve:r,reject:i,timeoutHandle:a,type:e.type},this.ws?.send(JSON.stringify({...e,seq:o}))})):Promise.reject("WebSocket not connected")}async requestRaw(e,t,r={}){let i=r.timeoutSeconds;return await this._send({type:e,stream_id:r.streamId,timeout:i,request:t},i===void 0?void 0:(i+5)*1e3)}async send(e){let t=e.timeout===void 0?void 0:(e.timeout+5)*1e3;return await this._send(e,t)}async setWorkblock(e,t){let r=await this.requests.setWorkBlockV2({workblock:t},{streamId:e,timeoutSeconds:Os});return{errors:r.errors??[],warnings:r.warnings??[]}}async getWorkblock(e){return await this.requests.getWorkblock({},{streamId:e})??void 0}async getWorkblockById(e){return await this.requests.getWorkblock({id:e})??void 0}async storeWorkblock(e){let t;try{if(t=await this.getWorkblockById(e.id),!t)throw new Error(`Workblock lookup for ${e.id} returned no definition`)}catch(o){if(!(o instanceof dr&&o.code==="NotFound"))throw o;t=void 0}if(!t)return await this.createWorkblock(e);let r=await this.requests.getEditStream({workblock_id:e.id}),i=await this.setWorkblock(r.id,e);if(i.errors.length>0)throw new Error(`Validation errors: ${JSON.stringify(i.errors)}`);return{stream:r,warnings:i.warnings}}async initializeWorkblock(e,t){return await this.requests.createWorkblock({workblock:e,feature_branch:t},{timeoutSeconds:Os})}async createWorkblock(e,t){let r=await this.requests.createWorkblock(t?{workblock:e,feature_branch:t}:{workblock:e},{timeoutSeconds:Os});if(r.errors?.length)throw new Error(`Validation errors: ${JSON.stringify(r.errors)}`);return{stream:r.stream,warnings:r.warnings??[]}}async listWorkblockDefinitions(){return await this.requests.listWorkblockDefinitions({})}async listWorkblockBranches(e){return(await this.requests.listWorkblockBranches({workblock_id:e})).branches}async getActiveWorkblockSetting(e){return(await this.requests.getActiveWorkblockSetting({workblock_id:e})).branch}async setActiveWorkblockSetting(e,t){await this.requests.setActiveWorkblockSetting({workblock_id:e,branch:t})}async createStudioWorkspace(e,t,r,i=!1){return(await this.requests.createStudioWorkspace({workblock_id:e,branch:t,title:r,create_user_branch:i})).stream}async findStudioWorkspaceOnBranch(e,t){return(await this.requests.findStudioWorkspaceOnBranch({workblock_id:e,target_branch:t})).stream_id}async getStudioWorkspace(e){return(await this.requests.getStudioWorkspace({stream_id:e})).workspace??void 0}async listStudioWorkspaces(e,t){if(!e&&!t)throw new Error("listStudioWorkspaces requires a user id or a workblock id");return(await this.requests.listStudioWorkspaces({user_id:e,workblock_id:t})).workspaces??[]}async getBlob(e){return this.debug&&console.error(`Getting blob ${e}`),e.startsWith("::bw:data:")?(await this.getBlobContent(e)).text:e}async getBlobContent(e){let t=this.tokenSource?await this.tokenSource():this.token,r=await this.fetchWithCache(`${this.blobURL}?key=${encodeURIComponent(e)}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});if(!r.ok)throw new Error(`Failed to fetch blob ${e}: ${r.status} ${r.statusText}`);return{contentType:r.headers.get("content-type")??"",text:await r.text()}}waitForCurrentUser(e=1e4){return this.currentUser?Promise.resolve(this.currentUser):new Promise((t,r)=>{let i=setTimeout(()=>r(new Error("The server did not announce the current user")),e);this.currentUserHandlers.push(o=>{clearTimeout(i),t(o)})})}async getWorkblockV2ById(e){return await this.requests.getWorkblockV2({id:e,resolve_blobs:!0})??void 0}async resolveWorkblockContent(e,t){return await this.requests.resolveWorkblockContent({workblock_id:e,commit_ref:t})}async createWorkblockVersion(e,t,r){return await this.requests.createWorkblockVersion({workblock_id:e,feature_branch:t,workspace_name:r},{timeoutSeconds:Os})}async setWorkblockV2(e,t,r){return await this.requests.setWorkBlockV2({workblock:t,branch:r.branch,expected_commit_ref:r.expectedCommitRef,advance_version:r.advanceVersion||void 0},{streamId:e,timeoutSeconds:Os})}async validateWorkblock(e){return await this.requests.validateWorkblock(e,{timeoutSeconds:Os})}async syncWorkblockVersion(e){return await this.requests.syncWorkblockVersion({},{streamId:e,timeoutSeconds:Os})}async getWorkspaceWorkblock(e){return await this.requests.getWorkblockV2({},{streamId:e})??void 0}async getDocsContent(){return(await this.requests.getDocsContent({})).content}async runModule(e,t,r){return(await this.requests.runModule({module_id:t,inputs:r},{streamId:e})).run_id}async runSingleTask(e,t,r,i){return await this.requests.runSingleTask({module_id:t,task_id:r,inputs:i},{streamId:e})}async invokeWorkblockTask(e){return(await this.requests.invokeWorkblockTask({workblock_id:e.workblockId,module_id:e.moduleId,task_id:e.taskId,commit_ref:e.commitRef,inputs:e.inputs},{streamId:e.streamId,timeoutSeconds:e.timeoutSeconds})).outputs??{}}async runModuleTests(e,t,r){return(await this.requests.wbRunTest({module_id:r,workblock_id:t},{streamId:e,timeoutSeconds:Os})).result??[]}async getWorkblockRun(e){return await this.requests.getWorkblockRun({id:e.runId,stream_id:e.runId?void 0:e.streamId,include_ephemeral:!0,nil_on_no_run:!0})??void 0}async getTaskLogs(e,t){return await this.requests.getTaskLogs({run_id:e,task_id:t})??[]}async cancelWorkblockRun(e,t){await this.requests.cancelWb({workblock_run_id:t},{streamId:e})}disconnect(){this.connected=!1,this.closing=!0,this.rejectAllPending(new Error("WebSocket disconnected")),this.ws?.close(),this.streamHandlers=[],this.eventHandlers=[],this.currentUserHandlers=[],this.store={},this.SequenceID=0}handleListStreams(e){let t=[];(e??[]).forEach(r=>{r.editing&&t.push(r)}),this.streamHandlers.forEach(r=>r(t))}async handleEvents(e){for(let t of this.eventHandlers)await t(e)}handleCurrentUser(e){this.currentUser=e,this.currentUserHandlers.forEach(t=>t(e))}rejectAllPending(e){for(let[t,r]of Object.entries(this.store))r&&(clearTimeout(r.timeoutHandle),r.reject(e),delete this.store[Number(t)])}reportConnectionError(e,t){this.lastConnectionError=e,this.connectionErrorHandlers.forEach(r=>r({host:this.connectionHost,url:this.connectionUrl,reason:e,statusCode:t}))}};var fi=O(require("path"));function yk(s){return s.task?.error??s.test?.error??s.module?.error??s.business_event?.error??s.library?.error??s.workblock?.error??JSON.stringify(s)}function xk(s,e){return fi.relative(s,e).split(fi.sep).join("/")}function Zq(s,e){let t=[];for(let[r,i]of[["react_components",e.react_components],["python",e.python]])for(let o of Object.keys(i??{}))s.includes(o)&&t.push(`${r}/${o}`);return t}function eN(s,e,t){let r=e.modules??[],i=[],o,n=s.workblock?.error??"";if(s.task){n=s.task.error;let a=r[s.task.module_index],c=a?.tasks?.[s.task.index];if(a&&c){o=`task ${JSON.stringify(`${a.name}/${c.name}`)}`;let l=fi.join(t,re(a.name),re(c.name)),d=lc(l,re(c.name));i.push(d?xk(t,d):`${xk(t,l)}/`)}else o=`task[${s.task.module_index}/${s.task.index}]`}else if(s.test){n=s.test.error;let a=r[s.test.module_index],c=a?.tests?.[s.test.index];a&&c?(o=`test ${JSON.stringify(`${a.name}/${c.name}`)}`,i.push(`${re(a.name)}/tests/${re(c.name)}.py`)):o=`test[${s.test.module_index}/${s.test.index}]`}else if(s.module||s.business_event){let a=s.module??s.business_event;n=a.error;let c=r[a.module_index];o=c?`module ${JSON.stringify(c.name)}`:`module[${a.module_index}]`}else s.library&&(n=s.library.error,i.push("library.py"));return i.push(...Zq(n,e).filter(a=>!i.includes(a))),i.length===0&&i.push("manifest.yaml"),{...s,paths:i,...o?{label:o}:{}}}function Uo(s,e,t){return s.map(r=>eN(r,e,t))}var tN=/\.(?:tsx?|jsx?|mjs)$/,sN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,rN=/invokeTask\s*(?:<[^>()]*>)?\s*\(\s*(['"`])([^'"`$\n]+)\1/g;function _k(s){let e=s.modules??[],t=(a,c)=>a.has(c)||c.startsWith("bworker.ai:"),r=a=>new Set(a.flatMap(c=>c.id?[c.name,c.id]:[c.name])),i=r(e.flatMap(a=>a.tasks??[])),o=[],n=(a,c,l,d)=>{let p=c?.text;if(!(!p||!tN.test(a)))for(let u of p.matchAll(rN)){let m=u[2];if(t(l,m))continue;let h=p.slice(0,u.index).split(`
219
+ `)}async function p_(s){return await gC(s,"manifest.yaml","manifest.yaml")}async function gC(s,e,t){if(!I.existsSync(s))return C.join(s,t);let i=(await I.promises.readdir(s)).find(o=>o.endsWith(e));return i?C.join(s,i):C.join(s,t)}function re(s){let e=C.basename(s).toLowerCase(),t="",r=!1;for(let i of e)i>="a"&&i<="z"||i>="0"&&i<="9"||i==="."||i==="-"?(t+=i,r=!1):r||(t+="_",r=!0);return t=t.replace(/^_+|_+$/g,"").replace(/^\.+/,""),t===""&&(t="file"),t}function bC(s,e){let t=C.posix.normalize(e.replaceAll("\\","/"));if(C.posix.isAbsolute(t)||t===".."||t.startsWith("../"))throw new Error(`invalid asset path: ${e}`);return C.posix.join(s.replaceAll("\\","/"),t)}function lc(s,e){let t=C.join(s,e+".py");if(I.existsSync(t))return t;if(!I.existsSync(s))return null;let i=I.readdirSync(s).find(o=>o.endsWith(".py"));return i?C.join(s,i):null}var xC=/\.[cm]?ts$/;async function yC(s,e="text/plain"){let{fileTypeFromFile:t}=await Promise.resolve().then(()=>(o_(),i_)),r=C.basename(s),i=(await t(s))?.mime;i||(i=xC.test(r)?"text/plain":n_.lookup(r)||e);let o=I.readFileSync(s);return kC(o)?{content_type:i,text:o.toString("utf8")}:{content_type:i,data:o.toString("base64")}}function _C(s){return s.text!==void 0?s.text.trim()==="":!s.data}function d_(s){try{let e=I.statSync(s);return e.size===0||e.size<4096&&I.readFileSync(s,"utf8").trim()===""}catch{return!1}}function kC(s){try{return new TextDecoder("utf-8",{fatal:!0}).decode(s),!0}catch{return!1}}var u_=new Set(["node_modules",".git","bun.lock","pnpm-lock.yaml","__pycache__"]),wC=new Set([Eo,To,Ba,So,Ma,".gitignore"]);async function ri(s,e,t){let r=d=>t?.add(C.resolve(d)),i=d=>(r(d),I.readFileSync(d,"utf8")),o=await p_(s);if(!I.existsSync(o)){e.error(`Manifest file ${o} not found`);return}let n=i(o),a=(0,a_.parse)(n);a.state="modified",a.updated_at=new Date().toISOString();let c=async(d,p,u,m)=>{let h=C.join(d,u);if(!I.existsSync(h))return;let f=p,g=f[u]=f[u]??{};await l(h,"",g,m),Object.keys(g).length===0&&delete f[u]};for(let d of a.modules??[]){let p=C.join(s,re(d.name));if(!I.existsSync(p)){e.error(`Module directory ${p} not found`);return}for(let u of d.tasks??[]){let m=re(u.name),h=C.join(p,m);if(!I.existsSync(h)){e.error(`Task directory ${h} not found`);continue}if(u.action.type==="code"||u.action.type==="python"){let f=lc(h,m);if(!f){e.error(`Task file for ${u.name} not found under ${h}`);return}u.action.value=i(f)}await c(h,u,"assets","text/plain"),await c(h,u,"design_docs","text/markdown")}if(d.tests&&d.tests.length>0){let u=new Map;for(let m of d.tests){let h=re(m.name),f=u.get(h);if(f!==void 0)throw new Error(`duplicate normalized test filename "${h}.py" in module "${d.name}": "${m.name}" conflicts with "${f}"`);u.set(h,m.name)}for(let m of d.tests){let h=re(m.name),f=C.join(p,"tests",h+".py");I.existsSync(f)&&(m.value=i(f))}}await c(p,d,"design_docs","text/markdown")}for(let[d,p]of[["library.py","library"],["schema.yaml","schema"],["logo.svg","logo"]]){let u=C.join(s,d);I.existsSync(u)&&!d_(u)&&(a[p]=i(u))}async function l(d,p,u,m="text/plain"){let h=I.readdirSync(d);for(let f of h){if(u_.has(f))continue;let g=C.join(d,f);if(await SC(g,e))continue;let b=I.lstatSync(g);if(b.isSymbolicLink()){e.log(`Skipping symbolic link in workblock assets: ${g}`);continue}let x=C.posix.join(p.replaceAll("\\","/"),f);if(b.isDirectory()){await l(g,x,u,m);continue}let y=await yC(g,m);if(_C(y)){e.log(`Empty file not stored by the platform, left out: ${g}`);continue}u[x]=y,r(g)}}for(let d of["react_components","python"]){if(!I.existsSync(C.join(s,d)))continue;let p=a[d]=a[d]??{};await l(C.join(s,d),"",p),Object.keys(p).length===0&&delete a[d]}return await c(s,a,"design_docs","text/markdown"),a}function Io(s){let e=s.split("/");return wC.has(e[0])||e.some(t=>u_.has(t))}function f_(s,e,t,r){let i=new Map;for(let c of e.modules??[])i.set(re(c.name),{name:c.name,tasks:new Map((c.tasks??[]).map(l=>[re(l.name),l.name]))});let o="not part of the workblock",n=c=>{let[l,d,p,...u]=c.split("/"),m=i.get(l);if(d===void 0||l==="react_components"||l==="python"||l==="design_docs")return o;if(!m)return`no module in manifest.yaml maps to the directory ${l}/`;if(d==="design_docs")return o;let h=p!==void 0&&u.length===0&&p.endsWith(".py");if(d==="tests")return h?`add a test named ${JSON.stringify(p.slice(0,-3))} under tests: of module ${JSON.stringify(m.name)} in manifest.yaml`:o;let f=m.tasks.get(d);return f?h?`only the task file of ${JSON.stringify(f)} is read; shared code goes in python/<name>.py or library.py`:o:`no task in module ${JSON.stringify(m.name)} maps to the directory ${l}/${d}/; add a task entry to manifest.yaml or delete it`},a=[];for(let c of r){let l=C.join(s,c);if(Io(c)||t.has(C.resolve(l)))continue;let d=I.lstatSync(l).isSymbolicLink()?"a symbolic link, which is never pushed":d_(l)?"an empty file; the platform stores none, so it is not pushed":n(c);a.push({path:c,hint:d})}return a}function vC(s){let e=s;for(I.statSync(e).isDirectory()||(e=C.dirname(e));e!==C.parse(e).root;){let t=C.join(e,".gitignore"),r=C.join(e,".git");if(I.existsSync(r))return I.existsSync(t)?e:null;e=C.dirname(e)}return null}async function SC(s,e){try{let t=vC(s);if(!t)return!1;let r=C.join(t,".gitignore"),i=I.readFileSync(r,"utf8"),o=C.relative(t,s),n=(0,c_.default)();return n.add(i),n.ignores(o)}catch(t){return e.log(`Error checking gitignore status: ${t}`),!1}}function cc(s,e){return C.relative(s,e).split(C.sep).join("/")}function EC(s,e,t,r){let i=C.resolve(s),o=[];for(let n of e??[]){if(t.has(n))continue;let a=C.relative(i,n);if(!a||a.startsWith("..")||C.isAbsolute(a))continue;I.rmSync(n,{force:!0}),o.push(a.split(C.sep).join("/"));let c=C.dirname(n);for(;c!==i&&c.startsWith(i+C.sep)&&!r.has(c)&&!(!I.existsSync(c)||I.readdirSync(c).length>0);)I.rmdirSync(c),c=C.dirname(c)}return o.sort()}async function ii(s,e,t,r={}){let i=await p_(s),o=C.resolve(s),n=[],a=(y,_,k=!1)=>{n.push({file:y,key:_,binary:k})},c=(y,_)=>{if(_)for(let[k,S]of Object.entries(_)){let T=bC(y.replaceAll("\\","/"),k),E=C.normalize(T);S.data&&(a(E,S.data,!0),delete S.data),S.text&&(a(E,S.text),delete S.text)}},l=(y,_)=>{_&&c(C.join(y,"design_docs"),_)},d=JSON.parse(JSON.stringify(e)),p=[];delete d.updated_at,delete d.state,delete d.actor,delete d.branch_user,delete d.storing;for(let y of d.modules??[]){let _=C.join(s,re(y.name));p.push(_);for(let k of y.tasks??[]){let S=k.action.type==="typescript";if(k.action.type!=="code"&&k.action.type!=="python"&&!S)continue;let T=re(k.name),E=C.join(_,T);if(!S){let P=lc(E,T)??C.join(E,`${T}.py`);a(P,k.action.value??"")}k.assets&&c(C.join(_,T,"assets"),k.assets),delete k.created_at,delete k.updated_at,S||delete k.action.value,delete k.assets,l(E,k.design_docs),delete k.design_docs}if(y.tests&&y.tests.length>0){let k=new Map;for(let S of y.tests){let T=re(S.name),E=k.get(T);if(E!==void 0)throw new Error(`duplicate normalized test filename "${T}.py" in module "${y.name}": "${S.name}" conflicts with "${E}"`);if(k.set(T,S.name),S.value&&S.value.trim()!==""){let v=C.join(_,"tests",T+".py");a(v,S.value),delete S.value}}}l(_,y.design_docs),delete y.design_docs}d.library&&a(C.join(s,"library.py"),d.library),d.schema&&a(C.join(s,"schema.yaml"),d.schema),d.logo&&a(C.join(s,"logo.svg"),d.logo),d.react_components&&c(C.join(s,"react_components"),d.react_components),d.python&&c(C.join(s,"python"),d.python),l(s,d.design_docs);let u=new Set([i,...n.map(y=>y.file)].map(y=>C.resolve(y)));for(let y of p)if(u.has(C.resolve(y)))throw new Error(`module directory "${cc(o,C.resolve(y))}" collides with a workblock file`);let m=await Promise.all(n.map(async({file:y,key:_,binary:k})=>{let S=await t.getBlob(_);return{file:y,bytes:k?Buffer.from(S,"base64"):Buffer.from(S,"utf8")}}));for(let y of p)I.mkdirSync(y,{recursive:!0});let h=EC(s,r.previouslyRead,u,new Set(p.map(y=>C.resolve(y)))),f=new Map;for(let{file:y,bytes:_}of m)f.set(cc(o,C.resolve(y)),_),!(r.sent?.get(C.resolve(y))?.equals(_)||I.existsSync(y)&&I.readFileSync(y).equals(_))&&(I.mkdirSync(C.dirname(y),{recursive:!0}),I.writeFileSync(y,_));let g=JSON.parse(JSON.stringify(d));delete g.updated_at,delete g.state,delete g.branch_user,delete g.storing,delete g.actor,delete g.library,delete g.logo,delete g.react_components,delete g.python,delete g.schema,delete g.design_docs;let b=Buffer.from((0,l_.stringify)(g),"utf8");return f.set(cc(o,C.resolve(i)),b),r.sent?.get(C.resolve(i))?.equals(b)||I.existsSync(i)&&I.readFileSync(i).equals(b)||I.writeFileSync(i,b),{written:[...u].map(y=>cc(o,y)).sort(),contents:f,removed:h}}var Ku=require("crypto"),Ye=O(require("fs")),$t=O(require("path"));var Vq=O(ck(),1),Hq=O(xc(),1),Kq=O(ai(),1),Jq=O(ju(),1),Yq=O(Fu(),1),Qq=O(zu(),1),bk=O(wc(),1),Xq=O(gk(),1);var Sc=bk.default;var Ec=class{constructor(e,t){this.client=e,this.analyticsClient=t??null}async acceptThreadWorkblock(e,t){return await this.requestWithTracking("accept_thread_workblock",e,t)}async acceptTos(e,t){return await this.requestWithTracking("accept_tos",e,t)}async addGroupMember(e,t){return await this.requestWithTracking("add_group_member",e,t)}async applyWorkblockDeployedUpdates(e,t){return await this.requestWithTracking("apply_workblock_deployed_updates",e,t)}async applyWorkblockVersionUpdates(e,t){return await this.requestWithTracking("apply_workblock_version_updates",e,t)}async approveLearningData(e,t){return await this.requestWithTracking("approve_learning_data",e,t)}async askAgent(e,t){return await this.requestWithTracking("ask_agent",e,t)}async assign(e,t){return await this.requestWithTracking("assign",e,t)}async assignEditStream(e,t){return await this.requestWithTracking("assign_edit_stream",e,t)}async assignWorkBlockRuns(e,t){return await this.requestWithTracking("assign_work_block_runs",e,t)}async authzSchemaApply(e,t){return await this.requestWithTracking("authz_schema_apply",e,t)}async authzSchemaDraftEmitAwarenessEvent(e,t){return await this.requestWithTracking("authz_schema_draft_emit_awareness_event",e,t)}async authzSchemaDraftEmitEvent(e,t){return await this.requestWithTracking("authz_schema_draft_emit_event",e,t)}async authzSchemaForceApply(e,t){return await this.requestWithTracking("authz_schema_force_apply",e,t)}async authzSchemaGrantRoleMembership(e,t){return await this.requestWithTracking("authz_schema_grant_role_membership",e,t)}async authzSchemaInitializeForWorkblock(e,t){return await this.requestWithTracking("authz_schema_initialize_for_workblock",e,t)}async authzSchemaPropose(e,t){return await this.requestWithTracking("authz_schema_propose",e,t)}async authzSchemaRevokeRoleMembership(e,t){return await this.requestWithTracking("authz_schema_revoke_role_membership",e,t)}async bulkTagLearningExamples(e,t){return await this.requestWithTracking("bulk_tag_learning_examples",e,t)}async cancelAgent(e,t){return await this.requestWithTracking("cancel_agent",e,t)}async cancelChild(e,t){return await this.requestWithTracking("cancel_child",e,t)}async cancelWb(e,t){return await this.requestWithTracking("cancel_wb",e,t)}async changelogMarkSeen(e,t){return await this.requestWithTracking("changelog_mark_seen",e,t)}async chatQueue(e,t){return await this.requestWithTracking("chat_queue",e,t)}async closeStream(e,t){return await this.requestWithTracking("close_stream",e,t)}async completeChild(e,t){return await this.requestWithTracking("complete_child",e,t)}async completeCredentialOauth(e,t){return await this.requestWithTracking("complete_credential_oauth",e,t)}async completeRunCredentialOauth(e,t){return await this.requestWithTracking("complete_run_credential_oauth",e,t)}async continueFromMessage(e,t){return await this.requestWithTracking("continue_from_message",e,t)}async continueUi(e,t){return await this.requestWithTracking("continue_ui",e,t)}async convertLegacyStream(e,t){return await this.requestWithTracking("convert_legacy_stream",e,t)}async createAccessToken(e,t){return await this.requestWithTracking("create_access_token",e,t)}async createCredential(e,t){return await this.requestWithTracking("create_credential",e,t)}async createGroup(e,t){return await this.requestWithTracking("create_group",e,t)}async createOauthClient(e,t){return await this.requestWithTracking("create_oauth_client",e,t)}async createOauthRegistrationToken(e,t){return await this.requestWithTracking("create_oauth_registration_token",e,t)}async createStream(e,t){return await this.requestWithTracking("create_stream",e,t)}async createStudioWorkspace(e,t){return await this.requestWithTracking("create_studio_workspace",e,t)}async createUser(e,t){return await this.requestWithTracking("create_user",e,t)}async createWorkblock(e,t){return await this.requestWithTracking("create_workblock",e,t)}async createWorkblockSchedule(e,t){return await this.requestWithTracking("create_workblock_schedule",e,t)}async createWorkblockVersion(e,t){return await this.requestWithTracking("create_workblock_version",e,t)}async createWorkblockVersionUpdate(e,t){return await this.requestWithTracking("create_workblock_version_update",e,t)}async deleteAccessToken(e,t){return await this.requestWithTracking("delete_access_token",e,t)}async deleteAllWorkblockRegistrationEvents(e,t){return await this.requestWithTracking("delete_all_workblock_registration_events",e,t)}async deleteCredential(e,t){return await this.requestWithTracking("delete_credential",e,t)}async deleteGroup(e,t){return await this.requestWithTracking("delete_group",e,t)}async deleteLearningExample(e,t){return await this.requestWithTracking("delete_learning_example",e,t)}async deleteOauthClient(e,t){return await this.requestWithTracking("delete_oauth_client",e,t)}async deleteSpace(e,t){return await this.requestWithTracking("delete_space",e,t)}async deleteStudioWorkspace(e,t){return await this.requestWithTracking("delete_studio_workspace",e,t)}async deleteWorkblock(e,t){return await this.requestWithTracking("delete_workblock",e,t)}async deleteWorkblockBranch(e,t){return await this.requestWithTracking("delete_workblock_branch",e,t)}async deleteWorkblockRegistration(e,t){return await this.requestWithTracking("delete_workblock_registration",e,t)}async deleteWorkblockRegistrationEvent(e,t){return await this.requestWithTracking("delete_workblock_registration_event",e,t)}async deleteWorkblockRunDataTruncation(e,t){return await this.requestWithTracking("delete_workblock_run_data_truncation",e,t)}async deleteWorkblockSchedule(e,t){return await this.requestWithTracking("delete_workblock_schedule",e,t)}async deployWorkblockVersion(e,t){return await this.requestWithTracking("deploy_workblock_version",e,t)}async disableWorkblockRegistration(e,t){return await this.requestWithTracking("disable_workblock_registration",e,t)}async discardPermissionRequest(e,t){return await this.requestWithTracking("discard_permission_request",e,t)}async dismissNotification(e,t){return await this.requestWithTracking("dismiss_notification",e,t)}async enableWorkblockRegistration(e,t){return await this.requestWithTracking("enable_workblock_registration",e,t)}async ensureStreamBranchHead(e,t){return await this.requestWithTracking("ensure_stream_branch_head",e,t)}async getEditStream(e,t){return await this.requestWithTracking("get_edit_stream",e,t)}async getSpaceStream(e,t){return await this.requestWithTracking("get_space_stream",e,t)}async help(e,t){return await this.requestWithTracking("help",e,t)}async initiateCredentialOauth(e,t){return await this.requestWithTracking("initiate_credential_oauth",e,t)}async initiateTaskCredentialOauth(e,t){return await this.requestWithTracking("initiate_task_credential_oauth",e,t)}async insertTasks(e,t){return await this.requestWithTracking("insert_tasks",e,t)}async installWorkblock(e,t){return await this.requestWithTracking("install_workblock",e,t)}async interruptChild(e,t){return await this.requestWithTracking("interrupt_child",e,t)}async invokeWorkblockTask(e,t){return await this.requestWithTracking("invoke_workblock_task",e,t)}async join(e,t){return await this.requestWithTracking("join",e,t)}async leave(e,t){return await this.requestWithTracking("leave",e,t)}async markAllNotificationsRead(e,t){return await this.requestWithTracking("mark_all_notifications_read",e,t)}async markNotificationRead(e,t){return await this.requestWithTracking("mark_notification_read",e,t)}async mergeWorkblockBranch(e,t){return await this.requestWithTracking("merge_workblock_branch",e,t)}async messageChild(e,t){return await this.requestWithTracking("message_child",e,t)}async peekWorkblockRegistrationEvents(e,t){return await this.requestWithTracking("peek_workblock_registration_events",e,t)}async permissionsGrant(e,t){return await this.requestWithTracking("permissions_grant",e,t)}async permissionsRevoke(e,t){return await this.requestWithTracking("permissions_revoke",e,t)}async publishToRegistry(e,t){return await this.requestWithTracking("publish_to_registry",e,t)}async recreateEditStream(e,t){return await this.requestWithTracking("recreate_edit_stream",e,t)}async reembedValidationSet(e,t){return await this.requestWithTracking("reembed_validation_set",e,t)}async registerWorkblockEvent(e,t){return await this.requestWithTracking("register_workblock_event",e,t)}async registrySearch(e,t){return await this.requestWithTracking("registry_search",e,t)}async registrySetParameters(e,t){return await this.requestWithTracking("registry_set_parameters",e,t)}async registrySetTags(e,t){return await this.requestWithTracking("registry_set_tags",e,t)}async rejectLearningData(e,t){return await this.requestWithTracking("reject_learning_data",e,t)}async rejectThreadWorkblock(e,t){return await this.requestWithTracking("reject_thread_workblock",e,t)}async remixWorkblockV2(e,t){return await this.requestWithTracking("remix_workblock_v2",e,t)}async removeGroupMember(e,t){return await this.requestWithTracking("remove_group_member",e,t)}async removeThread(e,t){return await this.requestWithTracking("remove_thread",e,t)}async requestPermission(e,t){return await this.requestWithTracking("request_permission",e,t)}async resetTask(e,t){return await this.requestWithTracking("reset_task",e,t)}async resetWorkblockBranch(e,t){return await this.requestWithTracking("reset_workblock_branch",e,t)}async resolveWorkblockMergeConflicts(e,t){return await this.requestWithTracking("resolve_workblock_merge_conflicts",e,t)}async restartStudioWorkspaceThread(e,t){return await this.requestWithTracking("restart_studio_workspace_thread",e,t)}async restartWorkblock(e,t){return await this.requestWithTracking("restart_workblock",e,t)}async resumeRetry(e,t){return await this.requestWithTracking("resume_retry",e,t)}async revertWorkblockCommit(e,t){return await this.requestWithTracking("revert_workblock_commit",e,t)}async revokeAllOauthConsents(e,t){return await this.requestWithTracking("revoke_all_oauth_consents",e,t)}async revokeOauthConsent(e,t){return await this.requestWithTracking("revoke_oauth_consent",e,t)}async revokeOauthRegistrationToken(e,t){return await this.requestWithTracking("revoke_oauth_registration_token",e,t)}async rotateOauthClientSecret(e,t){return await this.requestWithTracking("rotate_oauth_client_secret",e,t)}async runModule(e,t){return await this.requestWithTracking("run_module",e,t)}async runSingleTask(e,t){return await this.requestWithTracking("run_single_task",e,t)}async runSubgraph(e,t){return await this.requestWithTracking("run_subgraph",e,t)}async runTask(e,t){return await this.requestWithTracking("run_task",e,t)}async runWorkblockReplayTests(e,t){return await this.requestWithTracking("run_workblock_replay_tests",e,t)}async runtimeAuthzAttachRole(e,t){return await this.requestWithTracking("runtime_authz_attach_role",e,t)}async runtimeAuthzDeleteRelation(e,t){return await this.requestWithTracking("runtime_authz_delete_relation",e,t)}async runtimeAuthzDetachRole(e,t){return await this.requestWithTracking("runtime_authz_detach_role",e,t)}async runtimeAuthzStoreRelation(e,t){return await this.requestWithTracking("runtime_authz_store_relation",e,t)}async sendMessage(e,t){return await this.requestWithTracking("send_message",e,t)}async setActiveWorkblockSetting(e,t){return await this.requestWithTracking("set_active_workblock_setting",e,t)}async setAutoApproveConfig(e,t){return await this.requestWithTracking("set_auto_approve_config",e,t)}async setConsumptionLimits(e,t){return await this.requestWithTracking("set_consumption_limits",e,t)}async setEditing(e,t){return await this.requestWithTracking("set_editing",e,t)}async setKeepOpenOnComplete(e,t){return await this.requestWithTracking("set_keep_open_on_complete",e,t)}async setLegalHold(e,t){return await this.requestWithTracking("set_legal_hold",e,t)}async setLogging(e,t){return await this.requestWithTracking("set_logging",e,t)}async setOauthClientEnabled(e,t){return await this.requestWithTracking("set_oauth_client_enabled",e,t)}async setRetentionPolicy(e,t){return await this.requestWithTracking("set_retention_policy",e,t)}async setStudioWorkspaceArchived(e,t){return await this.requestWithTracking("set_studio_workspace_archived",e,t)}async setStudioWorkspaceThread(e,t){return await this.requestWithTracking("set_studio_workspace_thread",e,t)}async setUserSetting(e,t){return await this.requestWithTracking("set_user_setting",e,t)}async setWorkBlock(e,t){return await this.requestWithTracking("set_work_block",e,t)}async setWorkBlockV2(e,t){return await this.requestWithTracking("set_work_block_v2",e,t)}async setWorkblockCommitMessage(e,t){return await this.requestWithTracking("set_workblock_commit_message",e,t)}async setWorkblockRunDataTruncation(e,t){return await this.requestWithTracking("set_workblock_run_data_truncation",e,t)}async setWorkblockSchedulePaused(e,t){return await this.requestWithTracking("set_workblock_schedule_paused",e,t)}async startBranchThread(e,t){return await this.requestWithTracking("start_branch_thread",e,t)}async startWb(e,t){return await this.requestWithTracking("start_wb",e,t)}async storeWorkBlock(e,t){return await this.requestWithTracking("store_work_block",e,t)}async switchStreamBranch(e,t){return await this.requestWithTracking("switch_stream_branch",e,t)}async syncWorkblock(e,t){return await this.requestWithTracking("sync_workblock",e,t)}async syncWorkblockVersion(e,t){return await this.requestWithTracking("sync_workblock_version",e,t)}async temporalCancelWorkflow(e,t){return await this.requestWithTracking("temporal_cancel_workflow",e,t)}async temporalResetWorkflow(e,t){return await this.requestWithTracking("temporal_reset_workflow",e,t)}async temporalSignalWorkflow(e,t){return await this.requestWithTracking("temporal_signal_workflow",e,t)}async temporalTerminateWorkflow(e,t){return await this.requestWithTracking("temporal_terminate_workflow",e,t)}async transcribeAudio(e,t){return await this.requestWithTracking("transcribe_audio",e,t)}async triggerWorkblockSchedule(e,t){return await this.requestWithTracking("trigger_workblock_schedule",e,t)}async uninstallWorkblock(e,t){return await this.requestWithTracking("uninstall_workblock",e,t)}async updateAccessToken(e,t){return await this.requestWithTracking("update_access_token",e,t)}async updateAccount(e,t){return await this.requestWithTracking("update_account",e,t)}async updateCredential(e,t){return await this.requestWithTracking("update_credential",e,t)}async updateGroup(e,t){return await this.requestWithTracking("update_group",e,t)}async updateLearningExample(e,t){return await this.requestWithTracking("update_learning_example",e,t)}async updateOauthClient(e,t){return await this.requestWithTracking("update_oauth_client",e,t)}async updateProfile(e,t){return await this.requestWithTracking("update_profile",e,t)}async updateStudioWorkspaceTitle(e,t){return await this.requestWithTracking("update_studio_workspace_title",e,t)}async updateTask(e,t){return await this.requestWithTracking("update_task",e,t)}async updateUser(e,t){return await this.requestWithTracking("update_user",e,t)}async updateWorkblockSchedule(e,t){return await this.requestWithTracking("update_workblock_schedule",e,t)}async upsertSpace(e,t){return await this.requestWithTracking("upsert_space",e,t)}async addLearningData(e,t){return await this.client.sendMessage({type:"add_learning_data",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async addStreamLogs(e,t){return await this.client.sendMessage({type:"add_stream_logs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDiffVersions(e,t){return await this.client.sendMessage({type:"authz_schema_diff_versions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftGetEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_get_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftSubscribeAwarenessEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_subscribe_awareness_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftSubscribeDraftReplacedEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_subscribe_draft_replaced_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftSubscribeEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_subscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftSubscribeValidationEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_subscribe_validation_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftUnsubscribeAwarenessEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_unsubscribe_awareness_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftUnsubscribeDraftReplacedEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_unsubscribe_draft_replaced_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftUnsubscribeEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_unsubscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaDraftUnsubscribeValidationEvents(e,t){return await this.client.sendMessage({type:"authz_schema_draft_unsubscribe_validation_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGet(e,t){return await this.client.sendMessage({type:"authz_schema_get",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGetAppliedEnvelope(e,t){return await this.client.sendMessage({type:"authz_schema_get_applied_envelope",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGetDraftState(e,t){return await this.client.sendMessage({type:"authz_schema_get_draft_state",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGetForWorkblock(e,t){return await this.client.sendMessage({type:"authz_schema_get_for_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaGetVersion(e,t){return await this.client.sendMessage({type:"authz_schema_get_version",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaImpactReport(e,t){return await this.client.sendMessage({type:"authz_schema_impact_report",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaListOrphanedResources(e,t){return await this.client.sendMessage({type:"authz_schema_list_orphaned_resources",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaListRoleMemberships(e,t){return await this.client.sendMessage({type:"authz_schema_list_role_memberships",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaListVersions(e,t){return await this.client.sendMessage({type:"authz_schema_list_versions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaPreviewValidation(e,t){return await this.client.sendMessage({type:"authz_schema_preview_validation",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaQueryAudit(e,t){return await this.client.sendMessage({type:"authz_schema_query_audit",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async authzSchemaValidate(e,t){return await this.client.sendMessage({type:"authz_schema_validate",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async batchCheckWorkblockMergeability(e,t){return await this.client.sendMessage({type:"batch_check_workblock_mergeability",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async batchGetEvents(e,t){return await this.client.sendMessage({type:"batch_get_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async changelogList(e,t){return await this.client.sendMessage({type:"changelog_list",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkChild(e,t){return await this.client.sendMessage({type:"check_child",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkCredential(e,t){return await this.client.sendMessage({type:"check_credential",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkPermission(e,t){return await this.client.sendMessage({type:"check_permission",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkStreamAccess(e,t){return await this.client.sendMessage({type:"check_stream_access",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async checkWorkblockBranchMergeability(e,t){return await this.client.sendMessage({type:"check_workblock_branch_mergeability",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async closeWorkblockRunDataSession(e,t){return await this.client.sendMessage({type:"close_workblock_run_data_session",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async consoleLog(e,t){return await this.client.sendMessage({type:"console_log",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async countWorkblockRegistrationEvents(e,t){return await this.client.sendMessage({type:"count_workblock_registration_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async createWorkblockTokenUrl(e,t){return await this.client.sendMessage({type:"create_workblock_token_url",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async diffWorkblockReplayTest(e,t){return await this.client.sendMessage({type:"diff_workblock_replay_test",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async discoverCredentialOauth(e,t){return await this.client.sendMessage({type:"discover_credential_oauth",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async evaluateWorkblockRunDataTransformQuery(e,t){return await this.client.sendMessage({type:"evaluate_workblock_run_data_transform_query",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async findLearningDuplicates(e,t){return await this.client.sendMessage({type:"find_learning_duplicates",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async findStudioWorkspaceOnBranch(e,t){return await this.client.sendMessage({type:"find_studio_workspace_on_branch",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async findWorkblockRows(e,t){return await this.client.sendMessage({type:"find_workblock_rows",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAccount(e,t){return await this.client.sendMessage({type:"get_account",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getActiveWorkblockSetting(e,t){return await this.client.sendMessage({type:"get_active_workblock_setting",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAffectedRunsCount(e,t){return await this.client.sendMessage({type:"get_affected_runs_count",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAgentTurn(e,t){return await this.client.sendMessage({type:"get_agent_turn",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAutoApproveConfig(e,t){return await this.client.sendMessage({type:"get_auto_approve_config",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getAvailableModels(e,t){return await this.client.sendMessage({type:"get_available_models",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getBaseWorkblockVersion(e,t){return await this.client.sendMessage({type:"get_base_workblock_version",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getConsumptionStatus(e,t){return await this.client.sendMessage({type:"get_consumption_status",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getCredentialForEdit(e,t){return await this.client.sendMessage({type:"get_credential_for_edit",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getDefaultWorkblockRegistration(e,t){return await this.client.sendMessage({type:"get_default_workblock_registration",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getDocsContent(e,t){return await this.client.sendMessage({type:"get_docs_content",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getEditStreamId(e,t){return await this.client.sendMessage({type:"get_edit_stream_id",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getEvents(e,t){return await this.client.sendMessage({type:"get_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getInstalledWorkblock(e,t){return await this.client.sendMessage({type:"get_installed_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getLearningExample(e,t){return await this.client.sendMessage({type:"get_learning_example",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getLearningExamples(e,t){return await this.client.sendMessage({type:"get_learning_examples",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getLlmRawCall(e,t){return await this.client.sendMessage({type:"get_llm_raw_call",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getLoginHistory(e,t){return await this.client.sendMessage({type:"get_login_history",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getPendingLearningData(e,t){return await this.client.sendMessage({type:"get_pending_learning_data",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getRegistryWorkblock(e,t){return await this.client.sendMessage({type:"get_registry_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getRegistryWorkblockInfo(e,t){return await this.client.sendMessage({type:"get_registry_workblock_info",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getReplayTestRunState(e,t){return await this.client.sendMessage({type:"get_replay_test_run_state",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getRetentionPolicy(e,t){return await this.client.sendMessage({type:"get_retention_policy",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getSpace(e,t){return await this.client.sendMessage({type:"get_space",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getStream(e,t){return await this.client.sendMessage({type:"get_stream",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getStreamLogs(e,t){return await this.client.sendMessage({type:"get_stream_logs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getStudioWorkspace(e,t){return await this.client.sendMessage({type:"get_studio_workspace",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getStudioWorkspacePresence(e,t){return await this.client.sendMessage({type:"get_studio_workspace_presence",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getTaskLogs(e,t){return await this.client.sendMessage({type:"get_task_logs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getTimelineAffectedCount(e,t){return await this.client.sendMessage({type:"get_timeline_affected_count",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getTimelineEventTypes(e,t){return await this.client.sendMessage({type:"get_timeline_event_types",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getTos(e,t){return await this.client.sendMessage({type:"get_tos",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getUserSetting(e,t){return await this.client.sendMessage({type:"get_user_setting",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getUsers(e,t){return await this.client.sendMessage({type:"get_users",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkBlockRuns(e,t){return await this.client.sendMessage({type:"get_work_block_runs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblock(e,t){return await this.client.sendMessage({type:"get_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockBranchInfo(e,t){return await this.client.sendMessage({type:"get_workblock_branch_info",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockCommitLog(e,t){return await this.client.sendMessage({type:"get_workblock_commit_log",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockCommitPatch(e,t){return await this.client.sendMessage({type:"get_workblock_commit_patch",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockDataSchema(e,t){return await this.client.sendMessage({type:"get_workblock_data_schema",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockFileContent(e,t){return await this.client.sendMessage({type:"get_workblock_file_content",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsConsumption(e,t){return await this.client.sendMessage({type:"get_workblock_operations_consumption",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsCurrent(e,t){return await this.client.sendMessage({type:"get_workblock_operations_current",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsFailures(e,t){return await this.client.sendMessage({type:"get_workblock_operations_failures",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsOutcomes(e,t){return await this.client.sendMessage({type:"get_workblock_operations_outcomes",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockOperationsRuns(e,t){return await this.client.sendMessage({type:"get_workblock_operations_runs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockRun(e,t){return await this.client.sendMessage({type:"get_workblock_run",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockRunDataSchemaVersionDetails(e,t){return await this.client.sendMessage({type:"get_workblock_run_data_schema_version_details",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockRunInputs(e,t){return await this.client.sendMessage({type:"get_workblock_run_inputs",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockRunResult(e,t){return await this.client.sendMessage({type:"get_workblock_run_result",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockSchedule(e,t){return await this.client.sendMessage({type:"get_workblock_schedule",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockTaskErrors(e,t){return await this.client.sendMessage({type:"get_workblock_task_errors",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockUi(e,t){return await this.client.sendMessage({type:"get_workblock_ui",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockUpstream(e,t){return await this.client.sendMessage({type:"get_workblock_upstream",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockV2(e,t){return await this.client.sendMessage({type:"get_workblock_v2",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async getWorkblockVersion(e,t){return await this.client.sendMessage({type:"get_workblock_version",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async inspectFile(e,t){return await this.client.sendMessage({type:"inspect_file",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async invokeTask(e,t){return await this.client.sendMessage({type:"invoke_task",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listAccessTokens(e,t){return await this.client.sendMessage({type:"list_access_tokens",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listApprovedLearningSets(e,t){return await this.client.sendMessage({type:"list_approved_learning_sets",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listCategories(e,t){return await this.client.sendMessage({type:"list_categories",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listCredentialTypes(e,t){return await this.client.sendMessage({type:"list_credential_types",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listCredentials(e,t){return await this.client.sendMessage({type:"list_credentials",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listGroupMembers(e,t){return await this.client.sendMessage({type:"list_group_members",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listGroups(e,t){return await this.client.sendMessage({type:"list_groups",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listInstalledWorkblocks(e,t){return await this.client.sendMessage({type:"list_installed_workblocks",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLearningDataSets(e,t){return await this.client.sendMessage({type:"list_learning_data_sets",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLearningExamples(e,t){return await this.client.sendMessage({type:"list_learning_examples",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLearningExamplesByScore(e,t){return await this.client.sendMessage({type:"list_learning_examples_by_score",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLearningSetsForWorkblock(e,t){return await this.client.sendMessage({type:"list_learning_sets_for_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listLlmRawCalls(e,t){return await this.client.sendMessage({type:"list_llm_raw_calls",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listMyOauthConsents(e,t){return await this.client.sendMessage({type:"list_my_oauth_consents",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listMyPermissionRequests(e,t){return await this.client.sendMessage({type:"list_my_permission_requests",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listNotifications(e,t){return await this.client.sendMessage({type:"list_notifications",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listOauthClients(e,t){return await this.client.sendMessage({type:"list_oauth_clients",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listOauthRegistrationTokens(e,t){return await this.client.sendMessage({type:"list_oauth_registration_tokens",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listOwnedRegistryWorkblocks(e,t){return await this.client.sendMessage({type:"list_owned_registry_workblocks",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listPendingLearningData(e,t){return await this.client.sendMessage({type:"list_pending_learning_data",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listQdrantCollections(e,t){return await this.client.sendMessage({type:"list_qdrant_collections",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listRegistryWorkblocks(e,t){return await this.client.sendMessage({type:"list_registry_workblocks",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listRowstoreCollections(e,t){return await this.client.sendMessage({type:"list_rowstore_collections",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listSpaces(e,t){return await this.client.sendMessage({type:"list_spaces",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listStudioWorkspaces(e,t){return await this.client.sendMessage({type:"list_studio_workspaces",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockBranches(e,t){return await this.client.sendMessage({type:"list_workblock_branches",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockDefinitions(e,t){return await this.client.sendMessage({type:"list_workblock_definitions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockRegistrations(e,t){return await this.client.sendMessage({type:"list_workblock_registrations",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockRowCollections(e,t){return await this.client.sendMessage({type:"list_workblock_row_collections",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockRunDataSchemaVersions(e,t){return await this.client.sendMessage({type:"list_workblock_run_data_schema_versions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockRunDataTruncations(e,t){return await this.client.sendMessage({type:"list_workblock_run_data_truncations",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockSchedules(e,t){return await this.client.sendMessage({type:"list_workblock_schedules",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async listWorkblockVersions(e,t){return await this.client.sendMessage({type:"list_workblock_versions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async permissionsCheck(e,t){return await this.client.sendMessage({type:"permissions_check",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async permissionsDefinitions(e,t){return await this.client.sendMessage({type:"permissions_definitions",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async permissionsListSubjects(e,t){return await this.client.sendMessage({type:"permissions_list_subjects",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async permissionsLookupResources(e,t){return await this.client.sendMessage({type:"permissions_lookup_resources",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async previewContinueFromMessage(e,t){return await this.client.sendMessage({type:"preview_continue_from_message",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async queryAuditLog(e,t){return await this.client.sendMessage({type:"query_audit_log",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async queryWorkblockRunData(e,t){return await this.client.sendMessage({type:"query_workblock_run_data",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async repeatDone(e,t){return await this.client.sendMessage({type:"repeat_done",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async resolveWorkblockByTask(e,t){return await this.client.sendMessage({type:"resolve_workblock_by_task",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async resolveWorkblockContent(e,t){return await this.client.sendMessage({type:"resolve_workblock_content",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async runtimeAuthzCheck(e,t){return await this.client.sendMessage({type:"runtime_authz_check",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async runtimeAuthzLookupResources(e,t){return await this.client.sendMessage({type:"runtime_authz_lookup_resources",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async runtimeAuthzLookupSubjects(e,t){return await this.client.sendMessage({type:"runtime_authz_lookup_subjects",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async sandboxTest(e,t){return await this.client.sendMessage({type:"sandbox_test",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async sandboxTestResponse(e,t){return await this.client.sendMessage({type:"sandbox_test_response",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async searchLearningExamples(e,t){return await this.client.sendMessage({type:"search_learning_examples",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async sendTaskProgress(e,t){return await this.client.sendMessage({type:"send_task_progress",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async sendTaskRunEvent(e,t){return await this.client.sendMessage({type:"send_task_run_event",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async setAgentComplete(e,t){return await this.client.sendMessage({type:"set_agent_complete",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async setWorkblockRunDataTransformQuery(e,t){return await this.client.sendMessage({type:"set_workblock_run_data_transform_query",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async startChild(e,t){return await this.client.sendMessage({type:"start_child",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalExportHistory(e,t){return await this.client.sendMessage({type:"temporal_export_history",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalGetStack(e,t){return await this.client.sendMessage({type:"temporal_get_stack",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalGetWorkflow(e,t){return await this.client.sendMessage({type:"temporal_get_workflow",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalListWorkflowTypes(e,t){return await this.client.sendMessage({type:"temporal_list_workflow_types",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalQueryWorkflow(e,t){return await this.client.sendMessage({type:"temporal_query_workflow",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalSearchWorkflows(e,t){return await this.client.sendMessage({type:"temporal_search_workflows",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async temporalStreamHistory(e,t){return await this.client.sendMessage({type:"temporal_stream_history",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async upsertMemo(e,t){return await this.client.sendMessage({type:"upsert_memo",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async validateTask(e,t){return await this.client.sendMessage({type:"validate_task",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async validateWorkblock(e,t){return await this.client.sendMessage({type:"validate_workblock",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async wbRunTest(e,t){return await this.client.sendMessage({type:"wb_run_test",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsEmitEvent(e,t){return await this.client.sendMessage({type:"yjs_emit_event",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsGetEvents(e,t){return await this.client.sendMessage({type:"yjs_get_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsResetEvents(e,t){return await this.client.sendMessage({type:"yjs_reset_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsStreamEmitEvent(e,t){return await this.client.sendMessage({type:"yjs_stream_emit_event",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsStreamSubscribeEvents(e,t){return await this.client.sendMessage({type:"yjs_stream_subscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsStreamUnsubscribeEvents(e,t){return await this.client.sendMessage({type:"yjs_stream_unsubscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsSubscribeEvents(e,t){return await this.client.sendMessage({type:"yjs_subscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async yjsUnsubscribeEvents(e,t){return await this.client.sendMessage({type:"yjs_unsubscribe_events",stream_id:t?.streamId,thread_id:t?.threadId,timeout:t?.timeoutSeconds,task_id:t?.taskId,request:e})}async requestWithTracking(e,t,r){let i=Date.now(),o={options_streamId:r?.streamId,options_threadId:r?.threadId,...this.sanitizeForAnalytics(t)};try{let n=await this.client.sendMessage({type:e,stream_id:r?.streamId,thread_id:r?.threadId,timeout:r?.timeoutSeconds,task_id:r?.taskId,model:r?.model,reasoning_effort:r?.reasoningEffort,request:t});return this.trackEventSafely(`user-action/${e}`,{...o,success:!0,duration:Date.now()-i}),n}catch(n){throw this.trackEventSafely(`user-action/${e}`,{...o,success:!1,duration:Date.now()-i,errorType:n instanceof Error?n.name:"Unknown"}),n}}trackEventSafely(e,t){try{this.analyticsClient?.track?.(e,t)}catch(r){console.error("Analytics tracking failed:",r)}}sanitizeForAnalytics(e){if(!e||typeof e!="object")return{hasContent:!!e};let t={};for(let[r,i]of Object.entries(e))(r.endsWith("_id")||r.endsWith("_ids")||r==="id")&&(t[r]=i);return t}};var dr=class extends Error{code;constructor(e,t){super(e),this.name="BwWebsocketError",this.code=t}},Os=180,ur=class{streamHandlers=[];eventHandlers=[];currentUserHandlers=[];onDisconnect=[];errorHandlers=[];connectionErrorHandlers=[];ws=null;store={};SequenceID=0;connected;blobURL;token;tokenSource;lastCleanup=0;requestTimeoutMs=3e4;runnerStartAllowanceMs=95e3;connectionHost;connectionUrl;lastConnectionError;closing=!1;debug;currentUser;requests=new Ec({sendMessage:e=>this.send(e)});constructor(e=!1){this.debug=e}addStreamHandler(e){this.streamHandlers.push(e)}addEventHandler(e){this.eventHandlers.push(e)}addCurrentUserHandler(e){this.currentUserHandlers.push(e)}addErrorHandler(e){this.errorHandlers.push(e)}addConnectionErrorHandler(e){this.connectionErrorHandlers.push(e)}addOnDisconnect(e){this.onDisconnect.push(e)}useTokenSource(e){this.tokenSource=e}close(){this.closing=!0,this.ws?.close()}connect(e,t){this.connectionHost=e,this.lastConnectionError=void 0,this.connected=!1,this.closing=!1,e.indexOf("://")===-1&&(e=`https://${e}`),this.token=t;let r=new URL(e);r.protocol==="ws:"?r.protocol="http:":r.protocol==="wss:"&&(r.protocol="https:"),!r.hostname.startsWith("api.")&&!r.hostname.startsWith("localhost")&&(r.hostname=`api.${r.hostname}`),r.pathname=r.pathname.replace("/workblocks/streams",""),r.pathname.endsWith("/")&&(r.pathname=r.pathname.slice(0,-1)),r.pathname=r.pathname+"/blobs",this.blobURL=r.toString();let i=new URL(e);switch(i.protocol){case"https:":i.protocol="wss:";break;case"http:":i.protocol="ws:";break}!i.hostname.startsWith("api.")&&!i.hostname.startsWith("localhost")&&(i.hostname=`api.${i.hostname}`),i.pathname.endsWith("/streams")||(i.pathname="/workblocks/streams"),this.connectionUrl=i.toString();let o=new Sc(i.toString(),{headers:{Authorization:`Bearer ${t}`}});this.ws=o,o.on("open",()=>{this.ws===o&&(this.connected=!0,this.lastConnectionError=void 0)}),o.on("unexpected-response",(n,a)=>{this.ws===o&&this.reportConnectionError(`Unexpected server response: ${a.statusCode}`,a.statusCode),o.terminate()}),o.on("message",n=>{if(this.ws!==o)return;let a=JSON.parse(n.toString());if(this.debug&&console.error("Received message","type"in a?a.type:"error","reply_to"in a?a.reply_to:void 0),"reply_to"in a){if(a.reply_to===void 0)return;let c=this.store[a.reply_to];c&&(delete this.store[a.reply_to],clearTimeout(c.timeoutHandle),"error"in a?c.reject(new dr(a.error,a.error_type??"")):c.resolve(a.response));return}if("error"in a){this.errorHandlers.forEach(c=>c(a.error));return}a.type==="streams"?this.handleListStreams(a.response):a.type==="events"?this.handleEvents(a.response).catch(c=>{console.error(c)}):a.type==="whoami"&&this.handleCurrentUser(a.response)}),o.on("close",(n,a)=>{this.ws===o&&(this.connected||this.closing||this.lastConnectionError||this.reportConnectionError(`Connection closed before it was established. Code: ${n}, Reason: ${a||"none"}`),this.rejectAllPending(new Error(`WebSocket disconnected. Code: ${n}, Reason: ${a}`)),this.onDisconnect.forEach(c=>c()))}),o.on("error",async n=>{this.ws===o&&(this.connected||this.closing||this.lastConnectionError||this.reportConnectionError(n.message),this.rejectAllPending(new Error(`WebSocket error: ${n.message}`)))})}waitForOpen(){if(this.connected)return Promise.resolve();let e=this.ws;return e?e.readyState===Sc.OPEN?(this.connected=!0,Promise.resolve()):new Promise((t,r)=>{let i=()=>{c(),t()},o=l=>{c(),r(new Error(`WebSocket error: ${l.message}`))},n=(l,d)=>{c(),r(new Error(`WebSocket error: Unexpected server response: ${d.statusCode}`))},a=(l,d)=>{c(),r(new Error(`WebSocket disconnected. Code: ${l}, Reason: ${d}`))},c=()=>{e.removeListener("open",i),e.removeListener("error",o),e.removeListener("unexpected-response",n),e.removeListener("close",a)};e.on("open",i),e.on("error",o),e.on("unexpected-response",n),e.on("close",a)}):Promise.reject(new Error("WebSocket not connected"))}fetchWithCache(e,t){return fetch(e,t)}async _send(e,t){return this.ws&&this.ws.readyState===Sc.OPEN?(this.SequenceID++,new Promise((r,i)=>{let o=this.SequenceID,n=(t??this.requestTimeoutMs)+this.runnerStartAllowanceMs,a=setTimeout(()=>{let c=this.store[o];c&&(delete this.store[o],c.reject(new Error(`Request timed out after ${n}ms${c.type?` (type=${c.type})`:""}`)))},n);this.store[o]={resolve:r,reject:i,timeoutHandle:a,type:e.type},this.ws?.send(JSON.stringify({...e,seq:o}))})):Promise.reject("WebSocket not connected")}async requestRaw(e,t,r={}){let i=r.timeoutSeconds;return await this._send({type:e,stream_id:r.streamId,timeout:i,request:t},i===void 0?void 0:(i+5)*1e3)}async send(e){let t=e.timeout===void 0?void 0:(e.timeout+5)*1e3;return await this._send(e,t)}async setWorkblock(e,t){let r=await this.requests.setWorkBlockV2({workblock:t},{streamId:e,timeoutSeconds:Os});return{errors:r.errors??[],warnings:r.warnings??[]}}async getWorkblock(e){return await this.requests.getWorkblock({},{streamId:e})??void 0}async getWorkblockById(e){return await this.requests.getWorkblock({id:e})??void 0}async storeWorkblock(e){let t;try{if(t=await this.getWorkblockById(e.id),!t)throw new Error(`Workblock lookup for ${e.id} returned no definition`)}catch(o){if(!(o instanceof dr&&o.code==="NotFound"))throw o;t=void 0}if(!t)return await this.createWorkblock(e);let r=await this.requests.getEditStream({workblock_id:e.id}),i=await this.setWorkblock(r.id,e);if(i.errors.length>0)throw new Error(`Validation errors: ${JSON.stringify(i.errors)}`);return{stream:r,warnings:i.warnings}}async initializeWorkblock(e,t){return await this.requests.createWorkblock({workblock:e,feature_branch:t},{timeoutSeconds:Os})}async createWorkblock(e,t){let r=await this.requests.createWorkblock(t?{workblock:e,feature_branch:t}:{workblock:e},{timeoutSeconds:Os});if(r.errors?.length)throw new Error(`Validation errors: ${JSON.stringify(r.errors)}`);return{stream:r.stream,warnings:r.warnings??[]}}async listWorkblockDefinitions(){return await this.requests.listWorkblockDefinitions({})}async listWorkblockBranches(e){return(await this.requests.listWorkblockBranches({workblock_id:e})).branches}async getActiveWorkblockSetting(e){return(await this.requests.getActiveWorkblockSetting({workblock_id:e})).branch}async setActiveWorkblockSetting(e,t){await this.requests.setActiveWorkblockSetting({workblock_id:e,branch:t})}async createStudioWorkspace(e,t,r,i=!1){return(await this.requests.createStudioWorkspace({workblock_id:e,branch:t,title:r,create_user_branch:i})).stream}async findStudioWorkspaceOnBranch(e,t){return(await this.requests.findStudioWorkspaceOnBranch({workblock_id:e,target_branch:t})).stream_id}async getStudioWorkspace(e){return(await this.requests.getStudioWorkspace({stream_id:e})).workspace??void 0}async listStudioWorkspaces(e,t){if(!e&&!t)throw new Error("listStudioWorkspaces requires a user id or a workblock id");return(await this.requests.listStudioWorkspaces({user_id:e,workblock_id:t})).workspaces??[]}async getBlob(e){return this.debug&&console.error(`Getting blob ${e}`),e.startsWith("::bw:data:")?(await this.getBlobContent(e)).text:e}async getBlobContent(e){let t=this.tokenSource?await this.tokenSource():this.token,r=await this.fetchWithCache(`${this.blobURL}?key=${encodeURIComponent(e)}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});if(!r.ok)throw new Error(`Failed to fetch blob ${e}: ${r.status} ${r.statusText}`);return{contentType:r.headers.get("content-type")??"",text:await r.text()}}waitForCurrentUser(e=1e4){return this.currentUser?Promise.resolve(this.currentUser):new Promise((t,r)=>{let i=setTimeout(()=>r(new Error("The server did not announce the current user")),e);this.currentUserHandlers.push(o=>{clearTimeout(i),t(o)})})}async getWorkblockV2ById(e){return await this.requests.getWorkblockV2({id:e,resolve_blobs:!0})??void 0}async resolveWorkblockContent(e,t){return await this.requests.resolveWorkblockContent({workblock_id:e,commit_ref:t})}async createWorkblockVersion(e,t,r){return await this.requests.createWorkblockVersion({workblock_id:e,feature_branch:t,workspace_name:r},{timeoutSeconds:Os})}async setWorkblockV2(e,t,r){return await this.requests.setWorkBlockV2({workblock:t,branch:r.branch,expected_commit_ref:r.expectedCommitRef,advance_version:r.advanceVersion||void 0},{streamId:e,timeoutSeconds:Os})}async validateWorkblock(e){return await this.requests.validateWorkblock(e,{timeoutSeconds:Os})}async syncWorkblockVersion(e){return await this.requests.syncWorkblockVersion({},{streamId:e,timeoutSeconds:Os})}async getWorkspaceWorkblock(e){return await this.requests.getWorkblockV2({},{streamId:e})??void 0}async getDocsContent(){return(await this.requests.getDocsContent({})).content}async runModule(e,t,r){return(await this.requests.runModule({module_id:t,inputs:r},{streamId:e})).run_id}async runSingleTask(e,t,r,i){return await this.requests.runSingleTask({module_id:t,task_id:r,inputs:i},{streamId:e})}async invokeWorkblockTask(e){return(await this.requests.invokeWorkblockTask({workblock_id:e.workblockId,module_id:e.moduleId,task_id:e.taskId,commit_ref:e.commitRef,inputs:e.inputs},{streamId:e.streamId,timeoutSeconds:e.timeoutSeconds})).outputs??{}}async runModuleTests(e,t,r){return(await this.requests.wbRunTest({module_id:r,workblock_id:t},{streamId:e,timeoutSeconds:Os})).result??[]}async getWorkblockRun(e){return await this.requests.getWorkblockRun({id:e.runId,stream_id:e.runId?void 0:e.streamId,include_ephemeral:!0,nil_on_no_run:!0})??void 0}async getTaskLogs(e,t){return await this.requests.getTaskLogs({run_id:e,task_id:t})??[]}async cancelWorkblockRun(e,t){await this.requests.cancelWb({workblock_run_id:t},{streamId:e})}disconnect(){this.connected=!1,this.closing=!0,this.rejectAllPending(new Error("WebSocket disconnected")),this.ws?.close(),this.streamHandlers=[],this.eventHandlers=[],this.currentUserHandlers=[],this.store={},this.SequenceID=0}handleListStreams(e){let t=[];(e??[]).forEach(r=>{r.editing&&t.push(r)}),this.streamHandlers.forEach(r=>r(t))}async handleEvents(e){for(let t of this.eventHandlers)await t(e)}handleCurrentUser(e){this.currentUser=e,this.currentUserHandlers.forEach(t=>t(e))}rejectAllPending(e){for(let[t,r]of Object.entries(this.store))r&&(clearTimeout(r.timeoutHandle),r.reject(e),delete this.store[Number(t)])}reportConnectionError(e,t){this.lastConnectionError=e,this.connectionErrorHandlers.forEach(r=>r({host:this.connectionHost,url:this.connectionUrl,reason:e,statusCode:t}))}};var fi=O(require("path"));function yk(s){return s.task?.error??s.test?.error??s.module?.error??s.business_event?.error??s.library?.error??s.workblock?.error??JSON.stringify(s)}function xk(s,e){return fi.relative(s,e).split(fi.sep).join("/")}function Zq(s,e){let t=[];for(let[r,i]of[["react_components",e.react_components],["python",e.python]])for(let o of Object.keys(i??{}))s.includes(o)&&t.push(`${r}/${o}`);return t}function eN(s,e,t){let r=e.modules??[],i=[],o,n=s.workblock?.error??"";if(s.task){n=s.task.error;let a=r[s.task.module_index],c=a?.tasks?.[s.task.index];if(a&&c){o=`task ${JSON.stringify(`${a.name}/${c.name}`)}`;let l=fi.join(t,re(a.name),re(c.name)),d=lc(l,re(c.name));i.push(d?xk(t,d):`${xk(t,l)}/`)}else o=`task[${s.task.module_index}/${s.task.index}]`}else if(s.test){n=s.test.error;let a=r[s.test.module_index],c=a?.tests?.[s.test.index];a&&c?(o=`test ${JSON.stringify(`${a.name}/${c.name}`)}`,i.push(`${re(a.name)}/tests/${re(c.name)}.py`)):o=`test[${s.test.module_index}/${s.test.index}]`}else if(s.module||s.business_event){let a=s.module??s.business_event;n=a.error;let c=r[a.module_index];o=c?`module ${JSON.stringify(c.name)}`:`module[${a.module_index}]`}else s.library&&(n=s.library.error,i.push("library.py"));return i.push(...Zq(n,e).filter(a=>!i.includes(a))),i.length===0&&i.push("manifest.yaml"),{...s,paths:i,...o?{label:o}:{}}}function Uo(s,e,t){return s.map(r=>eN(r,e,t))}var tN=/\.(?:tsx?|jsx?|mjs)$/,sN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,rN=/invokeTask\s*(?:<[^>()]*>)?\s*\(\s*(['"`])([^'"`$\n]+)\1/g;function _k(s){let e=s.modules??[],t=(a,c)=>a.has(c)||c.startsWith("bworker.ai:"),r=a=>new Set(a.flatMap(c=>c.id?[c.name,c.id]:[c.name])),i=r(e.flatMap(a=>a.tasks??[])),o=[],n=(a,c,l,d)=>{let p=c?.text;if(!(!p||!tN.test(a)))for(let u of p.matchAll(rN)){let m=u[2];if(t(l,m))continue;let h=p.slice(0,u.index).split(`
220
220
  `).length;o.push({path:a,line:h,message:`invokeTask names ${sN.test(m)?"task id":"task"} ${JSON.stringify(m)}, which no task in ${d} has; the call fails when it runs.`})}};for(let[a,c]of Object.entries(s.react_components??{}))n(`react_components/${a}`,c,i,"the workblock");for(let a of e){let c=r(a.tasks??[]);for(let l of a.tasks??[]){let d=`${re(a.name)}/${re(l.name)}`;for(let[p,u]of Object.entries(l.assets??{}))n(`${d}/assets/${p}`,u,c,`module ${JSON.stringify(a.name)}`)}}return o}function kk(s,e){let t=new Map;for(let i of e.modules??[])t.set(re(i.name),new Set((i.tasks??[]).map(o=>re(o.name))));let r=new Set;for(let i of s){let o=i.path.split("/");if(o.length!==3)continue;let[n,a,c]=o;if(["react_components","python","design_docs"].includes(n)||a==="tests"||!c.endsWith(".py"))continue;let l=t.get(n);(l?!l.has(a):c===`${a}.py`)&&r.add(`${n}/${a}/`)}return[...r].sort()}var wk=require("child_process"),Mt=O(require("fs")),vk=O(require("os")),mi=O(require("path")),Go="refs/wb-cli/base",iN={GIT_AUTHOR_NAME:"wb-cli",GIT_AUTHOR_EMAIL:"wb-cli@beyondwork.ai",GIT_COMMITTER_NAME:"wb-cli",GIT_COMMITTER_EMAIL:"wb-cli@beyondwork.ai",GIT_TERMINAL_PROMPT:"0"};function Tc(s,e,t={}){let r=(0,wk.spawnSync)("git",["-c","commit.gpgsign=false","-c","core.hooksPath=/dev/null","-c","core.autocrlf=false","-c","core.fileMode=false","-c","core.excludesFile=/dev/null",...e],{cwd:s,encoding:"utf8",input:t.input,env:{...process.env,...iN,...t.env},maxBuffer:268435456});if(r.error){let i=r.error.code==="ENOENT";throw new Error(i?"wb-cli needs git on the PATH.":`git ${e[0]}: ${r.error.message}`)}return{status:r.status??1,stdout:r.stdout,stderr:r.stderr}}function Ee(s,e,t){let r=Tc(s,e,t);if(r.status!==0)throw new Error(`git ${e[0]} failed in ${s}: ${(r.stderr||r.stdout).trim()}`);return r.stdout}function hi(s){return s.split("\0").filter(Boolean)}function oN(s){try{return Mt.lstatSync(s),!0}catch{return!1}}function gi(s){return Mt.existsSync(mi.join(s,".git"))}function nN(s){return Tc(s,["rev-parse","-q","--verify",`${Go}^{commit}`]).status===0}function Sk(s){return gi(s)&&nN(s)?hi(Ee(s,["ls-tree","-r","-z","--name-only",Go])):[]}function zo(s){let e=hi(Ee(s,["diff","--name-only","-z","--no-renames",Go])),t=hi(Ee(s,["ls-files","-z","--others","--exclude-standard"]));return[...new Set([...e,...t])].sort()}function Ek(s){let e=hi(Ee(s,["ls-files","-z","--cached","--others","--exclude-standard"]));return[...new Set(e)].filter(t=>oN(mi.join(s,t))).sort()}function aN(s,e,t){let r=Mt.mkdtempSync(mi.join(vk.tmpdir(),"wb-cli-index-"));try{let i={GIT_INDEX_FILE:mi.join(r,"index")};Ee(s,["read-tree","--empty"],{env:i}),t(i,r);let o=Ee(s,["write-tree"],{env:i}).trim(),n=Tc(s,["rev-parse","-q","--verify","HEAD^{commit}"]),a=Ee(s,["commit-tree",o,...n.status===0?["-p",n.stdout.trim()]:[],"-m",e]).trim();return Ee(s,["update-ref","HEAD",a]),Ee(s,["reset","-q"]),a}finally{Mt.rmSync(r,{recursive:!0,force:!0})}}function Tk(s,e,t){return aN(s,t,(r,i)=>{let o=[...e];if(o.length===0)return;let n=o.map(([,l],d)=>{let p=mi.join(i,`blob-${d}`);return Mt.writeFileSync(p,l),p}),a=Ee(s,["hash-object","-w","--stdin-paths"],{input:n.join(`
221
221
  `)+`
222
222
  `}).trim().split(`
@@ -438,6 +438,29 @@ $defs:
438
438
  - output
439
439
  - source
440
440
  type: object
441
+ AddStreamLogsRequest:
442
+ additionalProperties: false
443
+ properties:
444
+ commit_ref:
445
+ description: The version of the workblock that the UI runs, as for invoke_workblock_task. Only workblock editors may use a ref other than main.
446
+ type: string
447
+ entries:
448
+ description: The UI log entries to store. At most 50.
449
+ items:
450
+ $ref: '#/$defs/UIStreamLogEntry'
451
+ type: array
452
+ module_id:
453
+ description: The UI-only module of the UI. Defaults to the entrypoint module of the workblock.
454
+ format: uuid
455
+ type: string
456
+ workblock_id:
457
+ description: The workblock whose UI runs on the stream without a workblock run.
458
+ format: uuid
459
+ type: string
460
+ required:
461
+ - workblock_id
462
+ - entries
463
+ type: object
441
464
  AgentConfig:
442
465
  additionalProperties: false
443
466
  properties:
@@ -3497,6 +3520,26 @@ $defs:
3497
3520
  format: uuid
3498
3521
  type: string
3499
3522
  type: object
3523
+ FindWorkblockRowsRequest:
3524
+ additionalProperties: false
3525
+ properties:
3526
+ collection:
3527
+ description: The collection name that the workblock's code passes to rowstore.
3528
+ type: string
3529
+ limit:
3530
+ description: 'How many rows to return: 100 when empty, at most 1000.'
3531
+ type: integer
3532
+ scope:
3533
+ $ref: '#/$defs/RowstoreCollectionScope'
3534
+ description: 'The scope that the workblock''s code passes to rowstore: global when absent, as in rowstore.'
3535
+ workblock_id:
3536
+ description: The workblock whose code reads and writes the collection.
3537
+ format: uuid
3538
+ type: string
3539
+ required:
3540
+ - workblock_id
3541
+ - collection
3542
+ type: object
3500
3543
  Form:
3501
3544
  additionalProperties: false
3502
3545
  properties:
@@ -4040,6 +4083,34 @@ $defs:
4040
4083
  required:
4041
4084
  - id
4042
4085
  type: object
4086
+ GetStreamLogsRequest:
4087
+ additionalProperties: false
4088
+ properties:
4089
+ limit:
4090
+ description: The maximum number of entries, counted from the newest. The default is 100 and the maximum is 500.
4091
+ type: integer
4092
+ since:
4093
+ description: Leave out the entries that the server stored before this time. The server stores entries in batches, so an entry can have an earlier timestamp than this time.
4094
+ format: date-time
4095
+ type: string
4096
+ workblock_id:
4097
+ description: The workblock that runs on the stream without a workblock run.
4098
+ format: uuid
4099
+ type: string
4100
+ required:
4101
+ - workblock_id
4102
+ type: object
4103
+ GetStreamLogsResponse:
4104
+ additionalProperties: false
4105
+ properties:
4106
+ entries:
4107
+ description: The newest log entries of task invocations and UIs on the stream, oldest first.
4108
+ items:
4109
+ $ref: '#/$defs/StreamLogEntry'
4110
+ type: array
4111
+ required:
4112
+ - entries
4113
+ type: object
4043
4114
  GetStudioWorkspacePresenceRequest:
4044
4115
  additionalProperties: false
4045
4116
  properties:
@@ -5283,6 +5354,27 @@ $defs:
5283
5354
  required:
5284
5355
  - branches
5285
5356
  type: object
5357
+ ListWorkblockRowCollectionsRequest:
5358
+ additionalProperties: false
5359
+ properties:
5360
+ workblock_id:
5361
+ description: The workblock whose collections to list.
5362
+ format: uuid
5363
+ type: string
5364
+ required:
5365
+ - workblock_id
5366
+ type: object
5367
+ ListWorkblockRowCollectionsResult:
5368
+ additionalProperties: false
5369
+ properties:
5370
+ collections:
5371
+ description: The workblock-scoped collections, then the caller's user-scoped ones, each sorted by name.
5372
+ items:
5373
+ $ref: '#/$defs/WorkblockRowCollection'
5374
+ type: array
5375
+ required:
5376
+ - collections
5377
+ type: object
5286
5378
  ListWorkblockRunDataSchemaVersionsRequest:
5287
5379
  additionalProperties: false
5288
5380
  properties:
@@ -6006,6 +6098,7 @@ $defs:
6006
6098
  - authorization_code
6007
6099
  - refresh_token
6008
6100
  - client_credentials
6101
+ - urn:ietf:params:oauth:grant-type:device_code
6009
6102
  type: string
6010
6103
  OAuthRegistrationTokenInfo:
6011
6104
  additionalProperties: false
@@ -7677,6 +7770,8 @@ $defs:
7677
7770
  $ref: '#/$defs/AddGroupMemberRequest'
7678
7771
  add_learning_data:
7679
7772
  $ref: '#/$defs/AddLearningDataRequest'
7773
+ add_stream_logs:
7774
+ $ref: '#/$defs/AddStreamLogsRequest'
7680
7775
  apply_workblock_deployed_updates:
7681
7776
  $ref: '#/$defs/ApplyWorkblockDeployedUpdatesRequest'
7682
7777
  apply_workblock_version_updates:
@@ -7875,6 +7970,8 @@ $defs:
7875
7970
  $ref: '#/$defs/FindDuplicatesRequest'
7876
7971
  find_studio_workspace_on_branch:
7877
7972
  $ref: '#/$defs/FindStudioWorkspaceOnBranchRequest'
7973
+ find_workblock_rows:
7974
+ $ref: '#/$defs/FindWorkblockRowsRequest'
7878
7975
  get_account:
7879
7976
  $ref: '#/$defs/Empty'
7880
7977
  get_active_workblock_setting:
@@ -7929,6 +8026,8 @@ $defs:
7929
8026
  $ref: '#/$defs/GetSpaceStreamArgs'
7930
8027
  get_stream:
7931
8028
  $ref: '#/$defs/GetStreamArgs'
8029
+ get_stream_logs:
8030
+ $ref: '#/$defs/GetStreamLogsRequest'
7932
8031
  get_studio_workspace:
7933
8032
  $ref: '#/$defs/GetStudioWorkspaceRequest'
7934
8033
  get_studio_workspace_presence:
@@ -8069,6 +8168,8 @@ $defs:
8069
8168
  $ref: '#/$defs/ListArgs'
8070
8169
  list_workblock_registrations:
8071
8170
  $ref: '#/$defs/ListRegistrationsArgs'
8171
+ list_workblock_row_collections:
8172
+ $ref: '#/$defs/ListWorkblockRowCollectionsRequest'
8072
8173
  list_workblock_run_data_schema_versions:
8073
8174
  $ref: '#/$defs/ListWorkblockRunDataSchemaVersionsRequest'
8074
8175
  list_workblock_run_data_truncations:
@@ -8453,6 +8554,8 @@ $defs:
8453
8554
  $ref: '#/$defs/Empty'
8454
8555
  add_learning_data:
8455
8556
  $ref: '#/$defs/Empty'
8557
+ add_stream_logs:
8558
+ $ref: '#/$defs/Empty'
8456
8559
  apply_workblock_deployed_updates:
8457
8560
  $ref: '#/$defs/ApplyWorkblockVersionUpdatesResult'
8458
8561
  apply_workblock_version_updates:
@@ -8659,6 +8762,8 @@ $defs:
8659
8762
  $ref: '#/$defs/FindDuplicatesResponse'
8660
8763
  find_studio_workspace_on_branch:
8661
8764
  $ref: '#/$defs/FindStudioWorkspaceOnBranchResponse'
8765
+ find_workblock_rows:
8766
+ $ref: '#/$defs/RowstoreDataFrame'
8662
8767
  get_account:
8663
8768
  $ref: '#/$defs/Account'
8664
8769
  get_active_workblock_setting:
@@ -8715,6 +8820,8 @@ $defs:
8715
8820
  $ref: '#/$defs/GetSpaceStreamResponse'
8716
8821
  get_stream:
8717
8822
  $ref: '#/$defs/Stream'
8823
+ get_stream_logs:
8824
+ $ref: '#/$defs/GetStreamLogsResponse'
8718
8825
  get_studio_workspace:
8719
8826
  $ref: '#/$defs/GetStudioWorkspaceResponse'
8720
8827
  get_studio_workspace_presence:
@@ -8883,6 +8990,8 @@ $defs:
8883
8990
  items:
8884
8991
  $ref: '#/$defs/Registration'
8885
8992
  type: array
8993
+ list_workblock_row_collections:
8994
+ $ref: '#/$defs/ListWorkblockRowCollectionsResult'
8886
8995
  list_workblock_run_data_schema_versions:
8887
8996
  $ref: '#/$defs/ListWorkblockRunDataSchemaVersionsResponse'
8888
8997
  list_workblock_run_data_truncations:
@@ -9396,6 +9505,48 @@ $defs:
9396
9505
  - workblock
9397
9506
  - user
9398
9507
  type: string
9508
+ RowstoreDataFrame:
9509
+ additionalProperties: false
9510
+ properties:
9511
+ columns:
9512
+ items:
9513
+ $ref: '#/$defs/RowstoreHeader'
9514
+ type: array
9515
+ rows:
9516
+ items:
9517
+ $ref: '#/$defs/RowstoreRow'
9518
+ type: array
9519
+ required:
9520
+ - columns
9521
+ - rows
9522
+ type: object
9523
+ RowstoreHeader:
9524
+ additionalProperties: false
9525
+ properties:
9526
+ indexed:
9527
+ type: boolean
9528
+ name:
9529
+ type: string
9530
+ primary_key:
9531
+ type: boolean
9532
+ type:
9533
+ type: string
9534
+ required:
9535
+ - name
9536
+ - type
9537
+ - indexed
9538
+ - primary_key
9539
+ type: object
9540
+ RowstoreRow:
9541
+ additionalProperties: false
9542
+ properties:
9543
+ values:
9544
+ items:
9545
+ type: any
9546
+ type: array
9547
+ required:
9548
+ - values
9549
+ type: object
9399
9550
  RunCodeTestWorkBlockResult:
9400
9551
  additionalProperties: false
9401
9552
  properties:
@@ -10952,6 +11103,31 @@ $defs:
10952
11103
  - explore
10953
11104
  - insight
10954
11105
  type: object
11106
+ StreamLogEntry:
11107
+ additionalProperties: false
11108
+ properties:
11109
+ invocation_id:
11110
+ description: The task invocation that wrote the entry. Not set for UI entries.
11111
+ format: uuid
11112
+ type: string
11113
+ level:
11114
+ $ref: '#/$defs/LogLevel'
11115
+ message:
11116
+ type: string
11117
+ source:
11118
+ type: string
11119
+ task_name:
11120
+ description: The name of the invoked task. Not set for UI entries.
11121
+ type: string
11122
+ timestamp:
11123
+ format: date-time
11124
+ type: string
11125
+ required:
11126
+ - timestamp
11127
+ - source
11128
+ - level
11129
+ - message
11130
+ type: object
10955
11131
  StreamThread:
10956
11132
  additionalProperties: false
10957
11133
  properties:
@@ -12029,6 +12205,23 @@ $defs:
12029
12205
  - task_id
12030
12206
  - data
12031
12207
  type: object
12208
+ UIStreamLogEntry:
12209
+ additionalProperties: false
12210
+ properties:
12211
+ level:
12212
+ $ref: '#/$defs/LogLevel'
12213
+ message:
12214
+ description: The log message. The server cuts a message after 50,000 bytes.
12215
+ type: string
12216
+ timestamp:
12217
+ description: The time of the entry. The server uses its own time when this time is in the future or more than one minute old.
12218
+ format: date-time
12219
+ type: string
12220
+ required:
12221
+ - timestamp
12222
+ - level
12223
+ - message
12224
+ type: object
12032
12225
  UpdateAccessTokenRequest:
12033
12226
  additionalProperties: false
12034
12227
  properties:
@@ -13940,6 +14133,22 @@ $defs:
13940
14133
  - compatible
13941
14134
  - sample
13942
14135
  type: object
14136
+ WorkblockRowCollection:
14137
+ additionalProperties: false
14138
+ properties:
14139
+ columns:
14140
+ items:
14141
+ type: string
14142
+ type: array
14143
+ name:
14144
+ type: string
14145
+ scope:
14146
+ $ref: '#/$defs/RowstoreCollectionScope'
14147
+ required:
14148
+ - name
14149
+ - scope
14150
+ - columns
14151
+ type: object
13943
14152
  WorkblockRunArgs:
13944
14153
  additionalProperties: false
13945
14154
  properties:
@@ -14369,8 +14578,8 @@ $defs:
14369
14578
  required:
14370
14579
  - data_key
14371
14580
  type: object
14372
- `;var At="changes a branch of the workblock; wb-cli push (--update to publish) and pull keep the checkout's branch in step, and deploying to main happens in Studio",aw={deploy_workblock_version:"deploys a version to main, which a person does in Studio",merge_workblock_branch:At,reset_workblock_branch:At,delete_workblock_branch:At,apply_workblock_deployed_updates:At,apply_workblock_version_updates:At,sync_workblock_version:At,sync_workblock:At,resolve_workblock_merge_conflicts:At,create_workblock_version_update:At,revert_workblock_commit:At,switch_stream_branch:At,create_workblock_version:"creates a version; use wb-cli push --new-version <name>, which moves the checkout onto it",set_work_block:"saves workblock content; use wb-cli push, which fences the save against other writers",set_work_block_v2:"saves workblock content; use wb-cli push, which fences the save against other writers",store_work_block:"saves workblock content; use wb-cli push, which fences the save against other writers",delete_studio_workspace:"deletes a Studio workspace and the saves on it; do that in Studio",uninstall_workblock:"removes an installed workblock for every user; do that in Studio",delete_workblock:"deletes the workblock for every user; do that in Studio",publish_to_registry:"publishes the workblock for other tenants; do that in Studio",authz_schema_force_apply:"applies destructive authorization schema changes, which a person confirms in Studio",temporal_reset_workflow:"rewrites a run's history",yjs_reset_events:"discards a document's collaborative history"};function cf(s){return Object.hasOwn(aw,s)?aw[s]:void 0}var af;function lf(){if(!af){let e=(0,cw.parse)(nw).$defs??{},t=r=>e[r]?.properties??{};af={requests:t("RequestsMap"),responses:t("ResponsesMapRaw"),defs:e}}return af}function lw(s){let e=s?.toLowerCase();return Object.keys(lf().requests).filter(t=>!e||t.includes(e)).sort()}function pf(s){return Object.hasOwn(lf().requests,s)}var NN=4;function Yo(s,e,t,r){if(Array.isArray(s))return s.map(o=>Yo(o,e,t,r));if(!s||typeof s!="object")return s;let i=s.$ref;if(typeof i=="string"&&i.startsWith("#/$defs/")){let o=i.slice(8);return t>=NN||r.includes(o)||!e[o]?{$ref:o}:{$def:o,...Yo(e[o],e,t+1,[...r,o])}}return Object.fromEntries(Object.entries(s).filter(([o])=>o!=="additionalProperties").map(([o,n])=>[o,Yo(n,e,t,r)]))}function pw(s){let e=lf();if(!pf(s))throw new Error(`${JSON.stringify(s)} is not a request of this API. List them with wb-cli api --list [filter].`);let t=cf(s);return{verb:s,request:Yo(e.requests[s],e.defs,0,[]),response:Yo(e.responses[s]??null,e.defs,0,[]),...t?{refused:t}:{}}}var D1=O(zr()),Li=require("child_process");var df=(s,e,t)=>{let r=s instanceof RegExp?dw(s,t):s,i=e instanceof RegExp?dw(e,t):e,o=r!==null&&i!=null&&ON(r,i,t);return o&&{start:o[0],end:o[1],pre:t.slice(0,o[0]),body:t.slice(o[0]+r.length,o[1]),post:t.slice(o[1]+i.length)}},dw=(s,e)=>{let t=e.match(s);return t?t[0]:null},ON=(s,e,t)=>{let r,i,o,n,a,c=t.indexOf(s),l=t.indexOf(e,c+1),d=c;if(c>=0&&l>0){if(s===e)return[c,l];for(r=[],o=t.length;d>=0&&!a;){if(d===c)r.push(d),c=t.indexOf(s,d+1);else if(r.length===1){let p=r.pop();p!==void 0&&(a=[p,l])}else i=r.pop(),i!==void 0&&i<o&&(o=i,n=l),l=t.indexOf(e,d+1);d=c<l&&c>=0?c:l}r.length&&n!==void 0&&(a=[o,n])}return a};var uw="\0SLASH"+Math.random()+"\0",fw="\0OPEN"+Math.random()+"\0",hf="\0CLOSE"+Math.random()+"\0",mw="\0COMMA"+Math.random()+"\0",hw="\0PERIOD"+Math.random()+"\0",IN=new RegExp(uw,"g"),jN=new RegExp(fw,"g"),DN=new RegExp(hf,"g"),LN=new RegExp(mw,"g"),FN=new RegExp(hw,"g"),WN=/\\\\/g,BN=/\\{/g,MN=/\\}/g,UN=/\\,/g,GN=/\\\./g,zN=1e5,VN=4e6,HN=1e3,KN=1e3;function uf(s){return isNaN(s)?s.charCodeAt(0):parseInt(s,10)}function JN(s){return s.replace(WN,uw).replace(BN,fw).replace(MN,hf).replace(UN,mw).replace(GN,hw)}function YN(s){return s.replace(IN,"\\").replace(jN,"{").replace(DN,"}").replace(LN,",").replace(FN,".")}function ff(s,e){for(let t=0;t<e.length;t++)s.push(e[t])}function QN(s){let e=[],t="";for(;;){let r=df("{","}",s);if(!r){let c=s.split(",");return c[0]=t+c[0],ff(e,c),e}let{pre:i,body:o,post:n}=r,a=i.split(",");if(a[0]=t+a[0],a[a.length-1]+="{"+o+"}",!n.length)return ff(e,a),e;t=a.pop(),ff(e,a),s=n}}function gw(s,e={}){if(!s)return[];let{max:t=zN,maxLength:r=VN,maxDepth:i=HN,maxRewrites:o=KN}=e;return s.slice(0,2)==="{}"&&(s="\\{\\}"+s.slice(2)),mf(JN(s),t,r,i,0,o,!0).map(YN)}function XN(s){return"{"+s+"}"}function ZN(s){return/^-?0\d/.test(s)}function eO(s,e){return s<=e}function tO(s,e){return s>=e}function Qo(s,e,t,r,i,o){let n=[],a=0;for(let c=0;c<s.length;c++)for(let l=0;l<t.length;l++){if(n.length>=r)return n;let d=s[c]+e+t[l];if(!(o&&!d)){if(a+d.length>i)return n;n.push(d),a+=d.length}}return n}function sO(s,e,t,r){let i=s.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let n=uf(i[0]),a=uf(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(uf(i[2])),1):1,d=eO;a<n&&(l*=-1,d=tO);let u=i.some(ZN),m=0;for(let h=n;d(h,a)&&o.length<t;h+=l){let f;if(e)f=String.fromCharCode(h),f==="\\"&&(f="");else if(f=String(h),u){let g=c-f.length;if(g>0){let b=new Array(g+1).join("0");h<0?f="-"+b+f.slice(1):f=b+f}}if(m+f.length>r)break;o.push(f),m+=f.length}return o}function mf(s,e,t,r,i,o,n){if(i>r)return[s];let a=[""],c=0,l=!1,d=!0;for(;;){let p=df("{","}",s);if(!p)return Qo(a,s,[""],e,t,l);let u=p.pre;if(/\$$/.test(u)){if(a=Qo(a,u+"{"+p.body+"}",[""],e,t,l&&!p.post.length),d=!1,!p.post.length)break;s=p.post;continue}let m=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(p.body),h=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(p.body),f=m||h,g=p.body.indexOf(",")>=0;if(!f&&!g){if(c<o&&p.post.match(/,(?!,).*\}/)){c++,s=p.pre+"{"+p.body+hf+p.post,n=!0;continue}return Qo(a,u+"{"+p.body+"}"+p.post,[""],e,t,l)}d&&(l=n&&!f,d=!1);let b;if(f)b=sO(p.body,h,e,t);else{let x=QN(p.body);if(x.length===1&&x[0]!==void 0&&(x=mf(x[0],e,t,r,i+1,o,!1).map(XN),x.length===1)){if(a=Qo(a,u+x[0],[""],e,t,l&&!p.post.length),!p.post.length)break;s=p.post;continue}let y=l&&!p.post.length&&!u;for(let k=0;y&&k<a.length;k++)a[k]&&(y=!1);b=[];let _=0;e:for(let k=0;k<x.length;k++){let S=mf(x[k],e,t,r,i+1,o,!1);for(let T=0;T<S.length;T++){let E=S[T];if(!(y&&!E)){if(b.length>=e||_+E.length>t)break e;b.push(E),_+=E.length}}}}if(a=Qo(a,u,b,e,t,l&&!p.post.length),!p.post.length)break;s=p.post}return a}var Xo=s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>65536)throw new TypeError("pattern is too long")};var rO={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Zo=s=>s.replace(/[[\]\\-]/g,"\\$&"),iO=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),bw=s=>s.join(""),xw=(s,e)=>{let t=e;if(s.charAt(t)!=="[")throw new Error("not in a brace expression");let r=[],i=[],o=t+1,n=!1,a=!1,c=!1,l=!1,d=t,p="";e:for(;o<s.length;){let f=s.charAt(o);if((f==="!"||f==="^")&&o===t+1){l=!0,o++;continue}if(f==="]"&&n&&!c){d=o+1;break}if(n=!0,f==="\\"&&!c){c=!0,o++;continue}if(f==="["&&!c){for(let[g,[b,x,y]]of Object.entries(rO))if(s.startsWith(g,o)){if(p)return["$.",!1,s.length-t,!0];o+=g.length,y?i.push(b):r.push(b),a=a||x;continue e}}if(c=!1,p){f>p?r.push(Zo(p)+"-"+Zo(f)):f===p&&r.push(Zo(f)),p="",o++;continue}if(s.startsWith("-]",o+1)){r.push(Zo(f+"-")),o+=2;continue}if(s.startsWith("-",o+1)){p=f,o+=2;continue}r.push(Zo(f)),o++}if(d<o)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,s.length-t,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l){let f=r[0].length===2?r[0].slice(-1):r[0];return[iO(f),!1,d-t,!1]}let u="["+(l?"^":"")+bw(r)+"]",m="["+(l?"":"^")+bw(i)+"]";return[r.length&&i.length?"("+u+"|"+m+")":r.length?u:m,a,d-t,!0]};var Pt=(s,{windowsPathsNoEscape:e=!1,magicalBraces:t=!0}={})=>t?e?s.replace(/\[([^/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?s.replace(/\[([^/\\{}])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var Ue,oO=new Set(["!","?","+","*","@"]),gf=s=>oO.has(s),yw=s=>gf(s.type),nO=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),aO=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),cO=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),_w=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),lO="(?!(?:^|/)\\.\\.?(?:$|/))",qc="(?!\\.)",pO=new Set(["[","."]),dO=new Set(["..","."]),uO=new Set("().*{}+?[]^$\\!"),fO=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),bf="[^/]",kw=bf+"*?",ww=bf+"+?",mO=0,hr=class{type;#e;#s;#t=!1;#r=[];#i;#g;#u;#a=!1;#p;#c;#l=!1;id=++mO;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,r={}){this.type=e,e&&(this.#s=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#p=this.#e===this?r:this.#e.#p,this.#u=this.#e===this?[]:this.#e.#u,e==="!"&&!this.#e.#a&&this.#u.push(this),this.#g=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let e of this.#r)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#r.map(e=>String(e)).join("|")+")":this.#c=this.#r.map(e=>String(e)).join("")}#o(){if(this!==this.#e)throw new Error("should only call on root");if(this.#a)return this;this.toString(),this.#a=!0;let e;for(;e=this.#u.pop();){if(e.type!=="!")continue;let t=e,r=t.#i;for(;r;){for(let i=t.#g+1;!r.type&&i<r.#r.length;i++)for(let o of e.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(r.#r[i])}t=r,r=t.#i}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof Ue&&t.#i===this))throw new Error("invalid part: "+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#r.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#a&&this.#i?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#g===0)return!0;let e=this.#i;for(let t=0;t<this.#g;t++){let r=e.#r[t];if(!(r instanceof Ue&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#g===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let t=new Ue(this.type,e);for(let r of this.#r)t.copyIn(r);return t}static#x(e,t,r,i,o){let n=i.maxExtglobRecursion??2,a=!1,c=!1,l=-1,d=!1;if(t.type===null){let f=r,g="";for(;f<e.length;){let b=e.charAt(f++);if(a||b==="\\"){a=!a,g+=b;continue}if(c){f===l+1?(b==="^"||b==="!")&&(d=!0):b==="]"&&!(f===l+2&&d)&&(c=!1),g+=b;continue}else if(b==="["){c=!0,l=f,d=!1,g+=b;continue}if(!i.noext&&gf(b)&&e.charAt(f)==="("&&o<=n){t.push(g),g="";let y=new Ue(b,t);f=Ue.#x(e,y,f,i,o+1),t.push(y);continue}g+=b}return t.push(g),f}let p=r+1,u=new Ue(null,t),m=[],h="";for(;p<e.length;){let f=e.charAt(p++);if(a||f==="\\"){a=!a,h+=f;continue}if(c){p===l+1?(f==="^"||f==="!")&&(d=!0):f==="]"&&!(p===l+2&&d)&&(c=!1),h+=f;continue}else if(f==="["){c=!0,l=p,d=!1,h+=f;continue}if(!i.noext&&gf(f)&&e.charAt(p)==="("&&(o<=n||t&&t.#f(f))){let b=t&&t.#f(f)?0:1;u.push(h),h="";let x=new Ue(f,u);u.push(x),p=Ue.#x(e,x,p,i,o+b);continue}if(f==="|"){u.push(h),h="",m.push(u),u=new Ue(null,t);continue}if(f===")")return h===""&&t.#r.length===0&&(t.#l=!0),u.push(h),h="",t.push(...m,u),p;h+=f}return t.type=null,t.#s=void 0,t.#r=[e.substring(r-1)],p}#w(e){return this.#y(e,aO)}#y(e,t=nO){if(!e||typeof e!="object"||e.type!==null||e.#r.length!==1||this.type===null)return!1;let r=e.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#f(r.type,t)}#f(e,t=cO){return!!t.get(this.type)?.includes(e)}#S(e,t){let r=e.#r[0],i=new Ue(null,r,this.options);i.#r.push(""),r.push(i),this.#m(e,t)}#m(e,t){let r=e.#r[0];this.#r.splice(t,1,...r.#r);for(let i of r.#r)typeof i=="object"&&(i.#i=this);this.#c=void 0}#E(e){return!!_w.get(this.type)?.has(e)}#k(e){if(!e||typeof e!="object"||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!="object"||t.type===null?!1:this.#E(t.type)}#_(e){let t=_w.get(this.type),r=e.#r[0],i=t?.get(r.type);if(!i)return!1;this.#r=r.#r;for(let o of this.#r)typeof o=="object"&&(o.#i=this);this.type=i,this.#c=void 0,this.#l=!1}static fromGlob(e,t={}){let r=new Ue(null,void 0,t);return Ue.#x(e,r,0,t,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,r,i,o]=this.toRegExpSource();if(!(i||this.#s||this.#p.nocase&&!this.#p.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return r;let a=(this.#p.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#p}toRegExpSource(e){let t=e??!!this.#p.dot;if(this.#e===this&&(this.#b(),this.#o()),!yw(this)){let c=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),l=this.#r.map(m=>{let[h,f,g,b]=typeof m=="string"?Ue.#h(m,this.#s,c):m.toRegExpSource(e);return this.#s=this.#s||g,this.#t=this.#t||b,h}).join(""),d="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&dO.has(this.#r[0]))){let h=pO,f=t&&h.has(l.charAt(0))||l.startsWith("\\.")&&h.has(l.charAt(2))||l.startsWith("\\.\\.")&&h.has(l.charAt(4)),g=!t&&!e&&h.has(l.charAt(0));d=f?lO:g?qc:""}let p="";return this.isEnd()&&this.#e.#a&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[d+l+p,Pt(l),this.#s=!!this.#s,this.#t]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#v(t);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let c=this.toString(),l=this;return l.#r=[c],l.type=null,l.#s=void 0,[c,Pt(this.toString()),!1,!1]}let n=!r||e||t||!qc?"":this.#v(!0);n===o&&(n=""),n&&(o=`(?:${o})(?:${n})*?`);let a="";if(this.type==="!"&&this.#l)a=(this.isStart()&&!t?qc:"")+ww;else{let c=this.type==="!"?"))"+(this.isStart()&&!t&&!e?qc:"")+kw+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&n?")":this.type==="*"&&n?")?":`)${this.type}`;a=i+o+c}return[a,Pt(o),this.#s=!!this.#s,this.#t]}#b(){if(yw(this)){let e=0,t=!1;do{t=!0;for(let r=0;r<this.#r.length;r++){let i=this.#r[r];typeof i=="object"&&(i.#b(),this.#y(i)?(t=!1,this.#m(i,r)):this.#w(i)?(t=!1,this.#S(i,r)):this.#k(i)&&(t=!1,this.#_(i)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e=="object"&&e.#b();this.#c=void 0}#v(e){return this.#r.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[r,i,o,n]=t.toRegExpSource(e);return this.#t=this.#t||n,r}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#h(e,t,r=!1){let i=!1,o="",n=!1,a=!1;for(let c=0;c<e.length;c++){let l=e.charAt(c);if(i){i=!1,o+=(uO.has(l)?"\\":"")+l;continue}if(l==="*"){if(a)continue;a=!0,o+=r&&/^[*]+$/.test(e)?ww:kw,t=!0;continue}else a=!1;if(l==="\\"){c===e.length-1?o+="\\\\":i=!0;continue}if(l==="["){let[d,p,u,m]=xw(e,c);if(u){o+=d,n=n||p,c+=u-1,t=t||m;continue}}if(l==="?"){o+=bf,t=!0;continue}o+=fO(l)}return[o,Pt(e),!!t,n]}};Ue=hr;var xi=(s,{windowsPathsNoEscape:e=!1,magicalBraces:t=!1}={})=>t?e?s.replace(/[?*()[\]{}]/g,"[$&]"):s.replace(/[?*()[\]\\{}]/g,"\\$&"):e?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&");var Oe=(s,e,t={})=>(Xo(e),!t.nocomment&&e.charAt(0)==="#"?!1:new Qe(e,t).match(s)),hO=/^\*+([^+@!?*[(]*)$/,gO=s=>e=>!e.startsWith(".")&&e.endsWith(s),bO=s=>e=>e.endsWith(s),xO=s=>(s=s.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(s)),yO=s=>(s=s.toLowerCase(),e=>e.toLowerCase().endsWith(s)),_O=/^\*+\.\*+$/,kO=s=>!s.startsWith(".")&&s.includes("."),wO=s=>s!=="."&&s!==".."&&s.includes("."),vO=/^\.\*+$/,SO=s=>s!=="."&&s!==".."&&s.startsWith("."),EO=/^\*+$/,TO=s=>s.length!==0&&!s.startsWith("."),$O=s=>s.length!==0&&s!=="."&&s!=="..",RO=/^\?+([^+@!?*[(]*)?$/,AO=([s,e=""])=>{let t=Ew([s]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},PO=([s,e=""])=>{let t=Tw([s]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},CO=([s,e=""])=>{let t=Tw([s]);return e?r=>t(r)&&r.endsWith(e):t},qO=([s,e=""])=>{let t=Ew([s]);return e?r=>t(r)&&r.endsWith(e):t},Ew=([s])=>{let e=s.length;return t=>t.length===e&&!t.startsWith(".")},Tw=([s])=>{let e=s.length;return t=>t.length===e&&t!=="."&&t!==".."},$w=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",vw={win32:{sep:"\\"},posix:{sep:"/"}},NO=$w==="win32"?vw.win32.sep:vw.posix.sep;Oe.sep=NO;var oe=Symbol("globstar **");Oe.GLOBSTAR=oe;var OO="[^/]",IO=OO+"*?",jO="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",DO="(?:(?!(?:\\/|^)\\.).)*?",LO=(s,e={})=>t=>Oe(t,s,e);Oe.filter=LO;var pt=(s,e={})=>Object.assign({},s,e),FO=s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return Oe;let e=Oe;return Object.assign((r,i,o={})=>e(r,i,pt(s,o)),{Minimatch:class extends e.Minimatch{constructor(i,o={}){super(i,pt(s,o))}static defaults(i){return e.defaults(pt(s,i)).Minimatch}},AST:class extends e.AST{constructor(i,o,n={}){super(i,o,pt(s,n))}static fromGlob(i,o={}){return e.AST.fromGlob(i,pt(s,o))}},unescape:(r,i={})=>e.unescape(r,pt(s,i)),escape:(r,i={})=>e.escape(r,pt(s,i)),filter:(r,i={})=>e.filter(r,pt(s,i)),defaults:r=>e.defaults(pt(s,r)),makeRe:(r,i={})=>e.makeRe(r,pt(s,i)),braceExpand:(r,i={})=>e.braceExpand(r,pt(s,i)),match:(r,i,o={})=>e.match(r,i,pt(s,o)),sep:e.sep,GLOBSTAR:oe})};Oe.defaults=FO;var Rw=(s,e={})=>(Xo(s),e.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:gw(s,{max:e.braceExpandMax}));Oe.braceExpand=Rw;var WO=(s,e={})=>new Qe(s,e).makeRe();Oe.makeRe=WO;var BO=(s,e,t={})=>{let r=new Qe(e,t);return s=s.filter(i=>r.match(i)),r.options.nonull&&!s.length&&s.push(e),s};Oe.match=BO;var Sw=/[?*]|[+@!]\(.*?\)|\[|\]/,MO=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Qe=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){Xo(e),t=t||{},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||$w,this.isWindows=this.platform==="win32";let r="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[r]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let r=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,n,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=o[0]===""&&o[1]===""&&(o[2]==="?"||!Sw.test(o[2]))&&!Sw.test(o[3]),l=/^[a-z]:/i.test(o[0]);if(c)return[...o.slice(0,4),...o.slice(4).map(d=>this.parse(d))];if(l)return[o[0],...o.slice(1).map(d=>this.parse(d))]}return o.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let n=this.set[o];n[0]===""&&n[1]===""&&this.globParts[o][2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3])&&(n[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let r of e)for(let i=0;i<r.length;i++)r[i]==="**"&&(r[i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let r=-1;for(;(r=t.indexOf("**",r+1))!==-1;){let i=r;for(;t[i+1]==="**";)i++;i!==r&&t.splice(r,i-r)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((r,i)=>{let o=r[r.length-1];return i==="**"&&o==="**"?r:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(r.pop(),r):(r.push(i),r)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let o=e[i];i===1&&o===""&&e[0]===""||(o==="."||o==="")&&(t=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=!0,e.pop())}let r=0;for(;(r=e.indexOf("..",r+1))!==-1;){let i=e[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(t=!0,e.splice(r-1,2),r-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let r of e){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let n=i;for(;r[n+1]==="**";)n++;n>i&&r.splice(i+1,n-i);let a=r[i+1],c=r[i+2],l=r[i+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;t=!0,r.splice(i,1);let d=r.slice(0);d[i]="**",e.push(d),i--}if(!this.preserveMultipleSlashes){for(let n=1;n<r.length-1;n++){let a=r[n];n===1&&a===""&&r[0]===""||(a==="."||a==="")&&(t=!0,r.splice(n,1),n--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(t=!0,r.pop())}let o=0;for(;(o=r.indexOf("..",o+1))!==-1;){let n=r[o-1];if(n&&n!=="."&&n!==".."&&n!=="**"){t=!0;let c=o===1&&r[o+1]==="**"?["."]:[];r.splice(o-1,2,...c),r.length===0&&r.push(""),o-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let r=t+1;r<e.length;r++){let i=this.partsMatch(e[t],e[r],!this.preserveMultipleSlashes);if(i){e[t]=[],e[r]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,r=!1){let i=0,o=0,n=[],a="";for(;i<e.length&&o<t.length;)if(e[i]===t[o])n.push(a==="b"?t[o]:e[i]),i++,o++;else if(r&&e[i]==="**"&&t[o]===e[i+1])n.push(e[i]),i++;else if(r&&t[o]==="**"&&e[i]===t[o+1])n.push(t[o]),o++;else if(e[i]==="*"&&t[o]&&(this.options.dot||!t[o].startsWith("."))&&t[o]!=="**"){if(a==="b")return!1;a="a",n.push(e[i]),i++,o++}else if(t[o]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",n.push(t[o]),i++,o++}else return!1;return e.length===t.length&&n}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,r=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,r++;r&&(this.pattern=e.slice(r)),this.negate=t}matchOne(e,t,r=!1){let i=0,o=0;if(this.isWindows){let a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),c=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),l=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),d=!l&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),p=c?3:a?0:void 0,u=d?3:l?0:void 0;if(typeof p=="number"&&typeof u=="number"){let[m,h]=[e[p],t[u]];m.toLowerCase()===h.toLowerCase()&&(t[u]=m,o=u,i=p)}}let{optimizationLevel:n=1}=this.options;return n>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(oe)?this.#e(e,t,r,i,o):this.#t(e,t,r,i,o)}#e(e,t,r,i,o){let n=t.indexOf(oe,o),a=t.lastIndexOf(oe),[c,l,d]=r?[t.slice(o,n),t.slice(n+1),[]]:[t.slice(o,n),t.slice(n+1,a),t.slice(a+1)];if(c.length){let x=e.slice(i,i+c.length);if(!this.#t(x,c,r,0,0))return!1;i+=c.length,o+=c.length}let p=0;if(d.length){if(d.length+i>e.length)return!1;let x=e.length-d.length;if(this.#t(e,d,r,x,0))p=d.length;else{if(e[e.length-1]!==""||i+d.length===e.length||(x--,!this.#t(e,d,r,x,0)))return!1;p=d.length+1}}if(!l.length){let x=!!p;for(let y=i;y<e.length-p;y++){let _=String(e[y]);if(x=!0,_==="."||_===".."||!this.options.dot&&_.startsWith("."))return!1}return r||x}let u=[[[],0]],m=u[0],h=0,f=[0];for(let x of l)x===oe?(f.push(h),m=[[],0],u.push(m)):(m[0].push(x),h++);let g=u.length-1,b=e.length-p;for(let x of u)x[1]=b-(f[g--]+x[0].length);return!!this.#s(e,u,i,0,r,0,!!p)}#s(e,t,r,i,o,n,a){let c=t[i];if(!c){for(let p=r;p<e.length;p++){a=!0;let u=e[p];if(u==="."||u===".."||!this.options.dot&&u.startsWith("."))return!1}return a}let[l,d]=c;for(;r<=d;){if(this.#t(e.slice(0,r+l.length),l,o,r,0)&&n<this.maxGlobstarRecursion){let m=this.#s(e,t,r+l.length,i+1,o,n+1,a);if(m!==!1)return m}let u=e[r];if(u==="."||u===".."||!this.options.dot&&u.startsWith("."))return!1;r++}return o||null}#t(e,t,r,i,o){let n,a,c,l;for(n=i,a=o,l=e.length,c=t.length;n<l&&a<c;n++,a++){this.debug("matchOne loop");let d=t[a],p=e[n];if(this.debug(t,d,p),d===!1||d===oe)return!1;let u;if(typeof d=="string"?(u=p===d,this.debug("string match",d,p,u)):(u=d.test(p),this.debug("pattern match",d,p,u)),!u)return!1}if(n===l&&a===c)return!0;if(n===l)return r;if(a===c)return n===l-1&&e[n]==="";throw new Error("wtf?")}braceExpand(){return Rw(this.pattern,this.options)}parse(e){Xo(e);let t=this.options;if(e==="**")return oe;if(e==="")return"";let r,i=null;(r=e.match(EO))?i=t.dot?$O:TO:(r=e.match(hO))?i=(t.nocase?t.dot?yO:xO:t.dot?bO:gO)(r[1]):(r=e.match(RO))?i=(t.nocase?t.dot?PO:AO:t.dot?CO:qO)(r):(r=e.match(_O))?i=t.dot?wO:kO:(r=e.match(vO))&&(i=SO);let o=hr.fromGlob(e,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,r=t.noglobstar?IO:t.dot?jO:DO,i=new Set(t.nocase?["i"]:[]),o=e.map(c=>{let l=c.map(p=>{if(p instanceof RegExp)for(let u of p.flags.split(""))i.add(u);return typeof p=="string"?MO(p):p===oe?oe:p._src});l.forEach((p,u)=>{let m=l[u+1],h=l[u-1];p!==oe||h===oe||(h===void 0?m!==void 0&&m!==oe?l[u+1]="(?:\\/|"+r+"\\/)?"+m:l[u]=r:m===void 0?l[u-1]=h+"(?:\\/|\\/"+r+")?":m!==oe&&(l[u-1]=h+"(?:\\/|\\/"+r+"\\/)"+m,l[u+1]=oe))});let d=l.filter(p=>p!==oe);if(this.partial&&d.length>=1){let p=[];for(let u=1;u<=d.length;u++)p.push(d.slice(0,u).join("/"));return"(?:"+p.join("|")+")"}return d.join("/")}).join("|"),[n,a]=e.length>1?["(?:",")"]:["",""];o="^"+n+o+a+"$",this.partial&&(o="^(?:\\/|"+n+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let r=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let n=i[i.length-1];if(!n)for(let a=i.length-2;!n&&a>=0;a--)n=i[a];for(let a of o){let c=i;if(r.matchBase&&a.length===1&&(c=[n]),this.matchOne(c,a,t))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(e){return Oe.defaults(e).Minimatch}};Oe.AST=hr;Oe.Minimatch=Qe;Oe.escape=xi;Oe.unescape=Pt;var Xw=require("node:url");var yi=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Pw=new Set,xf=typeof process=="object"&&process?process:{},Cw=(s,e,t,r)=>{typeof xf.emitWarning=="function"?xf.emitWarning(s,e,t,r):console.error(`[${t}] ${e}: ${s}`)},Nc=globalThis.AbortController,Aw=globalThis.AbortSignal;if(typeof Nc>"u"){Aw=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(r,i){this._onabort.push(i)}},Nc=class{constructor(){e()}signal=new Aw;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let i of this.signal._onabort)i(r);this.signal.onabort?.(r)}}};let s=xf.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{s&&(s=!1,Cw("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var UO=s=>!Pw.has(s);var js=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),qw=s=>js(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?_i:null:null,_i=class extends Array{constructor(e){super(e),this.fill(0)}},yf=class s{heap;length;static#e=!1;static create(e){let t=qw(e);if(!t)return[];s.#e=!0;let r=new s(e,t);return s.#e=!1,r}constructor(e,t){if(!s.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},gr=class s{#e;#s;#t;#r;#i;#g;#u;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#p;#c;#l;#o;#x;#w;#y;#f;#S;#m;#E;#k;#_;#b;#v;#h;#P;static unsafeExposeInternals(e){return{starts:e.#k,ttls:e.#_,sizes:e.#E,keyMap:e.#c,keyList:e.#l,valList:e.#o,next:e.#x,prev:e.#w,get head(){return e.#y},get tail(){return e.#f},free:e.#S,isBackgroundFetch:t=>e.#d(t),backgroundFetch:(t,r,i,o)=>e.#I(t,r,i,o),moveToTail:t=>e.#L(t),indexes:t=>e.#R(t),rindexes:t=>e.#A(t),isStale:t=>e.#$(t)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#p}get size(){return this.#a}get fetchMethod(){return this.#g}get memoMethod(){return this.#u}get dispose(){return this.#t}get onInsert(){return this.#r}get disposeAfter(){return this.#i}constructor(e){let{max:t=0,ttl:r,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:c,dispose:l,onInsert:d,disposeAfter:p,noDisposeOnSet:u,noUpdateTTL:m,maxSize:h=0,maxEntrySize:f=0,sizeCalculation:g,fetchMethod:b,memoMethod:x,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:_,allowStaleOnFetchRejection:k,allowStaleOnFetchAbort:S,ignoreFetchAbort:T}=e;if(t!==0&&!js(t))throw new TypeError("max option must be a nonnegative integer");let E=t?qw(t):Array;if(!E)throw new Error("invalid max value: "+t);if(this.#e=t,this.#s=h,this.maxEntrySize=f||this.#s,this.sizeCalculation=g,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#u=x,b!==void 0&&typeof b!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#g=b,this.#v=!!b,this.#c=new Map,this.#l=new Array(t).fill(void 0),this.#o=new Array(t).fill(void 0),this.#x=new E(t),this.#w=new E(t),this.#y=0,this.#f=0,this.#S=yf.create(t),this.#a=0,this.#p=0,typeof l=="function"&&(this.#t=l),typeof d=="function"&&(this.#r=d),typeof p=="function"?(this.#i=p,this.#m=[]):(this.#i=void 0,this.#m=void 0),this.#b=!!this.#t,this.#P=!!this.#r,this.#h=!!this.#i,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!k,this.allowStaleOnFetchAbort=!!S,this.ignoreFetchAbort=!!T,this.maxEntrySize!==0){if(this.#s!==0&&!js(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!js(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#W()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!_,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=js(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!js(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#n()}if(this.#e===0&&this.ttl===0&&this.#s===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#s){let v="LRU_CACHE_UNBOUNDED";UO(v)&&(Pw.add(v),Cw("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",v,s))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#n(){let e=new _i(this.#e),t=new _i(this.#e);this.#_=e,this.#k=t,this.#C=(o,n,a=yi.now())=>{if(t[o]=n!==0?a:0,e[o]=n,n!==0&&this.ttlAutopurge){let c=setTimeout(()=>{this.#$(o)&&this.#q(this.#l[o],"expire")},n+1);c.unref&&c.unref()}},this.#N=o=>{t[o]=e[o]!==0?yi.now():0},this.#T=(o,n)=>{if(e[n]){let a=e[n],c=t[n];if(!a||!c)return;o.ttl=a,o.start=c,o.now=r||i();let l=o.now-c;o.remainingTTL=a-l}};let r=0,i=()=>{let o=yi.now();if(this.ttlResolution>0){r=o;let n=setTimeout(()=>r=0,this.ttlResolution);n.unref&&n.unref()}return o};this.getRemainingTTL=o=>{let n=this.#c.get(o);if(n===void 0)return 0;let a=e[n],c=t[n];if(!a||!c)return 1/0;let l=(r||i())-c;return a-l},this.#$=o=>{let n=t[o],a=e[o];return!!a&&!!n&&(r||i())-n>a}}#N=()=>{};#T=()=>{};#C=()=>{};#$=()=>!1;#W(){let e=new _i(this.#e);this.#p=0,this.#E=e,this.#O=t=>{this.#p-=e[t],e[t]=0},this.#B=(t,r,i,o)=>{if(this.#d(r))return 0;if(!js(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(r,t),!js(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#j=(t,r,i)=>{if(e[t]=r,this.#s){let o=this.#s-e[t];for(;this.#p>o;)this.#D(!0)}this.#p+=e[t],i&&(i.entrySize=r,i.totalCalculatedSize=this.#p)}}#O=e=>{};#j=(e,t,r)=>{};#B=(e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#R({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#f;!(!this.#M(t)||((e||!this.#$(t))&&(yield t),t===this.#y));)t=this.#w[t]}*#A({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#y;!(!this.#M(t)||((e||!this.#$(t))&&(yield t),t===this.#f));)t=this.#x[t]}#M(e){return e!==void 0&&this.#c.get(this.#l[e])===e}*entries(){for(let e of this.#R())this.#o[e]!==void 0&&this.#l[e]!==void 0&&!this.#d(this.#o[e])&&(yield[this.#l[e],this.#o[e]])}*rentries(){for(let e of this.#A())this.#o[e]!==void 0&&this.#l[e]!==void 0&&!this.#d(this.#o[e])&&(yield[this.#l[e],this.#o[e]])}*keys(){for(let e of this.#R()){let t=this.#l[e];t!==void 0&&!this.#d(this.#o[e])&&(yield t)}}*rkeys(){for(let e of this.#A()){let t=this.#l[e];t!==void 0&&!this.#d(this.#o[e])&&(yield t)}}*values(){for(let e of this.#R())this.#o[e]!==void 0&&!this.#d(this.#o[e])&&(yield this.#o[e])}*rvalues(){for(let e of this.#A())this.#o[e]!==void 0&&!this.#d(this.#o[e])&&(yield this.#o[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#R()){let i=this.#o[r],o=this.#d(i)?i.__staleWhileFetching:i;if(o!==void 0&&e(o,this.#l[r],this))return this.get(this.#l[r],t)}}forEach(e,t=this){for(let r of this.#R()){let i=this.#o[r],o=this.#d(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(t,o,this.#l[r],this)}}rforEach(e,t=this){for(let r of this.#A()){let i=this.#o[r],o=this.#d(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(t,o,this.#l[r],this)}}purgeStale(){let e=!1;for(let t of this.#A({allowStale:!0}))this.#$(t)&&(this.#q(this.#l[t],"expire"),e=!0);return e}info(e){let t=this.#c.get(e);if(t===void 0)return;let r=this.#o[t],i=this.#d(r)?r.__staleWhileFetching:r;if(i===void 0)return;let o={value:i};if(this.#_&&this.#k){let n=this.#_[t],a=this.#k[t];if(n&&a){let c=n-(yi.now()-a);o.ttl=c,o.start=Date.now()}}return this.#E&&(o.size=this.#E[t]),o}dump(){let e=[];for(let t of this.#R({allowStale:!0})){let r=this.#l[t],i=this.#o[t],o=this.#d(i)?i.__staleWhileFetching:i;if(o===void 0||r===void 0)continue;let n={value:o};if(this.#_&&this.#k){n.ttl=this.#_[t];let a=yi.now()-this.#k[t];n.start=Math.floor(Date.now()-a)}this.#E&&(n.size=this.#E[t]),e.unshift([r,n])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let i=Date.now()-r.start;r.start=yi.now()-i}this.set(t,r.value,r)}}set(e,t,r={}){if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=r,{noUpdateTTL:l=this.noUpdateTTL}=r,d=this.#B(e,t,r.size||0,a);if(this.maxEntrySize&&d>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#q(e,"set"),this;let p=this.#a===0?void 0:this.#c.get(e);if(p===void 0)p=this.#a===0?this.#f:this.#S.length!==0?this.#S.pop():this.#a===this.#e?this.#D(!1):this.#a,this.#l[p]=e,this.#o[p]=t,this.#c.set(e,p),this.#x[this.#f]=p,this.#w[p]=this.#f,this.#f=p,this.#a++,this.#j(p,d,c),c&&(c.set="add"),l=!1,this.#P&&this.#r?.(t,e,"add");else{this.#L(p);let u=this.#o[p];if(t!==u){if(this.#v&&this.#d(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=u;m!==void 0&&!n&&(this.#b&&this.#t?.(m,e,"set"),this.#h&&this.#m?.push([m,e,"set"]))}else n||(this.#b&&this.#t?.(u,e,"set"),this.#h&&this.#m?.push([u,e,"set"]));if(this.#O(p),this.#j(p,d,c),this.#o[p]=t,c){c.set="replace";let m=u&&this.#d(u)?u.__staleWhileFetching:u;m!==void 0&&(c.oldValue=m)}}else c&&(c.set="update");this.#P&&this.onInsert?.(t,e,t===u?"update":"replace")}if(i!==0&&!this.#_&&this.#n(),this.#_&&(l||this.#C(p,i,o),c&&this.#T(c,p)),!n&&this.#h&&this.#m){let u=this.#m,m;for(;m=u?.shift();)this.#i?.(...m)}return this}pop(){try{for(;this.#a;){let e=this.#o[this.#y];if(this.#D(!0),this.#d(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#h&&this.#m){let e=this.#m,t;for(;t=e?.shift();)this.#i?.(...t)}}}#D(e){let t=this.#y,r=this.#l[t],i=this.#o[t];return this.#v&&this.#d(i)?i.__abortController.abort(new Error("evicted")):(this.#b||this.#h)&&(this.#b&&this.#t?.(i,r,"evict"),this.#h&&this.#m?.push([i,r,"evict"])),this.#O(t),e&&(this.#l[t]=void 0,this.#o[t]=void 0,this.#S.push(t)),this.#a===1?(this.#y=this.#f=0,this.#S.length=0):this.#y=this.#x[t],this.#c.delete(r),this.#a--,t}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=t,o=this.#c.get(e);if(o!==void 0){let n=this.#o[o];if(this.#d(n)&&n.__staleWhileFetching===void 0)return!1;if(this.#$(o))i&&(i.has="stale",this.#T(i,o));else return r&&this.#N(o),i&&(i.has="hit",this.#T(i,o)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){let{allowStale:r=this.allowStale}=t,i=this.#c.get(e);if(i===void 0||!r&&this.#$(i))return;let o=this.#o[i];return this.#d(o)?o.__staleWhileFetching:o}#I(e,t,r,i){let o=t===void 0?void 0:this.#o[t];if(this.#d(o))return o;let n=new Nc,{signal:a}=r;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let c={signal:n.signal,options:r,context:i},l=(f,g=!1)=>{let{aborted:b}=n.signal,x=r.ignoreFetchAbort&&f!==void 0;if(r.status&&(b&&!g?(r.status.fetchAborted=!0,r.status.fetchError=n.signal.reason,x&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),b&&!x&&!g)return p(n.signal.reason);let y=m;return this.#o[t]===m&&(f===void 0?y.__staleWhileFetching?this.#o[t]=y.__staleWhileFetching:this.#q(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,f,c.options))),f},d=f=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=f),p(f)),p=f=>{let{aborted:g}=n.signal,b=g&&r.allowStaleOnFetchAbort,x=b||r.allowStaleOnFetchRejection,y=x||r.noDeleteOnFetchRejection,_=m;if(this.#o[t]===m&&(!y||_.__staleWhileFetching===void 0?this.#q(e,"fetch"):b||(this.#o[t]=_.__staleWhileFetching)),x)return r.status&&_.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),_.__staleWhileFetching;if(_.__returned===_)throw f},u=(f,g)=>{let b=this.#g?.(e,o,c);b&&b instanceof Promise&&b.then(x=>f(x===void 0?void 0:x),g),n.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(f(void 0),r.allowStaleOnFetchAbort&&(f=x=>l(x,!0)))})};r.status&&(r.status.fetchDispatched=!0);let m=new Promise(u).then(l,d),h=Object.assign(m,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return t===void 0?(this.set(e,h,{...c.options,status:void 0}),t=this.#c.get(e)):this.#o[t]=h,h}#d(e){if(!this.#v)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Nc}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:f,forceRefresh:g=!1,status:b,signal:x}=t;if(!this.#v)return b&&(b.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:b});let y={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:c,sizeCalculation:l,noUpdateTTL:d,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:h,ignoreFetchAbort:m,status:b,signal:x},_=this.#c.get(e);if(_===void 0){b&&(b.fetch="miss");let k=this.#I(e,_,y,f);return k.__returned=k}else{let k=this.#o[_];if(this.#d(k)){let P=r&&k.__staleWhileFetching!==void 0;return b&&(b.fetch="inflight",P&&(b.returnedStale=!0)),P?k.__staleWhileFetching:k.__returned=k}let S=this.#$(_);if(!g&&!S)return b&&(b.fetch="hit"),this.#L(_),i&&this.#N(_),b&&this.#T(b,_),k;let T=this.#I(e,_,y,f),v=T.__staleWhileFetching!==void 0&&r;return b&&(b.fetch=S?"stale":"refresh",v&&S&&(b.returnedStale=!0)),v?T.__staleWhileFetching:T.__returned=T}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let r=this.#u;if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:o,...n}=t,a=this.get(e,n);if(!o&&a!==void 0)return a;let c=r(e,a,{options:n,context:i});return this.set(e,c,n),c}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=t,a=this.#c.get(e);if(a!==void 0){let c=this.#o[a],l=this.#d(c);return n&&this.#T(n,a),this.#$(a)?(n&&(n.get="stale"),l?(n&&r&&c.__staleWhileFetching!==void 0&&(n.returnedStale=!0),r?c.__staleWhileFetching:void 0):(o||this.#q(e,"expire"),n&&r&&(n.returnedStale=!0),r?c:void 0)):(n&&(n.get="hit"),l?c.__staleWhileFetching:(this.#L(a),i&&this.#N(a),c))}else n&&(n.get="miss")}#U(e,t){this.#w[t]=e,this.#x[e]=t}#L(e){e!==this.#f&&(e===this.#y?this.#y=this.#x[e]:this.#U(this.#w[e],this.#x[e]),this.#U(this.#f,e),this.#f=e)}delete(e){return this.#q(e,"delete")}#q(e,t){let r=!1;if(this.#a!==0){let i=this.#c.get(e);if(i!==void 0)if(r=!0,this.#a===1)this.#F(t);else{this.#O(i);let o=this.#o[i];if(this.#d(o)?o.__abortController.abort(new Error("deleted")):(this.#b||this.#h)&&(this.#b&&this.#t?.(o,e,t),this.#h&&this.#m?.push([o,e,t])),this.#c.delete(e),this.#l[i]=void 0,this.#o[i]=void 0,i===this.#f)this.#f=this.#w[i];else if(i===this.#y)this.#y=this.#x[i];else{let n=this.#w[i];this.#x[n]=this.#x[i];let a=this.#x[i];this.#w[a]=this.#w[i]}this.#a--,this.#S.push(i)}}if(this.#h&&this.#m?.length){let i=this.#m,o;for(;o=i?.shift();)this.#i?.(...o)}return r}clear(){return this.#F("delete")}#F(e){for(let t of this.#A({allowStale:!0})){let r=this.#o[t];if(this.#d(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#l[t];this.#b&&this.#t?.(r,i,e),this.#h&&this.#m?.push([r,i,e])}}if(this.#c.clear(),this.#o.fill(void 0),this.#l.fill(void 0),this.#_&&this.#k&&(this.#_.fill(0),this.#k.fill(0)),this.#E&&this.#E.fill(0),this.#y=0,this.#f=0,this.#S.length=0,this.#p=0,this.#a=0,this.#h&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#i?.(...r)}}};var vi=require("node:path"),Mw=require("node:url"),Vt=require("fs"),ZO=O(require("node:fs"),1),Fs=require("node:fs/promises");var Wc=require("node:events"),Tf=O(require("node:stream"),1),Dw=require("node:string_decoder"),Nw=typeof process=="object"&&process?process:{stdout:null,stderr:null},GO=s=>!!s&&typeof s=="object"&&(s instanceof Ls||s instanceof Tf.default||zO(s)||VO(s)),zO=s=>!!s&&typeof s=="object"&&s instanceof Wc.EventEmitter&&typeof s.pipe=="function"&&s.pipe!==Tf.default.Writable.prototype.pipe,VO=s=>!!s&&typeof s=="object"&&s instanceof Wc.EventEmitter&&typeof s.write=="function"&&typeof s.end=="function",as=Symbol("EOF"),cs=Symbol("maybeEmitEnd"),Ds=Symbol("emittedEnd"),Oc=Symbol("emittingEnd"),en=Symbol("emittedError"),Ic=Symbol("closed"),Ow=Symbol("read"),jc=Symbol("flush"),Iw=Symbol("flushChunk"),Ct=Symbol("encoding"),ki=Symbol("decoder"),_e=Symbol("flowing"),tn=Symbol("paused"),wi=Symbol("resume"),ke=Symbol("buffer"),Ie=Symbol("pipes"),we=Symbol("bufferLength"),_f=Symbol("bufferPush"),Dc=Symbol("bufferShift"),Re=Symbol("objectMode"),ne=Symbol("destroyed"),kf=Symbol("error"),wf=Symbol("emitData"),jw=Symbol("emitEnd"),vf=Symbol("emitEnd2"),Gt=Symbol("async"),Sf=Symbol("abort"),Lc=Symbol("aborted"),sn=Symbol("signal"),br=Symbol("dataListeners"),Xe=Symbol("discarded"),rn=s=>Promise.resolve().then(s),HO=s=>s(),KO=s=>s==="end"||s==="finish"||s==="prefinish",JO=s=>s instanceof ArrayBuffer||!!s&&typeof s=="object"&&s.constructor&&s.constructor.name==="ArrayBuffer"&&s.byteLength>=0,YO=s=>!Buffer.isBuffer(s)&&ArrayBuffer.isView(s),Fc=class{src;dest;opts;ondrain;constructor(e,t,r){this.src=e,this.dest=t,this.opts=r,this.ondrain=()=>e[wi](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ef=class extends Fc{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,r){super(e,t,r),this.proxyErrors=i=>this.dest.emit("error",i),e.on("error",this.proxyErrors)}},QO=s=>!!s.objectMode,XO=s=>!s.objectMode&&!!s.encoding&&s.encoding!=="buffer",Ls=class extends Wc.EventEmitter{[_e]=!1;[tn]=!1;[Ie]=[];[ke]=[];[Re];[Ct];[Gt];[ki];[as]=!1;[Ds]=!1;[Oc]=!1;[Ic]=!1;[en]=null;[we]=0;[ne]=!1;[sn];[Lc]=!1;[br]=0;[Xe]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");QO(t)?(this[Re]=!0,this[Ct]=null):XO(t)?(this[Ct]=t.encoding,this[Re]=!1):(this[Re]=!1,this[Ct]=null),this[Gt]=!!t.async,this[ki]=this[Ct]?new Dw.StringDecoder(this[Ct]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ke]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ie]});let{signal:r}=t;r&&(this[sn]=r,r.aborted?this[Sf]():r.addEventListener("abort",()=>this[Sf]()))}get bufferLength(){return this[we]}get encoding(){return this[Ct]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Re]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Gt]}set async(e){this[Gt]=this[Gt]||!!e}[Sf](){this[Lc]=!0,this.emit("abort",this[sn]?.reason),this.destroy(this[sn]?.reason)}get aborted(){return this[Lc]}set aborted(e){}write(e,t,r){if(this[Lc])return!1;if(this[as])throw new Error("write after end");if(this[ne])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(r=t,t="utf8"),t||(t="utf8");let i=this[Gt]?rn:HO;if(!this[Re]&&!Buffer.isBuffer(e)){if(YO(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(JO(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Re]?(this[_e]&&this[we]!==0&&this[jc](!0),this[_e]?this.emit("data",e):this[_f](e),this[we]!==0&&this.emit("readable"),r&&i(r),this[_e]):e.length?(typeof e=="string"&&!(t===this[Ct]&&!this[ki]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Ct]&&(e=this[ki].write(e)),this[_e]&&this[we]!==0&&this[jc](!0),this[_e]?this.emit("data",e):this[_f](e),this[we]!==0&&this.emit("readable"),r&&i(r),this[_e]):(this[we]!==0&&this.emit("readable"),r&&i(r),this[_e])}read(e){if(this[ne])return null;if(this[Xe]=!1,this[we]===0||e===0||e&&e>this[we])return this[cs](),null;this[Re]&&(e=null),this[ke].length>1&&!this[Re]&&(this[ke]=[this[Ct]?this[ke].join(""):Buffer.concat(this[ke],this[we])]);let t=this[Ow](e||null,this[ke][0]);return this[cs](),t}[Ow](e,t){if(this[Re])this[Dc]();else{let r=t;e===r.length||e===null?this[Dc]():typeof r=="string"?(this[ke][0]=r.slice(e),t=r.slice(0,e),this[we]-=e):(this[ke][0]=r.subarray(e),t=r.subarray(0,e),this[we]-=e)}return this.emit("data",t),!this[ke].length&&!this[as]&&this.emit("drain"),t}end(e,t,r){return typeof e=="function"&&(r=e,e=void 0),typeof t=="function"&&(r=t,t="utf8"),e!==void 0&&this.write(e,t),r&&this.once("end",r),this[as]=!0,this.writable=!1,(this[_e]||!this[tn])&&this[cs](),this}[wi](){this[ne]||(!this[br]&&!this[Ie].length&&(this[Xe]=!0),this[tn]=!1,this[_e]=!0,this.emit("resume"),this[ke].length?this[jc]():this[as]?this[cs]():this.emit("drain"))}resume(){return this[wi]()}pause(){this[_e]=!1,this[tn]=!0,this[Xe]=!1}get destroyed(){return this[ne]}get flowing(){return this[_e]}get paused(){return this[tn]}[_f](e){this[Re]?this[we]+=1:this[we]+=e.length,this[ke].push(e)}[Dc](){return this[Re]?this[we]-=1:this[we]-=this[ke][0].length,this[ke].shift()}[jc](e=!1){do;while(this[Iw](this[Dc]())&&this[ke].length);!e&&!this[ke].length&&!this[as]&&this.emit("drain")}[Iw](e){return this.emit("data",e),this[_e]}pipe(e,t){if(this[ne])return e;this[Xe]=!1;let r=this[Ds];return t=t||{},e===Nw.stdout||e===Nw.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,r?t.end&&e.end():(this[Ie].push(t.proxyErrors?new Ef(this,e,t):new Fc(this,e,t)),this[Gt]?rn(()=>this[wi]()):this[wi]()),e}unpipe(e){let t=this[Ie].find(r=>r.dest===e);t&&(this[Ie].length===1?(this[_e]&&this[br]===0&&(this[_e]=!1),this[Ie]=[]):this[Ie].splice(this[Ie].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let r=super.on(e,t);if(e==="data")this[Xe]=!1,this[br]++,!this[Ie].length&&!this[_e]&&this[wi]();else if(e==="readable"&&this[we]!==0)super.emit("readable");else if(KO(e)&&this[Ds])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[en]){let i=t;this[Gt]?rn(()=>i.call(this,this[en])):i.call(this,this[en])}return r}removeListener(e,t){return this.off(e,t)}off(e,t){let r=super.off(e,t);return e==="data"&&(this[br]=this.listeners("data").length,this[br]===0&&!this[Xe]&&!this[Ie].length&&(this[_e]=!1)),r}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[br]=0,!this[Xe]&&!this[Ie].length&&(this[_e]=!1)),t}get emittedEnd(){return this[Ds]}[cs](){!this[Oc]&&!this[Ds]&&!this[ne]&&this[ke].length===0&&this[as]&&(this[Oc]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ic]&&this.emit("close"),this[Oc]=!1)}emit(e,...t){let r=t[0];if(e!=="error"&&e!=="close"&&e!==ne&&this[ne])return!1;if(e==="data")return!this[Re]&&!r?!1:this[Gt]?(rn(()=>this[wf](r)),!0):this[wf](r);if(e==="end")return this[jw]();if(e==="close"){if(this[Ic]=!0,!this[Ds]&&!this[ne])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(e==="error"){this[en]=r,super.emit(kf,r);let o=!this[sn]||this.listeners("error").length?super.emit("error",r):!1;return this[cs](),o}else if(e==="resume"){let o=super.emit("resume");return this[cs](),o}else if(e==="finish"||e==="prefinish"){let o=super.emit(e);return this.removeAllListeners(e),o}let i=super.emit(e,...t);return this[cs](),i}[wf](e){for(let r of this[Ie])r.dest.write(e)===!1&&this.pause();let t=this[Xe]?!1:super.emit("data",e);return this[cs](),t}[jw](){return this[Ds]?!1:(this[Ds]=!0,this.readable=!1,this[Gt]?(rn(()=>this[vf]()),!0):this[vf]())}[vf](){if(this[ki]){let t=this[ki].end();if(t){for(let r of this[Ie])r.dest.write(t);this[Xe]||super.emit("data",t)}}for(let t of this[Ie])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[Re]||(e.dataLength=0);let t=this.promise();return this.on("data",r=>{e.push(r),this[Re]||(e.dataLength+=r.length)}),await t,e}async concat(){if(this[Re])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Ct]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(ne,()=>t(new Error("stream destroyed"))),this.on("error",r=>t(r)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Xe]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[as])return t();let o,n,a=p=>{this.off("data",c),this.off("end",l),this.off(ne,d),t(),n(p)},c=p=>{this.off("error",a),this.off("end",l),this.off(ne,d),this.pause(),o({value:p,done:!!this[as]})},l=()=>{this.off("error",a),this.off("data",c),this.off(ne,d),t(),o({done:!0,value:void 0})},d=()=>a(new Error("stream destroyed"));return new Promise((p,u)=>{n=u,o=p,this.once(ne,d),this.once("error",a),this.once("end",l),this.once("data",c)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Xe]=!1;let e=!1,t=()=>(this.pause(),this.off(kf,t),this.off(ne,t),this.off("end",t),e=!0,{done:!0,value:void 0}),r=()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}};return this.once("end",t),this.once(kf,t),this.once(ne,t),{next:r,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[ne])return e?this.emit("error",e):this.emit(ne),this;this[ne]=!0,this[Xe]=!0,this[ke].length=0,this[we]=0;let t=this;return typeof t.close=="function"&&!this[Ic]&&t.close(),e?this.emit("error",e):this.emit(ne),this}static get isStream(){return GO}};var eI=Vt.realpathSync.native,nn={lstatSync:Vt.lstatSync,readdir:Vt.readdir,readdirSync:Vt.readdirSync,readlinkSync:Vt.readlinkSync,realpathSync:eI,promises:{lstat:Fs.lstat,readdir:Fs.readdir,readlink:Fs.readlink,realpath:Fs.realpath}},Uw=s=>!s||s===nn||s===ZO?nn:{...nn,...s,promises:{...nn.promises,...s.promises||{}}},Gw=/^\\\\\?\\([a-z]:)\\?$/i,tI=s=>s.replace(/\//g,"\\").replace(Gw,"$1\\"),sI=/[\\\/]/,ut=0,zw=1,Vw=2,zt=4,Hw=6,Kw=8,xr=10,Jw=12,dt=15,on=~dt,$f=16,Lw=32,an=64,qt=128,Bc=256,Uc=512,Fw=an|qt|Uc,rI=1023,Rf=s=>s.isFile()?Kw:s.isDirectory()?zt:s.isSymbolicLink()?xr:s.isCharacterDevice()?Vw:s.isBlockDevice()?Hw:s.isSocket()?Jw:s.isFIFO()?zw:ut,Ww=new gr({max:2**12}),cn=s=>{let e=Ww.get(s);if(e)return e;let t=s.normalize("NFKD");return Ww.set(s,t),t},Bw=new gr({max:2**12}),Mc=s=>{let e=Bw.get(s);if(e)return e;let t=cn(s.toLowerCase());return Bw.set(s,t),t},Gc=class extends gr{constructor(){super({max:256})}},Af=class extends gr{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1})}},Yw=Symbol("PathScurry setAsCwd"),Ae=class{name;root;roots;parent;nocase;isCWD=!1;#e;#s;get dev(){return this.#s}#t;get mode(){return this.#t}#r;get nlink(){return this.#r}#i;get uid(){return this.#i}#g;get gid(){return this.#g}#u;get rdev(){return this.#u}#a;get blksize(){return this.#a}#p;get ino(){return this.#p}#c;get size(){return this.#c}#l;get blocks(){return this.#l}#o;get atimeMs(){return this.#o}#x;get mtimeMs(){return this.#x}#w;get ctimeMs(){return this.#w}#y;get birthtimeMs(){return this.#y}#f;get atime(){return this.#f}#S;get mtime(){return this.#S}#m;get ctime(){return this.#m}#E;get birthtime(){return this.#E}#k;#_;#b;#v;#h;#P;#n;#N;#T;#C;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=ut,r,i,o,n,a){this.name=e,this.#k=o?Mc(e):cn(e),this.#n=t&rI,this.nocase=o,this.roots=i,this.root=r||this,this.#N=n,this.#b=a.fullpath,this.#h=a.relative,this.#P=a.relativePosix,this.parent=a.parent,this.parent?this.#e=this.parent.#e:this.#e=Uw(a.fs)}depth(){return this.#_!==void 0?this.#_:this.parent?this.#_=this.parent.depth()+1:this.#_=0}childrenCache(){return this.#N}resolve(e){if(!e)return this;let t=this.getRootString(e),i=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#$(i):this.#$(i)}#$(e){let t=this;for(let r of e)t=t.child(r);return t}children(){let e=this.#N.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#N.set(this,t),this.#n&=~$f,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let r=this.children(),i=this.nocase?Mc(e):cn(e);for(let c of r)if(c.#k===i)return c;let o=this.parent?this.sep:"",n=this.#b?this.#b+o+e:void 0,a=this.newChild(e,ut,{...t,parent:this,fullpath:n});return this.canReaddir()||(a.#n|=qt),r.push(a),a}relative(){if(this.isCWD)return"";if(this.#h!==void 0)return this.#h;let e=this.name,t=this.parent;if(!t)return this.#h=this.name;let r=t.relative();return r+(!r||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#P!==void 0)return this.#P;let e=this.name,t=this.parent;if(!t)return this.#P=this.fullpathPosix();let r=t.relativePosix();return r+(!r||!t.parent?"":"/")+e}fullpath(){if(this.#b!==void 0)return this.#b;let e=this.name,t=this.parent;if(!t)return this.#b=this.name;let i=t.fullpath()+(t.parent?this.sep:"")+e;return this.#b=i}fullpathPosix(){if(this.#v!==void 0)return this.#v;if(this.sep==="/")return this.#v=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#v=`//?/${i}`:this.#v=i}let e=this.parent,t=e.fullpathPosix(),r=t+(!t||!e.parent?"":"/")+this.name;return this.#v=r}isUnknown(){return(this.#n&dt)===ut}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#n&dt)===Kw}isDirectory(){return(this.#n&dt)===zt}isCharacterDevice(){return(this.#n&dt)===Vw}isBlockDevice(){return(this.#n&dt)===Hw}isFIFO(){return(this.#n&dt)===zw}isSocket(){return(this.#n&dt)===Jw}isSymbolicLink(){return(this.#n&xr)===xr}lstatCached(){return this.#n&Lw?this:void 0}readlinkCached(){return this.#T}realpathCached(){return this.#C}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#T)return!0;if(!this.parent)return!1;let e=this.#n&dt;return!(e!==ut&&e!==xr||this.#n&Bc||this.#n&qt)}calledReaddir(){return!!(this.#n&$f)}isENOENT(){return!!(this.#n&qt)}isNamed(e){return this.nocase?this.#k===Mc(e):this.#k===cn(e)}async readlink(){let e=this.#T;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),r=(await this.parent.realpath())?.resolve(t);if(r)return this.#T=r}catch(t){this.#D(t.code);return}}readlinkSync(){let e=this.#T;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),r=this.parent.realpathSync()?.resolve(t);if(r)return this.#T=r}catch(t){this.#D(t.code);return}}#W(e){this.#n|=$f;for(let t=e.provisional;t<e.length;t++){let r=e[t];r&&r.#O()}}#O(){this.#n&qt||(this.#n=(this.#n|qt)&on,this.#j())}#j(){let e=this.children();e.provisional=0;for(let t of e)t.#O()}#B(){this.#n|=Uc,this.#R()}#R(){if(this.#n&an)return;let e=this.#n;(e&dt)===zt&&(e&=on),this.#n=e|an,this.#j()}#A(e=""){e==="ENOTDIR"||e==="EPERM"?this.#R():e==="ENOENT"?this.#O():this.children().provisional=0}#M(e=""){e==="ENOTDIR"?this.parent.#R():e==="ENOENT"&&this.#O()}#D(e=""){let t=this.#n;t|=Bc,e==="ENOENT"&&(t|=qt),(e==="EINVAL"||e==="UNKNOWN")&&(t&=on),this.#n=t,e==="ENOTDIR"&&this.parent&&this.parent.#R()}#I(e,t){return this.#U(e,t)||this.#d(e,t)}#d(e,t){let r=Rf(e),i=this.newChild(e.name,r,{parent:this}),o=i.#n&dt;return o!==zt&&o!==xr&&o!==ut&&(i.#n|=an),t.unshift(i),t.provisional++,i}#U(e,t){for(let r=t.provisional;r<t.length;r++){let i=t[r];if((this.nocase?Mc(e.name):cn(e.name))===i.#k)return this.#L(e,i,r,t)}}#L(e,t,r,i){let o=t.name;return t.#n=t.#n&on|Rf(e),o!==e.name&&(t.name=e.name),r!==i.provisional&&(r===i.length-1?i.pop():i.splice(r,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#n&qt)===0)try{return this.#q(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#M(e.code)}}lstatSync(){if((this.#n&qt)===0)try{return this.#q(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#M(e.code)}}#q(e){let{atime:t,atimeMs:r,birthtime:i,birthtimeMs:o,blksize:n,blocks:a,ctime:c,ctimeMs:l,dev:d,gid:p,ino:u,mode:m,mtime:h,mtimeMs:f,nlink:g,rdev:b,size:x,uid:y}=e;this.#f=t,this.#o=r,this.#E=i,this.#y=o,this.#a=n,this.#l=a,this.#m=c,this.#w=l,this.#s=d,this.#g=p,this.#p=u,this.#t=m,this.#S=h,this.#x=f,this.#r=g,this.#u=b,this.#c=x,this.#i=y;let _=Rf(e);this.#n=this.#n&on|_|Lw,_!==ut&&_!==zt&&_!==xr&&(this.#n|=an)}#F=[];#z=!1;#V(e){this.#z=!1;let t=this.#F.slice();this.#F.length=0,t.forEach(r=>r(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let r=this.children();if(this.calledReaddir()){let o=r.slice(0,r.provisional);t?e(null,o):queueMicrotask(()=>e(null,o));return}if(this.#F.push(e),this.#z)return;this.#z=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(o,n)=>{if(o)this.#A(o.code),r.provisional=0;else{for(let a of n)this.#I(a,r);this.#W(r)}this.#V(r.slice(0,r.provisional))})}#G;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#G)await this.#G;else{let r=()=>{};this.#G=new Promise(i=>r=i);try{for(let i of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#I(i,e);this.#W(e)}catch(i){this.#A(i.code),e.provisional=0}this.#G=void 0,r()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let r of this.#e.readdirSync(t,{withFileTypes:!0}))this.#I(r,e);this.#W(e)}catch(r){this.#A(r.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#n&Fw)return!1;let e=dt&this.#n;return e===ut||e===zt||e===xr}shouldWalk(e,t){return(this.#n&zt)===zt&&!(this.#n&Fw)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#C)return this.#C;if(!((Uc|Bc|qt)&this.#n))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#C=this.resolve(e)}catch{this.#B()}}realpathSync(){if(this.#C)return this.#C;if(!((Uc|Bc|qt)&this.#n))try{let e=this.#e.realpathSync(this.fullpath());return this.#C=this.resolve(e)}catch{this.#B()}}[Yw](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),r=[],i=this;for(;i&&i.parent;)t.add(i),i.#h=r.join(this.sep),i.#P=r.join("/"),i=i.parent,r.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#h=void 0,i.#P=void 0,i=i.parent}},zc=class s extends Ae{sep="\\";splitSep=sI;constructor(e,t=ut,r,i,o,n,a){super(e,t,r,i,o,n,a)}newChild(e,t=ut,r={}){return new s(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return vi.win32.parse(e).root}getRoot(e){if(e=tI(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,r]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=r;return this.roots[e]=new Si(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(Gw,"$1\\"),e===t}},Vc=class s extends Ae{splitSep="/";sep="/";constructor(e,t=ut,r,i,o,n,a){super(e,t,r,i,o,n,a)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=ut,r={}){return new s(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Hc=class{root;rootPath;roots;cwd;#e;#s;#t;nocase;#r;constructor(e=process.cwd(),t,r,{nocase:i,childrenCacheSize:o=16*1024,fs:n=nn}={}){this.#r=Uw(n),(e instanceof URL||e.startsWith("file://"))&&(e=(0,Mw.fileURLToPath)(e));let a=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#e=new Gc,this.#s=new Gc,this.#t=new Af(o);let c=a.substring(this.rootPath.length).split(r);if(c.length===1&&!c[0]&&c.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let l=this.root,d=c.length-1,p=t.sep,u=this.rootPath,m=!1;for(let h of c){let f=d--;l=l.child(h,{relative:new Array(f).fill("..").join(p),relativePosix:new Array(f).fill("..").join("/"),fullpath:u+=(m?"":p)+h}),m=!0}this.cwd=l}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#t}resolve(...e){let t="";for(let o=e.length-1;o>=0;o--){let n=e[o];if(!(!n||n===".")&&(t=t?`${n}/${t}`:n,this.isAbsolute(n)))break}let r=this.#e.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpath();return this.#e.set(t,i),i}resolvePosix(...e){let t="";for(let o=e.length-1;o>=0;o--){let n=e[o];if(!(!n||n===".")&&(t=t?`${n}/${t}`:n,this.isAbsolute(n)))break}let r=this.#s.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpathPosix();return this.#s.set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r}=t;if(e.canReaddir()){let i=await e.readdir();return r?i:i.map(o=>o.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0}=t;return e.canReaddir()?r?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e.withFileTypes,e=this.cwd);let r=await e.readlink();return t?r:r?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e.withFileTypes,e=this.cwd);let r=e.readlinkSync();return t?r:r?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e.withFileTypes,e=this.cwd);let r=await e.realpath();return t?r:r?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e.withFileTypes,e=this.cwd);let r=e.realpathSync();return t?r:r?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t,a=[];(!o||o(e))&&a.push(r?e:e.fullpath());let c=new Set,l=(p,u)=>{c.add(p),p.readdirCB((m,h)=>{if(m)return u(m);let f=h.length;if(!f)return u();let g=()=>{--f===0&&u()};for(let b of h)(!o||o(b))&&a.push(r?b:b.fullpath()),i&&b.isSymbolicLink()?b.realpath().then(x=>x?.isUnknown()?x.lstat():x).then(x=>x?.shouldWalk(c,n)?l(x,g):g()):b.shouldWalk(c,n)?l(b,g):g()},!0)},d=e;return new Promise((p,u)=>{l(d,m=>{if(m)return u(m);p(a)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t,a=[];(!o||o(e))&&a.push(r?e:e.fullpath());let c=new Set([e]);for(let l of c){let d=l.readdirSync();for(let p of d){(!o||o(p))&&a.push(r?p:p.fullpath());let u=p;if(p.isSymbolicLink()){if(!(i&&(u=p.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(c,n)&&c.add(u)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t;(!o||o(e))&&(yield r?e:e.fullpath());let a=new Set([e]);for(let c of a){let l=c.readdirSync();for(let d of l){(!o||o(d))&&(yield r?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(i&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(a,n)&&a.add(p)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t,a=new Ls({objectMode:!0});(!o||o(e))&&a.write(r?e:e.fullpath());let c=new Set,l=[e],d=0,p=()=>{let u=!1;for(;!u;){let m=l.shift();if(!m){d===0&&a.end();return}d++,c.add(m);let h=(g,b,x=!1)=>{if(g)return a.emit("error",g);if(i&&!x){let y=[];for(let _ of b)_.isSymbolicLink()&&y.push(_.realpath().then(k=>k?.isUnknown()?k.lstat():k));if(y.length){Promise.all(y).then(()=>h(null,b,!0));return}}for(let y of b)y&&(!o||o(y))&&(a.write(r?y:y.fullpath())||(u=!0));d--;for(let y of b){let _=y.realpathCached()||y;_.shouldWalk(c,n)&&l.push(_)}u&&!a.flowing?a.once("drain",p):f||p()},f=!0;m.readdirCB(h,!0),f=!1}};return p(),a}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t,a=new Ls({objectMode:!0}),c=new Set;(!o||o(e))&&a.write(r?e:e.fullpath());let l=[e],d=0,p=()=>{let u=!1;for(;!u;){let m=l.shift();if(!m){d===0&&a.end();return}d++,c.add(m);let h=m.readdirSync();for(let f of h)(!o||o(f))&&(a.write(r?f:f.fullpath())||(u=!0));d--;for(let f of h){let g=f;if(f.isSymbolicLink()){if(!(i&&(g=f.realpathSync())))continue;g.isUnknown()&&g.lstatSync()}g.shouldWalk(c,n)&&l.push(g)}}u&&!a.flowing&&a.once("drain",p)};return p(),a}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[Yw](t)}},Si=class extends Hc{sep="\\";constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,vi.win32,"\\",{...t,nocase:r}),this.nocase=r;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return vi.win32.parse(e).root.toUpperCase()}newRoot(e){return new zc(this.rootPath,zt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Ei=class extends Hc{sep="/";constructor(e=process.cwd(),t={}){let{nocase:r=!1}=t;super(e,vi.posix,"/",{...t,nocase:r}),this.nocase=r}parseRootPath(e){return"/"}newRoot(e){return new Vc(this.rootPath,zt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},ln=class extends Ei{constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,{...t,nocase:r})}},UL=process.platform==="win32"?zc:Vc,Qw=process.platform==="win32"?Si:process.platform==="darwin"?ln:Ei;var iI=s=>s.length>=1,oI=s=>s.length>=1,Ti=class s{#e;#s;#t;length;#r;#i;#g;#u;#a;#p;#c=!0;constructor(e,t,r,i){if(!iI(e))throw new TypeError("empty pattern list");if(!oI(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,r<0||r>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#s=t,this.#t=r,this.#r=i,this.#t===0){if(this.isUNC()){let[o,n,a,c,...l]=this.#e,[d,p,u,m,...h]=this.#s;l[0]===""&&(l.shift(),h.shift());let f=[o,n,a,c,""].join("/"),g=[d,p,u,m,""].join("/");this.#e=[f,...l],this.#s=[g,...h],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[o,...n]=this.#e,[a,...c]=this.#s;n[0]===""&&(n.shift(),c.shift());let l=o+"/",d=a+"/";this.#e=[l,...n],this.#s=[d,...c],this.length=this.#e.length}}}pattern(){return this.#e[this.#t]}isString(){return typeof this.#e[this.#t]=="string"}isGlobstar(){return this.#e[this.#t]===oe}isRegExp(){return this.#e[this.#t]instanceof RegExp}globString(){return this.#g=this.#g||(this.#t===0?this.isAbsolute()?this.#s[0]+this.#s.slice(1).join("/"):this.#s.join("/"):this.#s.slice(this.#t).join("/"))}hasMore(){return this.length>this.#t+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new s(this.#e,this.#s,this.#t+1,this.#r),this.#i.#p=this.#p,this.#i.#a=this.#a,this.#i.#u=this.#u,this.#i):this.#i=null}isUNC(){let e=this.#e;return this.#a!==void 0?this.#a:this.#a=this.#r==="win32"&&this.#t===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#u!==void 0?this.#u:this.#u=this.#r==="win32"&&this.#t===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#p!==void 0?this.#p:this.#p=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#t===0?e:""}checkFollowGlobstar(){return!(this.#t===0||!this.isGlobstar()||!this.#c)}markFollowGlobstar(){return this.#t===0||!this.isGlobstar()||!this.#c?!1:(this.#c=!1,!0)}};var nI=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",$i=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:r,noext:i,noglobstar:o,platform:n=nI}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=n,this.mmopts={dot:!0,nobrace:t,nocase:r,noext:i,noglobstar:o,optimizationLevel:2,platform:n,nocomment:!0,nonegate:!0};for(let a of e)this.add(a)}add(e){let t=new Qe(e,this.mmopts);for(let r=0;r<t.set.length;r++){let i=t.set[r],o=t.globParts[r];if(!i||!o)throw new Error("invalid pattern object");for(;i[0]==="."&&o[0]===".";)i.shift(),o.shift();let n=new Ti(i,o,0,this.platform),a=new Qe(n.globString(),this.mmopts),c=o[o.length-1]==="**",l=n.isAbsolute();l?this.absolute.push(a):this.relative.push(a),c&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(e){let t=e.fullpath(),r=`${t}/`,i=e.relative()||".",o=`${i}/`;for(let n of this.relative)if(n.match(i)||n.match(o))return!0;for(let n of this.absolute)if(n.match(t)||n.match(r))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",r=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(r))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}};var Pf=class s{store;constructor(e=new Map){this.store=e}copy(){return new s(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let r=e.fullpath(),i=this.store.get(r);i?i.add(t.globString()):this.store.set(r,new Set([t.globString()]))}},Cf=class{store=new Map;add(e,t,r){let i=(t?2:0)|(r?1:0),o=this.store.get(e);this.store.set(e,o===void 0?i:i&o)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},qf=class{store=new Map;add(e,t){if(!e.canReaddir())return;let r=this.store.get(e);r?r.find(i=>i.globString()===t.globString())||r.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},pn=class s{hasWalkedCache;matches=new Cf;subwalks=new qf;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new Pf}processPatterns(e,t){this.patterns=t;let r=t.map(i=>[e,i]);for(let[i,o]of r){this.hasWalkedCache.storeWalked(i,o);let n=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(n){i=i.resolve(n==="/"&&this.opts.root!==void 0?this.opts.root:n);let p=o.rest();if(p)o=p;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let c,l,d=!1;for(;typeof(c=o.pattern())=="string"&&(l=o.rest());)i=i.resolve(c),o=l,d=!0;if(c=o.pattern(),l=o.rest(),d){if(this.hasWalkedCache.hasWalked(i,o))continue;this.hasWalkedCache.storeWalked(i,o)}if(typeof c=="string"){let p=c===".."||c===""||c===".";this.matches.add(i.resolve(c),a,p);continue}else if(c===oe){(!i.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(i,o);let p=l?.pattern(),u=l?.rest();if(!l||(p===""||p===".")&&!u)this.matches.add(i,a,p===""||p===".");else if(p===".."){let m=i.parent||i;u?this.hasWalkedCache.hasWalked(m,u)||this.subwalks.add(m,u):this.matches.add(m,a,!0)}}else c instanceof RegExp&&this.subwalks.add(i,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new s(this.opts,this.hasWalkedCache)}filterEntries(e,t){let r=this.subwalks.get(e),i=this.child();for(let o of t)for(let n of r){let a=n.isAbsolute(),c=n.pattern(),l=n.rest();c===oe?i.testGlobstar(o,n,l,a):c instanceof RegExp?i.testRegExp(o,c,l,a):i.testString(o,c,l,a)}return i}testGlobstar(e,t,r,i){if((this.dot||!e.name.startsWith("."))&&(t.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(r&&t.checkFollowGlobstar()?this.subwalks.add(e,r):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),r){let o=r.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(e,o,r.rest(),i);else if(o===".."){let n=e.parent||e;this.subwalks.add(n,r)}else o instanceof RegExp&&this.testRegExp(e,o,r.rest(),i)}}testRegExp(e,t,r,i){t.test(e.name)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}testString(e,t,r,i){e.isNamed(t)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}};var aI=(s,e)=>typeof s=="string"?new $i([s],e):Array.isArray(s)?new $i(s,e):s,Kc=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#s;#t;signal;maxDepth;includeChildMatches;constructor(e,t,r){if(this.patterns=e,this.path=t,this.opts=r,this.#t=!r.posix&&r.platform==="win32"?"\\":"/",this.includeChildMatches=r.includeChildMatches!==!1,(r.ignore||!this.includeChildMatches)&&(this.#s=aI(r.ignore??[],r),!this.includeChildMatches&&typeof this.#s.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=r.maxDepth||1/0,r.signal&&(this.signal=r.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#r(e){return this.seen.has(e)||!!this.#s?.ignored?.(e)}#i(e){return!!this.#s?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||await e.realpath(),!r)return;e=r}let o=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let n=await o.realpath();n&&(n.isUnknown()||this.opts.stat)&&await n.lstat()}return this.matchCheckTest(o,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#r(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||e.realpathSync(),!r)return;e=r}let o=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let n=o.realpathSync();n&&(n?.isUnknown()||this.opts.stat)&&n.lstatSync()}return this.matchCheckTest(o,t)}matchFinish(e,t){if(this.#r(e))return;if(!this.includeChildMatches&&this.#s?.add){let o=`${e.relativePosix()}/**`;this.#s.add(o)}let r=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#t:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(r){let o=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(o+i)}else{let o=this.opts.posix?e.relativePosix():e.relative(),n=this.opts.dotRelative&&!o.startsWith(".."+this.#t)?"."+this.#t:"";this.matchEmit(o?n+o+i:"."+i)}}async match(e,t,r){let i=await this.matchCheck(e,r);i&&this.matchFinish(i,t)}matchSync(e,t,r){let i=this.matchCheckSync(e,r);i&&this.matchFinish(i,t)}walkCB(e,t,r){this.signal?.aborted&&r(),this.walkCB2(e,t,new pn(this.opts),r)}walkCB2(e,t,r,i){if(this.#i(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,r,i));return}r.processPatterns(e,t);let o=1,n=()=>{--o===0&&i()};for(let[a,c,l]of r.matches.entries())this.#r(a)||(o++,this.match(a,c,l).then(()=>n()));for(let a of r.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirCached();a.calledReaddir()?this.walkCB3(a,c,r,n):a.readdirCB((l,d)=>this.walkCB3(a,d,r,n),!0)}n()}walkCB3(e,t,r,i){r=r.filterEntries(e,t);let o=1,n=()=>{--o===0&&i()};for(let[a,c,l]of r.matches.entries())this.#r(a)||(o++,this.match(a,c,l).then(()=>n()));for(let[a,c]of r.subwalks.entries())o++,this.walkCB2(a,c,r.child(),n);n()}walkCBSync(e,t,r){this.signal?.aborted&&r(),this.walkCB2Sync(e,t,new pn(this.opts),r)}walkCB2Sync(e,t,r,i){if(this.#i(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,r,i));return}r.processPatterns(e,t);let o=1,n=()=>{--o===0&&i()};for(let[a,c,l]of r.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let a of r.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirSync();this.walkCB3Sync(a,c,r,n)}n()}walkCB3Sync(e,t,r,i){r=r.filterEntries(e,t);let o=1,n=()=>{--o===0&&i()};for(let[a,c,l]of r.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let[a,c]of r.subwalks.entries())o++,this.walkCB2Sync(a,c,r.child(),n);n()}},dn=class extends Kc{matches=new Set;constructor(e,t,r){super(e,t,r)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},un=class extends Kc{results;constructor(e,t,r){super(e,t,r),this.results=new Ls({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var cI=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Nt=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,Xw.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=e,this.platform=t.platform||cI,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=t.platform==="win32"?Si:t.platform==="darwin"?ln:t.platform?Ei:Qw;this.scurry=new c(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let r=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:r,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},o=this.pattern.map(c=>new Qe(c,i)),[n,a]=o.reduce((c,l)=>(c[0].push(...l.set),c[1].push(...l.globParts),c),[[],[]]);this.patterns=n.map((c,l)=>{let d=a[l];if(!d)throw new Error("invalid pattern object");return new Ti(c,d,0,this.platform)})}async walk(){return[...await new dn(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new dn(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new un(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new un(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var Nf=(s,e={})=>{Array.isArray(s)||(s=[s]);for(let t of s)if(new Qe(t,e).hasMagic())return!0;return!1};function Jc(s,e={}){return new Nt(s,e).streamSync()}function tv(s,e={}){return new Nt(s,e).stream()}function sv(s,e={}){return new Nt(s,e).walkSync()}async function Zw(s,e={}){return new Nt(s,e).walk()}function Yc(s,e={}){return new Nt(s,e).iterateSync()}function rv(s,e={}){return new Nt(s,e).iterate()}var lI=Jc,pI=Object.assign(tv,{sync:Jc}),dI=Yc,uI=Object.assign(rv,{sync:Yc}),Of=Object.assign(sv,{stream:Jc,iterate:Yc}),ev=Object.assign(Zw,{glob:Zw,globSync:sv,sync:Of,globStream:tv,stream:pI,globStreamSync:Jc,streamSync:lI,globIterate:rv,iterate:uI,globIterateSync:Yc,iterateSync:dI,Glob:Nt,hasMagic:Nf,escape:xi,unescape:Pt});ev.glob=ev;var Lh=class{debug=!1;log(e){this.debug&&console.error(e)}result(e){console.error(e)}error(e){console.error(e)}},R=new Lh,Qt=1,U=2,tt=3,I1=300;async function L1(s,e,t,r,i={}){let o=de.resolve(t),n=de.resolve(o,s);if(r.log(`Attempting to assemble workblock from: ${n} (identifier: ${s})`),!kt.existsSync(n))throw r.error(`Directory does not exist: ${n}`),new Error(`Directory does not exist: ${n}`);let a=await ri(n,r);if(!a)throw r.error(`Failed to assemble workblock from ${n}`),new Error(`Failed to assemble workblock from ${n}`);let c=JSON.stringify(a,null,2);r.log(`Submitting workblock from ${s} to ${e}...`);let l={"Content-Type":"application/json",...i},d=await fetch(e,{method:"POST",headers:l,body:c});if(d.ok){r.log(`Workblock from ${s} submitted successfully to ${e}. Status: ${d.status}`);let p=await d.text();p&&r.log(`Response: ${p}`)}else{r.error(`Failed to submit workblock from ${s}. Status: ${d.status}`);let p=await d.text();throw p&&r.error(`Error details: ${p}`),new Error(`Failed to submit workblock from ${s}. Status: ${d.status}`)}}async function F1(s,e,t,r,i){let o=de.resolve(e);i.log("Determining changed workblock directories..."),i.log(`Workspace: ${o}`),i.log(`Workblock Base Directory (relative to workspace): ${s}`);let n="";try{let u=`git diff --name-only "${t}" "${r}"`;i.log(`Running git diff: ${u} in ${o}`),n=(0,Li.execSync)(u,{cwd:o,encoding:"utf8"})}catch(u){let m=u instanceof Error?u.message:String(u);throw i.error(`Failed to run git diff: ${m}`),u&&typeof u=="object"&&"stderr"in u&&u.stderr&&i.error(`Git stderr: ${String(u.stderr)}`),new Error(`Failed to run git diff: ${m}`)}let a=n.split(`
14373
- `).filter(u=>u.trim()!=="");if(i.log(`All changed files (${a.length}): ${a.join(", ")||"None"}`),a.length===0)return i.log("No files changed according to git diff."),[];let c=de.join(s,"**/{manifest.yaml,*manifest.yaml}");i.log(`Searching for manifest files with pattern: ${c} (relative to ${o})`);let l=Of(c,{cwd:o,nodir:!0,absolute:!0});if(i.log(`Found manifest files (${l.length}): ${l.join(", ")||"None"}`),l.length===0)return i.log("No manifest files found."),[];let d=new Set;for(let u of l){let m=de.dirname(u);i.log(`Potential workblock root (absolute): ${m}`);for(let h of a){let f=de.resolve(o,h);if(f.startsWith(m+de.sep)||f===m){let g=de.relative(o,m);d.add(g),i.log(`Found changed file '${h}' in workblock '${g}'. Adding to process list.`);break}}}let p=Array.from(d);return i.log(`Found ${p.length} changed workblock directories: ${p.join(", ")||"None"}`),p}H.name("wb-cli").description("CLI for working with Beyond Work workblocks").version("0.1.37").option("-d, --debug","Enable verbose debug logging").exitOverride(s=>process.exit(s.exitCode===0?0:U)).hook("preAction",s=>{R.debug=!!s.opts().debug});H.command("assemble <directory>").description("Assemble a workblock from a directory").option("-o, --output <file>","Output file (defaults to stdout)").action(async(s,e)=>{try{let t=de.resolve(s);kt.existsSync(t)||(R.error(`Directory does not exist: ${t}`),process.exit(1));let r=await ri(t,R);r||(R.error("Failed to assemble workblock"),process.exit(1));let i=JSON.stringify(r,null,2);if(e.output){let o=de.resolve(e.output);kt.writeFileSync(o,i),R.result(`Workblock written to ${o}`)}else process.stdout.write(i)}catch(t){let r=t instanceof Error?t.message:String(t);R.error(`Error: ${r}`),process.exit(1)}});H.command("split <manifest> <workblockDir>").description("Split a workblock manifest into files").action(async(s,e)=>{try{let t=de.resolve(s),r=de.resolve(e);kt.existsSync(t)||(R.error(`Manifest file does not exist: ${t}`),process.exit(1)),R.log(`Reading manifest from: ${t}`);let i=kt.readFileSync(t,"utf8"),o=(0,D1.parse)(i);o||(R.error("Failed to parse workblock from manifest"),process.exit(1)),R.log(`Splitting workblock into: ${r}`),await ii(r,o,{getBlob:async a=>a}),R.result(`Successfully split workblock into ${r}`)}catch(t){let r=t instanceof Error?t.message:String(t);R.error(`Error: ${r}`),process.exit(1)}});H.command("submit <directory> <url>").description("Assemble a workblock and POST it to a URL").option("-w, --workspace <path>","Workspace path, if directory is relative to it",".").option("-H, --header <header>","Add custom header in format 'Header-Name: value' (can be used multiple times)",(s,e=[])=>{let t=e;return t.push(s),t},[]).action(async(s,e,t)=>{try{let r={};for(let i of t.header){let o=i.indexOf(":");o===-1&&(R.error(`Invalid header format: ${i}. Expected 'Header-Name: value'`),process.exit(1));let n=i.substring(0,o).trim(),a=i.substring(o+1).trim();n||(R.error(`Invalid header format: ${i}. Header name cannot be empty`),process.exit(1)),r[n]=a}await L1(s,e,t.workspace,R,r)}catch(r){let i=r instanceof Error?r.message:String(r);R.error(`Error: ${i}`),process.exit(1)}});H.command("publish-changed-workblocks").description("Detects changed workblocks based on git diff and submits them. Optionally comments on a PR.").requiredOption("-u, --publish-url <url>","URL to publish/submit the workblocks to").requiredOption("-b, --workblock-base-dir <dir>","Base directory within the workspace where workblocks are located").option("-w, --workspace <path>","Path to the git workspace root",".").option("-t, --github-token <token>","GitHub token for PR commenting and API interactions").option("--git-diff-base <ref>","Base ref for git diff (e.g., HEAD^, origin/main)","HEAD^").option("--git-diff-head <ref>","Head ref for git diff","HEAD").action(async s=>{let{publishUrl:e,workblockBaseDir:t,workspace:r,githubToken:i,gitDiffBase:o,gitDiffHead:n}=s,{Octokit:a}=await Promise.resolve().then(()=>(eS(),Zv)),c;i&&(c=new a({auth:i}));let l=await F1(t,r,o,n,R),d,p,u;if(c){R.log("Attempting to determine PR information from the current commit...");try{let h=(0,Li.execSync)("git rev-parse HEAD",{cwd:r,encoding:"utf8"}).trim();R.log(`Current commit SHA: ${h}`);let f=(0,Li.execSync)("git remote get-url origin",{cwd:r,encoding:"utf8"}).trim();R.log(`Git remote origin URL: ${f}`);let g=f.split("/");if(g.length<2){R.log(`Could not parse owner/repo from git remote URL: '${f}'. Skipping PR interaction.`);return}let b=g[g.length-1];u=b.endsWith(".git")?b.slice(0,-4):b,p=g[g.length-2],R.log(`Inferred repository: ${p}/${u}`);let{data:x}=await c.rest.repos.listPullRequestsAssociatedWithCommit({owner:p,repo:u,commit_sha:h});if(x.length>0){let _=x.find(k=>k.state==="open")||x[0];d=_.number,R.log(`Found PR #${d} (state: ${_.state}) associated with commit ${h} in ${p}/${u}.`)}else R.log(`No PRs found associated with commit ${h} in ${p}/${u}.`)}catch(h){let f=h instanceof Error?h.message:String(h);R.error(`Error determining PR information: ${f}. Skipping PR interaction.`)}}if(l.length===0){R.log("No changed workblock directories (containing a manifest and changes) found.");return}R.log(`Found ${l.length} changed workblock directories to process: ${l.join(", ")}`);let m=!1;for(let h of l){R.log(`Processing directory: ${h}`);try{await L1(h,e,r,R,{}),R.log(`Successfully submitted workblock for directory: ${h}`)}catch(f){let g=f instanceof Error?f.message:String(f);R.error(`Failed to submit workblock for directory ${h}: ${g}`),m=!0}}if(d&&p&&u&&c&&l.length>0){R.log(`Attempting to comment on PR #${d} in repo ${p}/${u}`);let h="The following workblock directories were processed by `wb-cli publish-changed-workblocks`:\n";for(let f of l)h+=`- \`\`\`${f}\`\`\`
14581
+ `;var At="changes a branch of the workblock; wb-cli push (--update to publish) and pull keep the checkout's branch in step, and deploying to main happens in Studio",aw={deploy_workblock_version:"deploys a version to main, which a person does in Studio",merge_workblock_branch:At,reset_workblock_branch:At,delete_workblock_branch:At,apply_workblock_deployed_updates:At,apply_workblock_version_updates:At,sync_workblock_version:At,sync_workblock:At,resolve_workblock_merge_conflicts:At,create_workblock_version_update:At,revert_workblock_commit:At,switch_stream_branch:At,create_workblock_version:"creates a version; use wb-cli push --new-version <name>, which moves the checkout onto it",set_work_block:"saves workblock content; use wb-cli push, which fences the save against other writers",set_work_block_v2:"saves workblock content; use wb-cli push, which fences the save against other writers",store_work_block:"saves workblock content; use wb-cli push, which fences the save against other writers",delete_studio_workspace:"deletes a Studio workspace and the saves on it; do that in Studio",uninstall_workblock:"removes an installed workblock for every user; do that in Studio",delete_workblock:"deletes the workblock for every user; do that in Studio",publish_to_registry:"publishes the workblock for other tenants; do that in Studio",authz_schema_force_apply:"applies destructive authorization schema changes, which a person confirms in Studio",temporal_reset_workflow:"rewrites a run's history",yjs_reset_events:"discards a document's collaborative history"};function cf(s){return Object.hasOwn(aw,s)?aw[s]:void 0}var af;function lf(){if(!af){let e=(0,cw.parse)(nw).$defs??{},t=r=>e[r]?.properties??{};af={requests:t("RequestsMap"),responses:t("ResponsesMapRaw"),defs:e}}return af}function lw(s){let e=s?.toLowerCase();return Object.keys(lf().requests).filter(t=>!e||t.includes(e)).sort()}function pf(s){return Object.hasOwn(lf().requests,s)}var NN=4;function Yo(s,e,t,r){if(Array.isArray(s))return s.map(o=>Yo(o,e,t,r));if(!s||typeof s!="object")return s;let i=s.$ref;if(typeof i=="string"&&i.startsWith("#/$defs/")){let o=i.slice(8);return t>=NN||r.includes(o)||!e[o]?{$ref:o}:{$def:o,...Yo(e[o],e,t+1,[...r,o])}}return Object.fromEntries(Object.entries(s).filter(([o])=>o!=="additionalProperties").map(([o,n])=>[o,Yo(n,e,t,r)]))}function pw(s){let e=lf();if(!pf(s))throw new Error(`${JSON.stringify(s)} is not a request of this API. List them with wb-cli api --list [filter].`);let t=cf(s);return{verb:s,request:Yo(e.requests[s],e.defs,0,[]),response:Yo(e.responses[s]??null,e.defs,0,[]),...t?{refused:t}:{}}}var D1=O(zr()),Li=require("child_process");var df=(s,e,t)=>{let r=s instanceof RegExp?dw(s,t):s,i=e instanceof RegExp?dw(e,t):e,o=r!==null&&i!=null&&ON(r,i,t);return o&&{start:o[0],end:o[1],pre:t.slice(0,o[0]),body:t.slice(o[0]+r.length,o[1]),post:t.slice(o[1]+i.length)}},dw=(s,e)=>{let t=e.match(s);return t?t[0]:null},ON=(s,e,t)=>{let r,i,o,n,a,c=t.indexOf(s),l=t.indexOf(e,c+1),d=c;if(c>=0&&l>0){if(s===e)return[c,l];for(r=[],o=t.length;d>=0&&!a;){if(d===c)r.push(d),c=t.indexOf(s,d+1);else if(r.length===1){let p=r.pop();p!==void 0&&(a=[p,l])}else i=r.pop(),i!==void 0&&i<o&&(o=i,n=l),l=t.indexOf(e,d+1);d=c<l&&c>=0?c:l}r.length&&n!==void 0&&(a=[o,n])}return a};var uw="\0SLASH"+Math.random()+"\0",fw="\0OPEN"+Math.random()+"\0",hf="\0CLOSE"+Math.random()+"\0",mw="\0COMMA"+Math.random()+"\0",hw="\0PERIOD"+Math.random()+"\0",IN=new RegExp(uw,"g"),jN=new RegExp(fw,"g"),DN=new RegExp(hf,"g"),LN=new RegExp(mw,"g"),FN=new RegExp(hw,"g"),WN=/\\\\/g,BN=/\\{/g,MN=/\\}/g,UN=/\\,/g,GN=/\\\./g,zN=1e5,VN=4e6,HN=1e3,KN=1e3;function uf(s){return isNaN(s)?s.charCodeAt(0):parseInt(s,10)}function JN(s){return s.replace(WN,uw).replace(BN,fw).replace(MN,hf).replace(UN,mw).replace(GN,hw)}function YN(s){return s.replace(IN,"\\").replace(jN,"{").replace(DN,"}").replace(LN,",").replace(FN,".")}function ff(s,e){for(let t=0;t<e.length;t++)s.push(e[t])}function QN(s){let e=[],t="";for(;;){let r=df("{","}",s);if(!r){let c=s.split(",");return c[0]=t+c[0],ff(e,c),e}let{pre:i,body:o,post:n}=r,a=i.split(",");if(a[0]=t+a[0],a[a.length-1]+="{"+o+"}",!n.length)return ff(e,a),e;t=a.pop(),ff(e,a),s=n}}function gw(s,e={}){if(!s)return[];let{max:t=zN,maxLength:r=VN,maxDepth:i=HN,maxRewrites:o=KN}=e;return s.slice(0,2)==="{}"&&(s="\\{\\}"+s.slice(2)),mf(JN(s),t,r,i,0,o,!0).map(YN)}function XN(s){return"{"+s+"}"}function ZN(s){return/^-?0\d/.test(s)}function eO(s,e){return s<=e}function tO(s,e){return s>=e}function Qo(s,e,t,r,i,o){let n=[],a=0;for(let c=0;c<s.length;c++)for(let l=0;l<t.length;l++){if(n.length>=r)return n;let d=s[c]+e+t[l];if(!(o&&!d)){if(a+d.length>i)return n;n.push(d),a+=d.length}}return n}function sO(s,e,t,r){let i=s.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let n=uf(i[0]),a=uf(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(uf(i[2])),1):1,d=eO;a<n&&(l*=-1,d=tO);let u=i.some(ZN),m=0;for(let h=n;d(h,a)&&o.length<t;h+=l){let f;if(e)f=String.fromCharCode(h),f==="\\"&&(f="");else if(f=String(h),u){let g=c-f.length;if(g>0){let b=new Array(g+1).join("0");h<0?f="-"+b+f.slice(1):f=b+f}}if(m+f.length>r)break;o.push(f),m+=f.length}return o}function mf(s,e,t,r,i,o,n){if(i>r)return[s];let a=[""],c=0,l=!1,d=!0;for(;;){let p=df("{","}",s);if(!p)return Qo(a,s,[""],e,t,l);let u=p.pre;if(/\$$/.test(u)){if(a=Qo(a,u+"{"+p.body+"}",[""],e,t,l&&!p.post.length),d=!1,!p.post.length)break;s=p.post;continue}let m=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(p.body),h=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(p.body),f=m||h,g=p.body.indexOf(",")>=0;if(!f&&!g){if(c<o&&p.post.match(/,(?!,).*\}/)){c++,s=p.pre+"{"+p.body+hf+p.post,n=!0;continue}return Qo(a,u+"{"+p.body+"}"+p.post,[""],e,t,l)}d&&(l=n&&!f,d=!1);let b;if(f)b=sO(p.body,h,e,t);else{let x=QN(p.body);if(x.length===1&&x[0]!==void 0&&(x=mf(x[0],e,t,r,i+1,o,!1).map(XN),x.length===1)){if(a=Qo(a,u+x[0],[""],e,t,l&&!p.post.length),!p.post.length)break;s=p.post;continue}let y=l&&!p.post.length&&!u;for(let k=0;y&&k<a.length;k++)a[k]&&(y=!1);b=[];let _=0;e:for(let k=0;k<x.length;k++){let S=mf(x[k],e,t,r,i+1,o,!1);for(let T=0;T<S.length;T++){let E=S[T];if(!(y&&!E)){if(b.length>=e||_+E.length>t)break e;b.push(E),_+=E.length}}}}if(a=Qo(a,u,b,e,t,l&&!p.post.length),!p.post.length)break;s=p.post}return a}var Xo=s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>65536)throw new TypeError("pattern is too long")};var rO={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Zo=s=>s.replace(/[[\]\\-]/g,"\\$&"),iO=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),bw=s=>s.join(""),xw=(s,e)=>{let t=e;if(s.charAt(t)!=="[")throw new Error("not in a brace expression");let r=[],i=[],o=t+1,n=!1,a=!1,c=!1,l=!1,d=t,p="";e:for(;o<s.length;){let f=s.charAt(o);if((f==="!"||f==="^")&&o===t+1){l=!0,o++;continue}if(f==="]"&&n&&!c){d=o+1;break}if(n=!0,f==="\\"&&!c){c=!0,o++;continue}if(f==="["&&!c){for(let[g,[b,x,y]]of Object.entries(rO))if(s.startsWith(g,o)){if(p)return["$.",!1,s.length-t,!0];o+=g.length,y?i.push(b):r.push(b),a=a||x;continue e}}if(c=!1,p){f>p?r.push(Zo(p)+"-"+Zo(f)):f===p&&r.push(Zo(f)),p="",o++;continue}if(s.startsWith("-]",o+1)){r.push(Zo(f+"-")),o+=2;continue}if(s.startsWith("-",o+1)){p=f,o+=2;continue}r.push(Zo(f)),o++}if(d<o)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,s.length-t,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l){let f=r[0].length===2?r[0].slice(-1):r[0];return[iO(f),!1,d-t,!1]}let u="["+(l?"^":"")+bw(r)+"]",m="["+(l?"":"^")+bw(i)+"]";return[r.length&&i.length?"("+u+"|"+m+")":r.length?u:m,a,d-t,!0]};var Pt=(s,{windowsPathsNoEscape:e=!1,magicalBraces:t=!0}={})=>t?e?s.replace(/\[([^/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?s.replace(/\[([^/\\{}])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var Ue,oO=new Set(["!","?","+","*","@"]),gf=s=>oO.has(s),yw=s=>gf(s.type),nO=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),aO=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),cO=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),_w=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),lO="(?!(?:^|/)\\.\\.?(?:$|/))",qc="(?!\\.)",pO=new Set(["[","."]),dO=new Set(["..","."]),uO=new Set("().*{}+?[]^$\\!"),fO=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),bf="[^/]",kw=bf+"*?",ww=bf+"+?",mO=0,hr=class{type;#e;#s;#t=!1;#r=[];#i;#g;#u;#a=!1;#p;#c;#l=!1;id=++mO;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,r={}){this.type=e,e&&(this.#s=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#p=this.#e===this?r:this.#e.#p,this.#u=this.#e===this?[]:this.#e.#u,e==="!"&&!this.#e.#a&&this.#u.push(this),this.#g=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let e of this.#r)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#r.map(e=>String(e)).join("|")+")":this.#c=this.#r.map(e=>String(e)).join("")}#o(){if(this!==this.#e)throw new Error("should only call on root");if(this.#a)return this;this.toString(),this.#a=!0;let e;for(;e=this.#u.pop();){if(e.type!=="!")continue;let t=e,r=t.#i;for(;r;){for(let i=t.#g+1;!r.type&&i<r.#r.length;i++)for(let o of e.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(r.#r[i])}t=r,r=t.#i}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof Ue&&t.#i===this))throw new Error("invalid part: "+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#r.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#a&&this.#i?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#g===0)return!0;let e=this.#i;for(let t=0;t<this.#g;t++){let r=e.#r[t];if(!(r instanceof Ue&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#g===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let t=new Ue(this.type,e);for(let r of this.#r)t.copyIn(r);return t}static#x(e,t,r,i,o){let n=i.maxExtglobRecursion??2,a=!1,c=!1,l=-1,d=!1;if(t.type===null){let f=r,g="";for(;f<e.length;){let b=e.charAt(f++);if(a||b==="\\"){a=!a,g+=b;continue}if(c){f===l+1?(b==="^"||b==="!")&&(d=!0):b==="]"&&!(f===l+2&&d)&&(c=!1),g+=b;continue}else if(b==="["){c=!0,l=f,d=!1,g+=b;continue}if(!i.noext&&gf(b)&&e.charAt(f)==="("&&o<=n){t.push(g),g="";let y=new Ue(b,t);f=Ue.#x(e,y,f,i,o+1),t.push(y);continue}g+=b}return t.push(g),f}let p=r+1,u=new Ue(null,t),m=[],h="";for(;p<e.length;){let f=e.charAt(p++);if(a||f==="\\"){a=!a,h+=f;continue}if(c){p===l+1?(f==="^"||f==="!")&&(d=!0):f==="]"&&!(p===l+2&&d)&&(c=!1),h+=f;continue}else if(f==="["){c=!0,l=p,d=!1,h+=f;continue}if(!i.noext&&gf(f)&&e.charAt(p)==="("&&(o<=n||t&&t.#f(f))){let b=t&&t.#f(f)?0:1;u.push(h),h="";let x=new Ue(f,u);u.push(x),p=Ue.#x(e,x,p,i,o+b);continue}if(f==="|"){u.push(h),h="",m.push(u),u=new Ue(null,t);continue}if(f===")")return h===""&&t.#r.length===0&&(t.#l=!0),u.push(h),h="",t.push(...m,u),p;h+=f}return t.type=null,t.#s=void 0,t.#r=[e.substring(r-1)],p}#w(e){return this.#y(e,aO)}#y(e,t=nO){if(!e||typeof e!="object"||e.type!==null||e.#r.length!==1||this.type===null)return!1;let r=e.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#f(r.type,t)}#f(e,t=cO){return!!t.get(this.type)?.includes(e)}#S(e,t){let r=e.#r[0],i=new Ue(null,r,this.options);i.#r.push(""),r.push(i),this.#m(e,t)}#m(e,t){let r=e.#r[0];this.#r.splice(t,1,...r.#r);for(let i of r.#r)typeof i=="object"&&(i.#i=this);this.#c=void 0}#E(e){return!!_w.get(this.type)?.has(e)}#k(e){if(!e||typeof e!="object"||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!="object"||t.type===null?!1:this.#E(t.type)}#_(e){let t=_w.get(this.type),r=e.#r[0],i=t?.get(r.type);if(!i)return!1;this.#r=r.#r;for(let o of this.#r)typeof o=="object"&&(o.#i=this);this.type=i,this.#c=void 0,this.#l=!1}static fromGlob(e,t={}){let r=new Ue(null,void 0,t);return Ue.#x(e,r,0,t,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,r,i,o]=this.toRegExpSource();if(!(i||this.#s||this.#p.nocase&&!this.#p.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return r;let a=(this.#p.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#p}toRegExpSource(e){let t=e??!!this.#p.dot;if(this.#e===this&&(this.#b(),this.#o()),!yw(this)){let c=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),l=this.#r.map(m=>{let[h,f,g,b]=typeof m=="string"?Ue.#h(m,this.#s,c):m.toRegExpSource(e);return this.#s=this.#s||g,this.#t=this.#t||b,h}).join(""),d="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&dO.has(this.#r[0]))){let h=pO,f=t&&h.has(l.charAt(0))||l.startsWith("\\.")&&h.has(l.charAt(2))||l.startsWith("\\.\\.")&&h.has(l.charAt(4)),g=!t&&!e&&h.has(l.charAt(0));d=f?lO:g?qc:""}let p="";return this.isEnd()&&this.#e.#a&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[d+l+p,Pt(l),this.#s=!!this.#s,this.#t]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#v(t);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let c=this.toString(),l=this;return l.#r=[c],l.type=null,l.#s=void 0,[c,Pt(this.toString()),!1,!1]}let n=!r||e||t||!qc?"":this.#v(!0);n===o&&(n=""),n&&(o=`(?:${o})(?:${n})*?`);let a="";if(this.type==="!"&&this.#l)a=(this.isStart()&&!t?qc:"")+ww;else{let c=this.type==="!"?"))"+(this.isStart()&&!t&&!e?qc:"")+kw+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&n?")":this.type==="*"&&n?")?":`)${this.type}`;a=i+o+c}return[a,Pt(o),this.#s=!!this.#s,this.#t]}#b(){if(yw(this)){let e=0,t=!1;do{t=!0;for(let r=0;r<this.#r.length;r++){let i=this.#r[r];typeof i=="object"&&(i.#b(),this.#y(i)?(t=!1,this.#m(i,r)):this.#w(i)?(t=!1,this.#S(i,r)):this.#k(i)&&(t=!1,this.#_(i)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e=="object"&&e.#b();this.#c=void 0}#v(e){return this.#r.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[r,i,o,n]=t.toRegExpSource(e);return this.#t=this.#t||n,r}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#h(e,t,r=!1){let i=!1,o="",n=!1,a=!1;for(let c=0;c<e.length;c++){let l=e.charAt(c);if(i){i=!1,o+=(uO.has(l)?"\\":"")+l;continue}if(l==="*"){if(a)continue;a=!0,o+=r&&/^[*]+$/.test(e)?ww:kw,t=!0;continue}else a=!1;if(l==="\\"){c===e.length-1?o+="\\\\":i=!0;continue}if(l==="["){let[d,p,u,m]=xw(e,c);if(u){o+=d,n=n||p,c+=u-1,t=t||m;continue}}if(l==="?"){o+=bf,t=!0;continue}o+=fO(l)}return[o,Pt(e),!!t,n]}};Ue=hr;var xi=(s,{windowsPathsNoEscape:e=!1,magicalBraces:t=!1}={})=>t?e?s.replace(/[?*()[\]{}]/g,"[$&]"):s.replace(/[?*()[\]\\{}]/g,"\\$&"):e?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&");var Oe=(s,e,t={})=>(Xo(e),!t.nocomment&&e.charAt(0)==="#"?!1:new Qe(e,t).match(s)),hO=/^\*+([^+@!?*[(]*)$/,gO=s=>e=>!e.startsWith(".")&&e.endsWith(s),bO=s=>e=>e.endsWith(s),xO=s=>(s=s.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(s)),yO=s=>(s=s.toLowerCase(),e=>e.toLowerCase().endsWith(s)),_O=/^\*+\.\*+$/,kO=s=>!s.startsWith(".")&&s.includes("."),wO=s=>s!=="."&&s!==".."&&s.includes("."),vO=/^\.\*+$/,SO=s=>s!=="."&&s!==".."&&s.startsWith("."),EO=/^\*+$/,TO=s=>s.length!==0&&!s.startsWith("."),$O=s=>s.length!==0&&s!=="."&&s!=="..",RO=/^\?+([^+@!?*[(]*)?$/,AO=([s,e=""])=>{let t=Ew([s]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},PO=([s,e=""])=>{let t=Tw([s]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},CO=([s,e=""])=>{let t=Tw([s]);return e?r=>t(r)&&r.endsWith(e):t},qO=([s,e=""])=>{let t=Ew([s]);return e?r=>t(r)&&r.endsWith(e):t},Ew=([s])=>{let e=s.length;return t=>t.length===e&&!t.startsWith(".")},Tw=([s])=>{let e=s.length;return t=>t.length===e&&t!=="."&&t!==".."},$w=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",vw={win32:{sep:"\\"},posix:{sep:"/"}},NO=$w==="win32"?vw.win32.sep:vw.posix.sep;Oe.sep=NO;var oe=Symbol("globstar **");Oe.GLOBSTAR=oe;var OO="[^/]",IO=OO+"*?",jO="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",DO="(?:(?!(?:\\/|^)\\.).)*?",LO=(s,e={})=>t=>Oe(t,s,e);Oe.filter=LO;var pt=(s,e={})=>Object.assign({},s,e),FO=s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return Oe;let e=Oe;return Object.assign((r,i,o={})=>e(r,i,pt(s,o)),{Minimatch:class extends e.Minimatch{constructor(i,o={}){super(i,pt(s,o))}static defaults(i){return e.defaults(pt(s,i)).Minimatch}},AST:class extends e.AST{constructor(i,o,n={}){super(i,o,pt(s,n))}static fromGlob(i,o={}){return e.AST.fromGlob(i,pt(s,o))}},unescape:(r,i={})=>e.unescape(r,pt(s,i)),escape:(r,i={})=>e.escape(r,pt(s,i)),filter:(r,i={})=>e.filter(r,pt(s,i)),defaults:r=>e.defaults(pt(s,r)),makeRe:(r,i={})=>e.makeRe(r,pt(s,i)),braceExpand:(r,i={})=>e.braceExpand(r,pt(s,i)),match:(r,i,o={})=>e.match(r,i,pt(s,o)),sep:e.sep,GLOBSTAR:oe})};Oe.defaults=FO;var Rw=(s,e={})=>(Xo(s),e.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:gw(s,{max:e.braceExpandMax}));Oe.braceExpand=Rw;var WO=(s,e={})=>new Qe(s,e).makeRe();Oe.makeRe=WO;var BO=(s,e,t={})=>{let r=new Qe(e,t);return s=s.filter(i=>r.match(i)),r.options.nonull&&!s.length&&s.push(e),s};Oe.match=BO;var Sw=/[?*]|[+@!]\(.*?\)|\[|\]/,MO=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Qe=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){Xo(e),t=t||{},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||$w,this.isWindows=this.platform==="win32";let r="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[r]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let r=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,n,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=o[0]===""&&o[1]===""&&(o[2]==="?"||!Sw.test(o[2]))&&!Sw.test(o[3]),l=/^[a-z]:/i.test(o[0]);if(c)return[...o.slice(0,4),...o.slice(4).map(d=>this.parse(d))];if(l)return[o[0],...o.slice(1).map(d=>this.parse(d))]}return o.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let n=this.set[o];n[0]===""&&n[1]===""&&this.globParts[o][2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3])&&(n[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let r of e)for(let i=0;i<r.length;i++)r[i]==="**"&&(r[i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let r=-1;for(;(r=t.indexOf("**",r+1))!==-1;){let i=r;for(;t[i+1]==="**";)i++;i!==r&&t.splice(r,i-r)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((r,i)=>{let o=r[r.length-1];return i==="**"&&o==="**"?r:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(r.pop(),r):(r.push(i),r)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let o=e[i];i===1&&o===""&&e[0]===""||(o==="."||o==="")&&(t=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=!0,e.pop())}let r=0;for(;(r=e.indexOf("..",r+1))!==-1;){let i=e[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(t=!0,e.splice(r-1,2),r-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let r of e){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let n=i;for(;r[n+1]==="**";)n++;n>i&&r.splice(i+1,n-i);let a=r[i+1],c=r[i+2],l=r[i+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;t=!0,r.splice(i,1);let d=r.slice(0);d[i]="**",e.push(d),i--}if(!this.preserveMultipleSlashes){for(let n=1;n<r.length-1;n++){let a=r[n];n===1&&a===""&&r[0]===""||(a==="."||a==="")&&(t=!0,r.splice(n,1),n--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(t=!0,r.pop())}let o=0;for(;(o=r.indexOf("..",o+1))!==-1;){let n=r[o-1];if(n&&n!=="."&&n!==".."&&n!=="**"){t=!0;let c=o===1&&r[o+1]==="**"?["."]:[];r.splice(o-1,2,...c),r.length===0&&r.push(""),o-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let r=t+1;r<e.length;r++){let i=this.partsMatch(e[t],e[r],!this.preserveMultipleSlashes);if(i){e[t]=[],e[r]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,r=!1){let i=0,o=0,n=[],a="";for(;i<e.length&&o<t.length;)if(e[i]===t[o])n.push(a==="b"?t[o]:e[i]),i++,o++;else if(r&&e[i]==="**"&&t[o]===e[i+1])n.push(e[i]),i++;else if(r&&t[o]==="**"&&e[i]===t[o+1])n.push(t[o]),o++;else if(e[i]==="*"&&t[o]&&(this.options.dot||!t[o].startsWith("."))&&t[o]!=="**"){if(a==="b")return!1;a="a",n.push(e[i]),i++,o++}else if(t[o]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",n.push(t[o]),i++,o++}else return!1;return e.length===t.length&&n}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,r=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,r++;r&&(this.pattern=e.slice(r)),this.negate=t}matchOne(e,t,r=!1){let i=0,o=0;if(this.isWindows){let a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),c=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),l=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),d=!l&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),p=c?3:a?0:void 0,u=d?3:l?0:void 0;if(typeof p=="number"&&typeof u=="number"){let[m,h]=[e[p],t[u]];m.toLowerCase()===h.toLowerCase()&&(t[u]=m,o=u,i=p)}}let{optimizationLevel:n=1}=this.options;return n>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(oe)?this.#e(e,t,r,i,o):this.#t(e,t,r,i,o)}#e(e,t,r,i,o){let n=t.indexOf(oe,o),a=t.lastIndexOf(oe),[c,l,d]=r?[t.slice(o,n),t.slice(n+1),[]]:[t.slice(o,n),t.slice(n+1,a),t.slice(a+1)];if(c.length){let x=e.slice(i,i+c.length);if(!this.#t(x,c,r,0,0))return!1;i+=c.length,o+=c.length}let p=0;if(d.length){if(d.length+i>e.length)return!1;let x=e.length-d.length;if(this.#t(e,d,r,x,0))p=d.length;else{if(e[e.length-1]!==""||i+d.length===e.length||(x--,!this.#t(e,d,r,x,0)))return!1;p=d.length+1}}if(!l.length){let x=!!p;for(let y=i;y<e.length-p;y++){let _=String(e[y]);if(x=!0,_==="."||_===".."||!this.options.dot&&_.startsWith("."))return!1}return r||x}let u=[[[],0]],m=u[0],h=0,f=[0];for(let x of l)x===oe?(f.push(h),m=[[],0],u.push(m)):(m[0].push(x),h++);let g=u.length-1,b=e.length-p;for(let x of u)x[1]=b-(f[g--]+x[0].length);return!!this.#s(e,u,i,0,r,0,!!p)}#s(e,t,r,i,o,n,a){let c=t[i];if(!c){for(let p=r;p<e.length;p++){a=!0;let u=e[p];if(u==="."||u===".."||!this.options.dot&&u.startsWith("."))return!1}return a}let[l,d]=c;for(;r<=d;){if(this.#t(e.slice(0,r+l.length),l,o,r,0)&&n<this.maxGlobstarRecursion){let m=this.#s(e,t,r+l.length,i+1,o,n+1,a);if(m!==!1)return m}let u=e[r];if(u==="."||u===".."||!this.options.dot&&u.startsWith("."))return!1;r++}return o||null}#t(e,t,r,i,o){let n,a,c,l;for(n=i,a=o,l=e.length,c=t.length;n<l&&a<c;n++,a++){this.debug("matchOne loop");let d=t[a],p=e[n];if(this.debug(t,d,p),d===!1||d===oe)return!1;let u;if(typeof d=="string"?(u=p===d,this.debug("string match",d,p,u)):(u=d.test(p),this.debug("pattern match",d,p,u)),!u)return!1}if(n===l&&a===c)return!0;if(n===l)return r;if(a===c)return n===l-1&&e[n]==="";throw new Error("wtf?")}braceExpand(){return Rw(this.pattern,this.options)}parse(e){Xo(e);let t=this.options;if(e==="**")return oe;if(e==="")return"";let r,i=null;(r=e.match(EO))?i=t.dot?$O:TO:(r=e.match(hO))?i=(t.nocase?t.dot?yO:xO:t.dot?bO:gO)(r[1]):(r=e.match(RO))?i=(t.nocase?t.dot?PO:AO:t.dot?CO:qO)(r):(r=e.match(_O))?i=t.dot?wO:kO:(r=e.match(vO))&&(i=SO);let o=hr.fromGlob(e,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,r=t.noglobstar?IO:t.dot?jO:DO,i=new Set(t.nocase?["i"]:[]),o=e.map(c=>{let l=c.map(p=>{if(p instanceof RegExp)for(let u of p.flags.split(""))i.add(u);return typeof p=="string"?MO(p):p===oe?oe:p._src});l.forEach((p,u)=>{let m=l[u+1],h=l[u-1];p!==oe||h===oe||(h===void 0?m!==void 0&&m!==oe?l[u+1]="(?:\\/|"+r+"\\/)?"+m:l[u]=r:m===void 0?l[u-1]=h+"(?:\\/|\\/"+r+")?":m!==oe&&(l[u-1]=h+"(?:\\/|\\/"+r+"\\/)"+m,l[u+1]=oe))});let d=l.filter(p=>p!==oe);if(this.partial&&d.length>=1){let p=[];for(let u=1;u<=d.length;u++)p.push(d.slice(0,u).join("/"));return"(?:"+p.join("|")+")"}return d.join("/")}).join("|"),[n,a]=e.length>1?["(?:",")"]:["",""];o="^"+n+o+a+"$",this.partial&&(o="^(?:\\/|"+n+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let r=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let n=i[i.length-1];if(!n)for(let a=i.length-2;!n&&a>=0;a--)n=i[a];for(let a of o){let c=i;if(r.matchBase&&a.length===1&&(c=[n]),this.matchOne(c,a,t))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(e){return Oe.defaults(e).Minimatch}};Oe.AST=hr;Oe.Minimatch=Qe;Oe.escape=xi;Oe.unescape=Pt;var Xw=require("node:url");var yi=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Pw=new Set,xf=typeof process=="object"&&process?process:{},Cw=(s,e,t,r)=>{typeof xf.emitWarning=="function"?xf.emitWarning(s,e,t,r):console.error(`[${t}] ${e}: ${s}`)},Nc=globalThis.AbortController,Aw=globalThis.AbortSignal;if(typeof Nc>"u"){Aw=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(r,i){this._onabort.push(i)}},Nc=class{constructor(){e()}signal=new Aw;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let i of this.signal._onabort)i(r);this.signal.onabort?.(r)}}};let s=xf.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{s&&(s=!1,Cw("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var UO=s=>!Pw.has(s);var js=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),qw=s=>js(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?_i:null:null,_i=class extends Array{constructor(e){super(e),this.fill(0)}},yf=class s{heap;length;static#e=!1;static create(e){let t=qw(e);if(!t)return[];s.#e=!0;let r=new s(e,t);return s.#e=!1,r}constructor(e,t){if(!s.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},gr=class s{#e;#s;#t;#r;#i;#g;#u;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#p;#c;#l;#o;#x;#w;#y;#f;#S;#m;#E;#k;#_;#b;#v;#h;#P;static unsafeExposeInternals(e){return{starts:e.#k,ttls:e.#_,sizes:e.#E,keyMap:e.#c,keyList:e.#l,valList:e.#o,next:e.#x,prev:e.#w,get head(){return e.#y},get tail(){return e.#f},free:e.#S,isBackgroundFetch:t=>e.#d(t),backgroundFetch:(t,r,i,o)=>e.#I(t,r,i,o),moveToTail:t=>e.#L(t),indexes:t=>e.#R(t),rindexes:t=>e.#A(t),isStale:t=>e.#$(t)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#p}get size(){return this.#a}get fetchMethod(){return this.#g}get memoMethod(){return this.#u}get dispose(){return this.#t}get onInsert(){return this.#r}get disposeAfter(){return this.#i}constructor(e){let{max:t=0,ttl:r,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:c,dispose:l,onInsert:d,disposeAfter:p,noDisposeOnSet:u,noUpdateTTL:m,maxSize:h=0,maxEntrySize:f=0,sizeCalculation:g,fetchMethod:b,memoMethod:x,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:_,allowStaleOnFetchRejection:k,allowStaleOnFetchAbort:S,ignoreFetchAbort:T}=e;if(t!==0&&!js(t))throw new TypeError("max option must be a nonnegative integer");let E=t?qw(t):Array;if(!E)throw new Error("invalid max value: "+t);if(this.#e=t,this.#s=h,this.maxEntrySize=f||this.#s,this.sizeCalculation=g,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#u=x,b!==void 0&&typeof b!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#g=b,this.#v=!!b,this.#c=new Map,this.#l=new Array(t).fill(void 0),this.#o=new Array(t).fill(void 0),this.#x=new E(t),this.#w=new E(t),this.#y=0,this.#f=0,this.#S=yf.create(t),this.#a=0,this.#p=0,typeof l=="function"&&(this.#t=l),typeof d=="function"&&(this.#r=d),typeof p=="function"?(this.#i=p,this.#m=[]):(this.#i=void 0,this.#m=void 0),this.#b=!!this.#t,this.#P=!!this.#r,this.#h=!!this.#i,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!k,this.allowStaleOnFetchAbort=!!S,this.ignoreFetchAbort=!!T,this.maxEntrySize!==0){if(this.#s!==0&&!js(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!js(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#W()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!_,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=js(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!js(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#n()}if(this.#e===0&&this.ttl===0&&this.#s===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#s){let v="LRU_CACHE_UNBOUNDED";UO(v)&&(Pw.add(v),Cw("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",v,s))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#n(){let e=new _i(this.#e),t=new _i(this.#e);this.#_=e,this.#k=t,this.#C=(o,n,a=yi.now())=>{if(t[o]=n!==0?a:0,e[o]=n,n!==0&&this.ttlAutopurge){let c=setTimeout(()=>{this.#$(o)&&this.#q(this.#l[o],"expire")},n+1);c.unref&&c.unref()}},this.#N=o=>{t[o]=e[o]!==0?yi.now():0},this.#T=(o,n)=>{if(e[n]){let a=e[n],c=t[n];if(!a||!c)return;o.ttl=a,o.start=c,o.now=r||i();let l=o.now-c;o.remainingTTL=a-l}};let r=0,i=()=>{let o=yi.now();if(this.ttlResolution>0){r=o;let n=setTimeout(()=>r=0,this.ttlResolution);n.unref&&n.unref()}return o};this.getRemainingTTL=o=>{let n=this.#c.get(o);if(n===void 0)return 0;let a=e[n],c=t[n];if(!a||!c)return 1/0;let l=(r||i())-c;return a-l},this.#$=o=>{let n=t[o],a=e[o];return!!a&&!!n&&(r||i())-n>a}}#N=()=>{};#T=()=>{};#C=()=>{};#$=()=>!1;#W(){let e=new _i(this.#e);this.#p=0,this.#E=e,this.#O=t=>{this.#p-=e[t],e[t]=0},this.#B=(t,r,i,o)=>{if(this.#d(r))return 0;if(!js(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(r,t),!js(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#j=(t,r,i)=>{if(e[t]=r,this.#s){let o=this.#s-e[t];for(;this.#p>o;)this.#D(!0)}this.#p+=e[t],i&&(i.entrySize=r,i.totalCalculatedSize=this.#p)}}#O=e=>{};#j=(e,t,r)=>{};#B=(e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#R({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#f;!(!this.#M(t)||((e||!this.#$(t))&&(yield t),t===this.#y));)t=this.#w[t]}*#A({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#y;!(!this.#M(t)||((e||!this.#$(t))&&(yield t),t===this.#f));)t=this.#x[t]}#M(e){return e!==void 0&&this.#c.get(this.#l[e])===e}*entries(){for(let e of this.#R())this.#o[e]!==void 0&&this.#l[e]!==void 0&&!this.#d(this.#o[e])&&(yield[this.#l[e],this.#o[e]])}*rentries(){for(let e of this.#A())this.#o[e]!==void 0&&this.#l[e]!==void 0&&!this.#d(this.#o[e])&&(yield[this.#l[e],this.#o[e]])}*keys(){for(let e of this.#R()){let t=this.#l[e];t!==void 0&&!this.#d(this.#o[e])&&(yield t)}}*rkeys(){for(let e of this.#A()){let t=this.#l[e];t!==void 0&&!this.#d(this.#o[e])&&(yield t)}}*values(){for(let e of this.#R())this.#o[e]!==void 0&&!this.#d(this.#o[e])&&(yield this.#o[e])}*rvalues(){for(let e of this.#A())this.#o[e]!==void 0&&!this.#d(this.#o[e])&&(yield this.#o[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#R()){let i=this.#o[r],o=this.#d(i)?i.__staleWhileFetching:i;if(o!==void 0&&e(o,this.#l[r],this))return this.get(this.#l[r],t)}}forEach(e,t=this){for(let r of this.#R()){let i=this.#o[r],o=this.#d(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(t,o,this.#l[r],this)}}rforEach(e,t=this){for(let r of this.#A()){let i=this.#o[r],o=this.#d(i)?i.__staleWhileFetching:i;o!==void 0&&e.call(t,o,this.#l[r],this)}}purgeStale(){let e=!1;for(let t of this.#A({allowStale:!0}))this.#$(t)&&(this.#q(this.#l[t],"expire"),e=!0);return e}info(e){let t=this.#c.get(e);if(t===void 0)return;let r=this.#o[t],i=this.#d(r)?r.__staleWhileFetching:r;if(i===void 0)return;let o={value:i};if(this.#_&&this.#k){let n=this.#_[t],a=this.#k[t];if(n&&a){let c=n-(yi.now()-a);o.ttl=c,o.start=Date.now()}}return this.#E&&(o.size=this.#E[t]),o}dump(){let e=[];for(let t of this.#R({allowStale:!0})){let r=this.#l[t],i=this.#o[t],o=this.#d(i)?i.__staleWhileFetching:i;if(o===void 0||r===void 0)continue;let n={value:o};if(this.#_&&this.#k){n.ttl=this.#_[t];let a=yi.now()-this.#k[t];n.start=Math.floor(Date.now()-a)}this.#E&&(n.size=this.#E[t]),e.unshift([r,n])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let i=Date.now()-r.start;r.start=yi.now()-i}this.set(t,r.value,r)}}set(e,t,r={}){if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=r,{noUpdateTTL:l=this.noUpdateTTL}=r,d=this.#B(e,t,r.size||0,a);if(this.maxEntrySize&&d>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#q(e,"set"),this;let p=this.#a===0?void 0:this.#c.get(e);if(p===void 0)p=this.#a===0?this.#f:this.#S.length!==0?this.#S.pop():this.#a===this.#e?this.#D(!1):this.#a,this.#l[p]=e,this.#o[p]=t,this.#c.set(e,p),this.#x[this.#f]=p,this.#w[p]=this.#f,this.#f=p,this.#a++,this.#j(p,d,c),c&&(c.set="add"),l=!1,this.#P&&this.#r?.(t,e,"add");else{this.#L(p);let u=this.#o[p];if(t!==u){if(this.#v&&this.#d(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=u;m!==void 0&&!n&&(this.#b&&this.#t?.(m,e,"set"),this.#h&&this.#m?.push([m,e,"set"]))}else n||(this.#b&&this.#t?.(u,e,"set"),this.#h&&this.#m?.push([u,e,"set"]));if(this.#O(p),this.#j(p,d,c),this.#o[p]=t,c){c.set="replace";let m=u&&this.#d(u)?u.__staleWhileFetching:u;m!==void 0&&(c.oldValue=m)}}else c&&(c.set="update");this.#P&&this.onInsert?.(t,e,t===u?"update":"replace")}if(i!==0&&!this.#_&&this.#n(),this.#_&&(l||this.#C(p,i,o),c&&this.#T(c,p)),!n&&this.#h&&this.#m){let u=this.#m,m;for(;m=u?.shift();)this.#i?.(...m)}return this}pop(){try{for(;this.#a;){let e=this.#o[this.#y];if(this.#D(!0),this.#d(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#h&&this.#m){let e=this.#m,t;for(;t=e?.shift();)this.#i?.(...t)}}}#D(e){let t=this.#y,r=this.#l[t],i=this.#o[t];return this.#v&&this.#d(i)?i.__abortController.abort(new Error("evicted")):(this.#b||this.#h)&&(this.#b&&this.#t?.(i,r,"evict"),this.#h&&this.#m?.push([i,r,"evict"])),this.#O(t),e&&(this.#l[t]=void 0,this.#o[t]=void 0,this.#S.push(t)),this.#a===1?(this.#y=this.#f=0,this.#S.length=0):this.#y=this.#x[t],this.#c.delete(r),this.#a--,t}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=t,o=this.#c.get(e);if(o!==void 0){let n=this.#o[o];if(this.#d(n)&&n.__staleWhileFetching===void 0)return!1;if(this.#$(o))i&&(i.has="stale",this.#T(i,o));else return r&&this.#N(o),i&&(i.has="hit",this.#T(i,o)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){let{allowStale:r=this.allowStale}=t,i=this.#c.get(e);if(i===void 0||!r&&this.#$(i))return;let o=this.#o[i];return this.#d(o)?o.__staleWhileFetching:o}#I(e,t,r,i){let o=t===void 0?void 0:this.#o[t];if(this.#d(o))return o;let n=new Nc,{signal:a}=r;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let c={signal:n.signal,options:r,context:i},l=(f,g=!1)=>{let{aborted:b}=n.signal,x=r.ignoreFetchAbort&&f!==void 0;if(r.status&&(b&&!g?(r.status.fetchAborted=!0,r.status.fetchError=n.signal.reason,x&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),b&&!x&&!g)return p(n.signal.reason);let y=m;return this.#o[t]===m&&(f===void 0?y.__staleWhileFetching?this.#o[t]=y.__staleWhileFetching:this.#q(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,f,c.options))),f},d=f=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=f),p(f)),p=f=>{let{aborted:g}=n.signal,b=g&&r.allowStaleOnFetchAbort,x=b||r.allowStaleOnFetchRejection,y=x||r.noDeleteOnFetchRejection,_=m;if(this.#o[t]===m&&(!y||_.__staleWhileFetching===void 0?this.#q(e,"fetch"):b||(this.#o[t]=_.__staleWhileFetching)),x)return r.status&&_.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),_.__staleWhileFetching;if(_.__returned===_)throw f},u=(f,g)=>{let b=this.#g?.(e,o,c);b&&b instanceof Promise&&b.then(x=>f(x===void 0?void 0:x),g),n.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(f(void 0),r.allowStaleOnFetchAbort&&(f=x=>l(x,!0)))})};r.status&&(r.status.fetchDispatched=!0);let m=new Promise(u).then(l,d),h=Object.assign(m,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return t===void 0?(this.set(e,h,{...c.options,status:void 0}),t=this.#c.get(e)):this.#o[t]=h,h}#d(e){if(!this.#v)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Nc}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:f,forceRefresh:g=!1,status:b,signal:x}=t;if(!this.#v)return b&&(b.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:b});let y={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:c,sizeCalculation:l,noUpdateTTL:d,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:h,ignoreFetchAbort:m,status:b,signal:x},_=this.#c.get(e);if(_===void 0){b&&(b.fetch="miss");let k=this.#I(e,_,y,f);return k.__returned=k}else{let k=this.#o[_];if(this.#d(k)){let P=r&&k.__staleWhileFetching!==void 0;return b&&(b.fetch="inflight",P&&(b.returnedStale=!0)),P?k.__staleWhileFetching:k.__returned=k}let S=this.#$(_);if(!g&&!S)return b&&(b.fetch="hit"),this.#L(_),i&&this.#N(_),b&&this.#T(b,_),k;let T=this.#I(e,_,y,f),v=T.__staleWhileFetching!==void 0&&r;return b&&(b.fetch=S?"stale":"refresh",v&&S&&(b.returnedStale=!0)),v?T.__staleWhileFetching:T.__returned=T}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let r=this.#u;if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:o,...n}=t,a=this.get(e,n);if(!o&&a!==void 0)return a;let c=r(e,a,{options:n,context:i});return this.set(e,c,n),c}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=t,a=this.#c.get(e);if(a!==void 0){let c=this.#o[a],l=this.#d(c);return n&&this.#T(n,a),this.#$(a)?(n&&(n.get="stale"),l?(n&&r&&c.__staleWhileFetching!==void 0&&(n.returnedStale=!0),r?c.__staleWhileFetching:void 0):(o||this.#q(e,"expire"),n&&r&&(n.returnedStale=!0),r?c:void 0)):(n&&(n.get="hit"),l?c.__staleWhileFetching:(this.#L(a),i&&this.#N(a),c))}else n&&(n.get="miss")}#U(e,t){this.#w[t]=e,this.#x[e]=t}#L(e){e!==this.#f&&(e===this.#y?this.#y=this.#x[e]:this.#U(this.#w[e],this.#x[e]),this.#U(this.#f,e),this.#f=e)}delete(e){return this.#q(e,"delete")}#q(e,t){let r=!1;if(this.#a!==0){let i=this.#c.get(e);if(i!==void 0)if(r=!0,this.#a===1)this.#F(t);else{this.#O(i);let o=this.#o[i];if(this.#d(o)?o.__abortController.abort(new Error("deleted")):(this.#b||this.#h)&&(this.#b&&this.#t?.(o,e,t),this.#h&&this.#m?.push([o,e,t])),this.#c.delete(e),this.#l[i]=void 0,this.#o[i]=void 0,i===this.#f)this.#f=this.#w[i];else if(i===this.#y)this.#y=this.#x[i];else{let n=this.#w[i];this.#x[n]=this.#x[i];let a=this.#x[i];this.#w[a]=this.#w[i]}this.#a--,this.#S.push(i)}}if(this.#h&&this.#m?.length){let i=this.#m,o;for(;o=i?.shift();)this.#i?.(...o)}return r}clear(){return this.#F("delete")}#F(e){for(let t of this.#A({allowStale:!0})){let r=this.#o[t];if(this.#d(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#l[t];this.#b&&this.#t?.(r,i,e),this.#h&&this.#m?.push([r,i,e])}}if(this.#c.clear(),this.#o.fill(void 0),this.#l.fill(void 0),this.#_&&this.#k&&(this.#_.fill(0),this.#k.fill(0)),this.#E&&this.#E.fill(0),this.#y=0,this.#f=0,this.#S.length=0,this.#p=0,this.#a=0,this.#h&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#i?.(...r)}}};var vi=require("node:path"),Mw=require("node:url"),Vt=require("fs"),ZO=O(require("node:fs"),1),Fs=require("node:fs/promises");var Wc=require("node:events"),Tf=O(require("node:stream"),1),Dw=require("node:string_decoder"),Nw=typeof process=="object"&&process?process:{stdout:null,stderr:null},GO=s=>!!s&&typeof s=="object"&&(s instanceof Ls||s instanceof Tf.default||zO(s)||VO(s)),zO=s=>!!s&&typeof s=="object"&&s instanceof Wc.EventEmitter&&typeof s.pipe=="function"&&s.pipe!==Tf.default.Writable.prototype.pipe,VO=s=>!!s&&typeof s=="object"&&s instanceof Wc.EventEmitter&&typeof s.write=="function"&&typeof s.end=="function",as=Symbol("EOF"),cs=Symbol("maybeEmitEnd"),Ds=Symbol("emittedEnd"),Oc=Symbol("emittingEnd"),en=Symbol("emittedError"),Ic=Symbol("closed"),Ow=Symbol("read"),jc=Symbol("flush"),Iw=Symbol("flushChunk"),Ct=Symbol("encoding"),ki=Symbol("decoder"),_e=Symbol("flowing"),tn=Symbol("paused"),wi=Symbol("resume"),ke=Symbol("buffer"),Ie=Symbol("pipes"),we=Symbol("bufferLength"),_f=Symbol("bufferPush"),Dc=Symbol("bufferShift"),Re=Symbol("objectMode"),ne=Symbol("destroyed"),kf=Symbol("error"),wf=Symbol("emitData"),jw=Symbol("emitEnd"),vf=Symbol("emitEnd2"),Gt=Symbol("async"),Sf=Symbol("abort"),Lc=Symbol("aborted"),sn=Symbol("signal"),br=Symbol("dataListeners"),Xe=Symbol("discarded"),rn=s=>Promise.resolve().then(s),HO=s=>s(),KO=s=>s==="end"||s==="finish"||s==="prefinish",JO=s=>s instanceof ArrayBuffer||!!s&&typeof s=="object"&&s.constructor&&s.constructor.name==="ArrayBuffer"&&s.byteLength>=0,YO=s=>!Buffer.isBuffer(s)&&ArrayBuffer.isView(s),Fc=class{src;dest;opts;ondrain;constructor(e,t,r){this.src=e,this.dest=t,this.opts=r,this.ondrain=()=>e[wi](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ef=class extends Fc{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,r){super(e,t,r),this.proxyErrors=i=>this.dest.emit("error",i),e.on("error",this.proxyErrors)}},QO=s=>!!s.objectMode,XO=s=>!s.objectMode&&!!s.encoding&&s.encoding!=="buffer",Ls=class extends Wc.EventEmitter{[_e]=!1;[tn]=!1;[Ie]=[];[ke]=[];[Re];[Ct];[Gt];[ki];[as]=!1;[Ds]=!1;[Oc]=!1;[Ic]=!1;[en]=null;[we]=0;[ne]=!1;[sn];[Lc]=!1;[br]=0;[Xe]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");QO(t)?(this[Re]=!0,this[Ct]=null):XO(t)?(this[Ct]=t.encoding,this[Re]=!1):(this[Re]=!1,this[Ct]=null),this[Gt]=!!t.async,this[ki]=this[Ct]?new Dw.StringDecoder(this[Ct]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ke]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ie]});let{signal:r}=t;r&&(this[sn]=r,r.aborted?this[Sf]():r.addEventListener("abort",()=>this[Sf]()))}get bufferLength(){return this[we]}get encoding(){return this[Ct]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Re]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Gt]}set async(e){this[Gt]=this[Gt]||!!e}[Sf](){this[Lc]=!0,this.emit("abort",this[sn]?.reason),this.destroy(this[sn]?.reason)}get aborted(){return this[Lc]}set aborted(e){}write(e,t,r){if(this[Lc])return!1;if(this[as])throw new Error("write after end");if(this[ne])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(r=t,t="utf8"),t||(t="utf8");let i=this[Gt]?rn:HO;if(!this[Re]&&!Buffer.isBuffer(e)){if(YO(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(JO(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Re]?(this[_e]&&this[we]!==0&&this[jc](!0),this[_e]?this.emit("data",e):this[_f](e),this[we]!==0&&this.emit("readable"),r&&i(r),this[_e]):e.length?(typeof e=="string"&&!(t===this[Ct]&&!this[ki]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Ct]&&(e=this[ki].write(e)),this[_e]&&this[we]!==0&&this[jc](!0),this[_e]?this.emit("data",e):this[_f](e),this[we]!==0&&this.emit("readable"),r&&i(r),this[_e]):(this[we]!==0&&this.emit("readable"),r&&i(r),this[_e])}read(e){if(this[ne])return null;if(this[Xe]=!1,this[we]===0||e===0||e&&e>this[we])return this[cs](),null;this[Re]&&(e=null),this[ke].length>1&&!this[Re]&&(this[ke]=[this[Ct]?this[ke].join(""):Buffer.concat(this[ke],this[we])]);let t=this[Ow](e||null,this[ke][0]);return this[cs](),t}[Ow](e,t){if(this[Re])this[Dc]();else{let r=t;e===r.length||e===null?this[Dc]():typeof r=="string"?(this[ke][0]=r.slice(e),t=r.slice(0,e),this[we]-=e):(this[ke][0]=r.subarray(e),t=r.subarray(0,e),this[we]-=e)}return this.emit("data",t),!this[ke].length&&!this[as]&&this.emit("drain"),t}end(e,t,r){return typeof e=="function"&&(r=e,e=void 0),typeof t=="function"&&(r=t,t="utf8"),e!==void 0&&this.write(e,t),r&&this.once("end",r),this[as]=!0,this.writable=!1,(this[_e]||!this[tn])&&this[cs](),this}[wi](){this[ne]||(!this[br]&&!this[Ie].length&&(this[Xe]=!0),this[tn]=!1,this[_e]=!0,this.emit("resume"),this[ke].length?this[jc]():this[as]?this[cs]():this.emit("drain"))}resume(){return this[wi]()}pause(){this[_e]=!1,this[tn]=!0,this[Xe]=!1}get destroyed(){return this[ne]}get flowing(){return this[_e]}get paused(){return this[tn]}[_f](e){this[Re]?this[we]+=1:this[we]+=e.length,this[ke].push(e)}[Dc](){return this[Re]?this[we]-=1:this[we]-=this[ke][0].length,this[ke].shift()}[jc](e=!1){do;while(this[Iw](this[Dc]())&&this[ke].length);!e&&!this[ke].length&&!this[as]&&this.emit("drain")}[Iw](e){return this.emit("data",e),this[_e]}pipe(e,t){if(this[ne])return e;this[Xe]=!1;let r=this[Ds];return t=t||{},e===Nw.stdout||e===Nw.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,r?t.end&&e.end():(this[Ie].push(t.proxyErrors?new Ef(this,e,t):new Fc(this,e,t)),this[Gt]?rn(()=>this[wi]()):this[wi]()),e}unpipe(e){let t=this[Ie].find(r=>r.dest===e);t&&(this[Ie].length===1?(this[_e]&&this[br]===0&&(this[_e]=!1),this[Ie]=[]):this[Ie].splice(this[Ie].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let r=super.on(e,t);if(e==="data")this[Xe]=!1,this[br]++,!this[Ie].length&&!this[_e]&&this[wi]();else if(e==="readable"&&this[we]!==0)super.emit("readable");else if(KO(e)&&this[Ds])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[en]){let i=t;this[Gt]?rn(()=>i.call(this,this[en])):i.call(this,this[en])}return r}removeListener(e,t){return this.off(e,t)}off(e,t){let r=super.off(e,t);return e==="data"&&(this[br]=this.listeners("data").length,this[br]===0&&!this[Xe]&&!this[Ie].length&&(this[_e]=!1)),r}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[br]=0,!this[Xe]&&!this[Ie].length&&(this[_e]=!1)),t}get emittedEnd(){return this[Ds]}[cs](){!this[Oc]&&!this[Ds]&&!this[ne]&&this[ke].length===0&&this[as]&&(this[Oc]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ic]&&this.emit("close"),this[Oc]=!1)}emit(e,...t){let r=t[0];if(e!=="error"&&e!=="close"&&e!==ne&&this[ne])return!1;if(e==="data")return!this[Re]&&!r?!1:this[Gt]?(rn(()=>this[wf](r)),!0):this[wf](r);if(e==="end")return this[jw]();if(e==="close"){if(this[Ic]=!0,!this[Ds]&&!this[ne])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(e==="error"){this[en]=r,super.emit(kf,r);let o=!this[sn]||this.listeners("error").length?super.emit("error",r):!1;return this[cs](),o}else if(e==="resume"){let o=super.emit("resume");return this[cs](),o}else if(e==="finish"||e==="prefinish"){let o=super.emit(e);return this.removeAllListeners(e),o}let i=super.emit(e,...t);return this[cs](),i}[wf](e){for(let r of this[Ie])r.dest.write(e)===!1&&this.pause();let t=this[Xe]?!1:super.emit("data",e);return this[cs](),t}[jw](){return this[Ds]?!1:(this[Ds]=!0,this.readable=!1,this[Gt]?(rn(()=>this[vf]()),!0):this[vf]())}[vf](){if(this[ki]){let t=this[ki].end();if(t){for(let r of this[Ie])r.dest.write(t);this[Xe]||super.emit("data",t)}}for(let t of this[Ie])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[Re]||(e.dataLength=0);let t=this.promise();return this.on("data",r=>{e.push(r),this[Re]||(e.dataLength+=r.length)}),await t,e}async concat(){if(this[Re])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Ct]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(ne,()=>t(new Error("stream destroyed"))),this.on("error",r=>t(r)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Xe]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[as])return t();let o,n,a=p=>{this.off("data",c),this.off("end",l),this.off(ne,d),t(),n(p)},c=p=>{this.off("error",a),this.off("end",l),this.off(ne,d),this.pause(),o({value:p,done:!!this[as]})},l=()=>{this.off("error",a),this.off("data",c),this.off(ne,d),t(),o({done:!0,value:void 0})},d=()=>a(new Error("stream destroyed"));return new Promise((p,u)=>{n=u,o=p,this.once(ne,d),this.once("error",a),this.once("end",l),this.once("data",c)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Xe]=!1;let e=!1,t=()=>(this.pause(),this.off(kf,t),this.off(ne,t),this.off("end",t),e=!0,{done:!0,value:void 0}),r=()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}};return this.once("end",t),this.once(kf,t),this.once(ne,t),{next:r,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[ne])return e?this.emit("error",e):this.emit(ne),this;this[ne]=!0,this[Xe]=!0,this[ke].length=0,this[we]=0;let t=this;return typeof t.close=="function"&&!this[Ic]&&t.close(),e?this.emit("error",e):this.emit(ne),this}static get isStream(){return GO}};var eI=Vt.realpathSync.native,nn={lstatSync:Vt.lstatSync,readdir:Vt.readdir,readdirSync:Vt.readdirSync,readlinkSync:Vt.readlinkSync,realpathSync:eI,promises:{lstat:Fs.lstat,readdir:Fs.readdir,readlink:Fs.readlink,realpath:Fs.realpath}},Uw=s=>!s||s===nn||s===ZO?nn:{...nn,...s,promises:{...nn.promises,...s.promises||{}}},Gw=/^\\\\\?\\([a-z]:)\\?$/i,tI=s=>s.replace(/\//g,"\\").replace(Gw,"$1\\"),sI=/[\\\/]/,ut=0,zw=1,Vw=2,zt=4,Hw=6,Kw=8,xr=10,Jw=12,dt=15,on=~dt,$f=16,Lw=32,an=64,qt=128,Bc=256,Uc=512,Fw=an|qt|Uc,rI=1023,Rf=s=>s.isFile()?Kw:s.isDirectory()?zt:s.isSymbolicLink()?xr:s.isCharacterDevice()?Vw:s.isBlockDevice()?Hw:s.isSocket()?Jw:s.isFIFO()?zw:ut,Ww=new gr({max:2**12}),cn=s=>{let e=Ww.get(s);if(e)return e;let t=s.normalize("NFKD");return Ww.set(s,t),t},Bw=new gr({max:2**12}),Mc=s=>{let e=Bw.get(s);if(e)return e;let t=cn(s.toLowerCase());return Bw.set(s,t),t},Gc=class extends gr{constructor(){super({max:256})}},Af=class extends gr{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1})}},Yw=Symbol("PathScurry setAsCwd"),Ae=class{name;root;roots;parent;nocase;isCWD=!1;#e;#s;get dev(){return this.#s}#t;get mode(){return this.#t}#r;get nlink(){return this.#r}#i;get uid(){return this.#i}#g;get gid(){return this.#g}#u;get rdev(){return this.#u}#a;get blksize(){return this.#a}#p;get ino(){return this.#p}#c;get size(){return this.#c}#l;get blocks(){return this.#l}#o;get atimeMs(){return this.#o}#x;get mtimeMs(){return this.#x}#w;get ctimeMs(){return this.#w}#y;get birthtimeMs(){return this.#y}#f;get atime(){return this.#f}#S;get mtime(){return this.#S}#m;get ctime(){return this.#m}#E;get birthtime(){return this.#E}#k;#_;#b;#v;#h;#P;#n;#N;#T;#C;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=ut,r,i,o,n,a){this.name=e,this.#k=o?Mc(e):cn(e),this.#n=t&rI,this.nocase=o,this.roots=i,this.root=r||this,this.#N=n,this.#b=a.fullpath,this.#h=a.relative,this.#P=a.relativePosix,this.parent=a.parent,this.parent?this.#e=this.parent.#e:this.#e=Uw(a.fs)}depth(){return this.#_!==void 0?this.#_:this.parent?this.#_=this.parent.depth()+1:this.#_=0}childrenCache(){return this.#N}resolve(e){if(!e)return this;let t=this.getRootString(e),i=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#$(i):this.#$(i)}#$(e){let t=this;for(let r of e)t=t.child(r);return t}children(){let e=this.#N.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#N.set(this,t),this.#n&=~$f,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let r=this.children(),i=this.nocase?Mc(e):cn(e);for(let c of r)if(c.#k===i)return c;let o=this.parent?this.sep:"",n=this.#b?this.#b+o+e:void 0,a=this.newChild(e,ut,{...t,parent:this,fullpath:n});return this.canReaddir()||(a.#n|=qt),r.push(a),a}relative(){if(this.isCWD)return"";if(this.#h!==void 0)return this.#h;let e=this.name,t=this.parent;if(!t)return this.#h=this.name;let r=t.relative();return r+(!r||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#P!==void 0)return this.#P;let e=this.name,t=this.parent;if(!t)return this.#P=this.fullpathPosix();let r=t.relativePosix();return r+(!r||!t.parent?"":"/")+e}fullpath(){if(this.#b!==void 0)return this.#b;let e=this.name,t=this.parent;if(!t)return this.#b=this.name;let i=t.fullpath()+(t.parent?this.sep:"")+e;return this.#b=i}fullpathPosix(){if(this.#v!==void 0)return this.#v;if(this.sep==="/")return this.#v=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#v=`//?/${i}`:this.#v=i}let e=this.parent,t=e.fullpathPosix(),r=t+(!t||!e.parent?"":"/")+this.name;return this.#v=r}isUnknown(){return(this.#n&dt)===ut}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#n&dt)===Kw}isDirectory(){return(this.#n&dt)===zt}isCharacterDevice(){return(this.#n&dt)===Vw}isBlockDevice(){return(this.#n&dt)===Hw}isFIFO(){return(this.#n&dt)===zw}isSocket(){return(this.#n&dt)===Jw}isSymbolicLink(){return(this.#n&xr)===xr}lstatCached(){return this.#n&Lw?this:void 0}readlinkCached(){return this.#T}realpathCached(){return this.#C}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#T)return!0;if(!this.parent)return!1;let e=this.#n&dt;return!(e!==ut&&e!==xr||this.#n&Bc||this.#n&qt)}calledReaddir(){return!!(this.#n&$f)}isENOENT(){return!!(this.#n&qt)}isNamed(e){return this.nocase?this.#k===Mc(e):this.#k===cn(e)}async readlink(){let e=this.#T;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),r=(await this.parent.realpath())?.resolve(t);if(r)return this.#T=r}catch(t){this.#D(t.code);return}}readlinkSync(){let e=this.#T;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),r=this.parent.realpathSync()?.resolve(t);if(r)return this.#T=r}catch(t){this.#D(t.code);return}}#W(e){this.#n|=$f;for(let t=e.provisional;t<e.length;t++){let r=e[t];r&&r.#O()}}#O(){this.#n&qt||(this.#n=(this.#n|qt)&on,this.#j())}#j(){let e=this.children();e.provisional=0;for(let t of e)t.#O()}#B(){this.#n|=Uc,this.#R()}#R(){if(this.#n&an)return;let e=this.#n;(e&dt)===zt&&(e&=on),this.#n=e|an,this.#j()}#A(e=""){e==="ENOTDIR"||e==="EPERM"?this.#R():e==="ENOENT"?this.#O():this.children().provisional=0}#M(e=""){e==="ENOTDIR"?this.parent.#R():e==="ENOENT"&&this.#O()}#D(e=""){let t=this.#n;t|=Bc,e==="ENOENT"&&(t|=qt),(e==="EINVAL"||e==="UNKNOWN")&&(t&=on),this.#n=t,e==="ENOTDIR"&&this.parent&&this.parent.#R()}#I(e,t){return this.#U(e,t)||this.#d(e,t)}#d(e,t){let r=Rf(e),i=this.newChild(e.name,r,{parent:this}),o=i.#n&dt;return o!==zt&&o!==xr&&o!==ut&&(i.#n|=an),t.unshift(i),t.provisional++,i}#U(e,t){for(let r=t.provisional;r<t.length;r++){let i=t[r];if((this.nocase?Mc(e.name):cn(e.name))===i.#k)return this.#L(e,i,r,t)}}#L(e,t,r,i){let o=t.name;return t.#n=t.#n&on|Rf(e),o!==e.name&&(t.name=e.name),r!==i.provisional&&(r===i.length-1?i.pop():i.splice(r,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#n&qt)===0)try{return this.#q(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#M(e.code)}}lstatSync(){if((this.#n&qt)===0)try{return this.#q(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#M(e.code)}}#q(e){let{atime:t,atimeMs:r,birthtime:i,birthtimeMs:o,blksize:n,blocks:a,ctime:c,ctimeMs:l,dev:d,gid:p,ino:u,mode:m,mtime:h,mtimeMs:f,nlink:g,rdev:b,size:x,uid:y}=e;this.#f=t,this.#o=r,this.#E=i,this.#y=o,this.#a=n,this.#l=a,this.#m=c,this.#w=l,this.#s=d,this.#g=p,this.#p=u,this.#t=m,this.#S=h,this.#x=f,this.#r=g,this.#u=b,this.#c=x,this.#i=y;let _=Rf(e);this.#n=this.#n&on|_|Lw,_!==ut&&_!==zt&&_!==xr&&(this.#n|=an)}#F=[];#z=!1;#V(e){this.#z=!1;let t=this.#F.slice();this.#F.length=0,t.forEach(r=>r(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let r=this.children();if(this.calledReaddir()){let o=r.slice(0,r.provisional);t?e(null,o):queueMicrotask(()=>e(null,o));return}if(this.#F.push(e),this.#z)return;this.#z=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(o,n)=>{if(o)this.#A(o.code),r.provisional=0;else{for(let a of n)this.#I(a,r);this.#W(r)}this.#V(r.slice(0,r.provisional))})}#G;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#G)await this.#G;else{let r=()=>{};this.#G=new Promise(i=>r=i);try{for(let i of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#I(i,e);this.#W(e)}catch(i){this.#A(i.code),e.provisional=0}this.#G=void 0,r()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let r of this.#e.readdirSync(t,{withFileTypes:!0}))this.#I(r,e);this.#W(e)}catch(r){this.#A(r.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#n&Fw)return!1;let e=dt&this.#n;return e===ut||e===zt||e===xr}shouldWalk(e,t){return(this.#n&zt)===zt&&!(this.#n&Fw)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#C)return this.#C;if(!((Uc|Bc|qt)&this.#n))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#C=this.resolve(e)}catch{this.#B()}}realpathSync(){if(this.#C)return this.#C;if(!((Uc|Bc|qt)&this.#n))try{let e=this.#e.realpathSync(this.fullpath());return this.#C=this.resolve(e)}catch{this.#B()}}[Yw](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),r=[],i=this;for(;i&&i.parent;)t.add(i),i.#h=r.join(this.sep),i.#P=r.join("/"),i=i.parent,r.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#h=void 0,i.#P=void 0,i=i.parent}},zc=class s extends Ae{sep="\\";splitSep=sI;constructor(e,t=ut,r,i,o,n,a){super(e,t,r,i,o,n,a)}newChild(e,t=ut,r={}){return new s(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return vi.win32.parse(e).root}getRoot(e){if(e=tI(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,r]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=r;return this.roots[e]=new Si(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(Gw,"$1\\"),e===t}},Vc=class s extends Ae{splitSep="/";sep="/";constructor(e,t=ut,r,i,o,n,a){super(e,t,r,i,o,n,a)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=ut,r={}){return new s(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Hc=class{root;rootPath;roots;cwd;#e;#s;#t;nocase;#r;constructor(e=process.cwd(),t,r,{nocase:i,childrenCacheSize:o=16*1024,fs:n=nn}={}){this.#r=Uw(n),(e instanceof URL||e.startsWith("file://"))&&(e=(0,Mw.fileURLToPath)(e));let a=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#e=new Gc,this.#s=new Gc,this.#t=new Af(o);let c=a.substring(this.rootPath.length).split(r);if(c.length===1&&!c[0]&&c.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let l=this.root,d=c.length-1,p=t.sep,u=this.rootPath,m=!1;for(let h of c){let f=d--;l=l.child(h,{relative:new Array(f).fill("..").join(p),relativePosix:new Array(f).fill("..").join("/"),fullpath:u+=(m?"":p)+h}),m=!0}this.cwd=l}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#t}resolve(...e){let t="";for(let o=e.length-1;o>=0;o--){let n=e[o];if(!(!n||n===".")&&(t=t?`${n}/${t}`:n,this.isAbsolute(n)))break}let r=this.#e.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpath();return this.#e.set(t,i),i}resolvePosix(...e){let t="";for(let o=e.length-1;o>=0;o--){let n=e[o];if(!(!n||n===".")&&(t=t?`${n}/${t}`:n,this.isAbsolute(n)))break}let r=this.#s.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpathPosix();return this.#s.set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r}=t;if(e.canReaddir()){let i=await e.readdir();return r?i:i.map(o=>o.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0}=t;return e.canReaddir()?r?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e.withFileTypes,e=this.cwd);let r=await e.readlink();return t?r:r?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e.withFileTypes,e=this.cwd);let r=e.readlinkSync();return t?r:r?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e.withFileTypes,e=this.cwd);let r=await e.realpath();return t?r:r?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e.withFileTypes,e=this.cwd);let r=e.realpathSync();return t?r:r?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t,a=[];(!o||o(e))&&a.push(r?e:e.fullpath());let c=new Set,l=(p,u)=>{c.add(p),p.readdirCB((m,h)=>{if(m)return u(m);let f=h.length;if(!f)return u();let g=()=>{--f===0&&u()};for(let b of h)(!o||o(b))&&a.push(r?b:b.fullpath()),i&&b.isSymbolicLink()?b.realpath().then(x=>x?.isUnknown()?x.lstat():x).then(x=>x?.shouldWalk(c,n)?l(x,g):g()):b.shouldWalk(c,n)?l(b,g):g()},!0)},d=e;return new Promise((p,u)=>{l(d,m=>{if(m)return u(m);p(a)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t,a=[];(!o||o(e))&&a.push(r?e:e.fullpath());let c=new Set([e]);for(let l of c){let d=l.readdirSync();for(let p of d){(!o||o(p))&&a.push(r?p:p.fullpath());let u=p;if(p.isSymbolicLink()){if(!(i&&(u=p.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(c,n)&&c.add(u)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t;(!o||o(e))&&(yield r?e:e.fullpath());let a=new Set([e]);for(let c of a){let l=c.readdirSync();for(let d of l){(!o||o(d))&&(yield r?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(i&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(a,n)&&a.add(p)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t,a=new Ls({objectMode:!0});(!o||o(e))&&a.write(r?e:e.fullpath());let c=new Set,l=[e],d=0,p=()=>{let u=!1;for(;!u;){let m=l.shift();if(!m){d===0&&a.end();return}d++,c.add(m);let h=(g,b,x=!1)=>{if(g)return a.emit("error",g);if(i&&!x){let y=[];for(let _ of b)_.isSymbolicLink()&&y.push(_.realpath().then(k=>k?.isUnknown()?k.lstat():k));if(y.length){Promise.all(y).then(()=>h(null,b,!0));return}}for(let y of b)y&&(!o||o(y))&&(a.write(r?y:y.fullpath())||(u=!0));d--;for(let y of b){let _=y.realpathCached()||y;_.shouldWalk(c,n)&&l.push(_)}u&&!a.flowing?a.once("drain",p):f||p()},f=!0;m.readdirCB(h,!0),f=!1}};return p(),a}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Ae||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:o,walkFilter:n}=t,a=new Ls({objectMode:!0}),c=new Set;(!o||o(e))&&a.write(r?e:e.fullpath());let l=[e],d=0,p=()=>{let u=!1;for(;!u;){let m=l.shift();if(!m){d===0&&a.end();return}d++,c.add(m);let h=m.readdirSync();for(let f of h)(!o||o(f))&&(a.write(r?f:f.fullpath())||(u=!0));d--;for(let f of h){let g=f;if(f.isSymbolicLink()){if(!(i&&(g=f.realpathSync())))continue;g.isUnknown()&&g.lstatSync()}g.shouldWalk(c,n)&&l.push(g)}}u&&!a.flowing&&a.once("drain",p)};return p(),a}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[Yw](t)}},Si=class extends Hc{sep="\\";constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,vi.win32,"\\",{...t,nocase:r}),this.nocase=r;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return vi.win32.parse(e).root.toUpperCase()}newRoot(e){return new zc(this.rootPath,zt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Ei=class extends Hc{sep="/";constructor(e=process.cwd(),t={}){let{nocase:r=!1}=t;super(e,vi.posix,"/",{...t,nocase:r}),this.nocase=r}parseRootPath(e){return"/"}newRoot(e){return new Vc(this.rootPath,zt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},ln=class extends Ei{constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,{...t,nocase:r})}},U7=process.platform==="win32"?zc:Vc,Qw=process.platform==="win32"?Si:process.platform==="darwin"?ln:Ei;var iI=s=>s.length>=1,oI=s=>s.length>=1,Ti=class s{#e;#s;#t;length;#r;#i;#g;#u;#a;#p;#c=!0;constructor(e,t,r,i){if(!iI(e))throw new TypeError("empty pattern list");if(!oI(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,r<0||r>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#s=t,this.#t=r,this.#r=i,this.#t===0){if(this.isUNC()){let[o,n,a,c,...l]=this.#e,[d,p,u,m,...h]=this.#s;l[0]===""&&(l.shift(),h.shift());let f=[o,n,a,c,""].join("/"),g=[d,p,u,m,""].join("/");this.#e=[f,...l],this.#s=[g,...h],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[o,...n]=this.#e,[a,...c]=this.#s;n[0]===""&&(n.shift(),c.shift());let l=o+"/",d=a+"/";this.#e=[l,...n],this.#s=[d,...c],this.length=this.#e.length}}}pattern(){return this.#e[this.#t]}isString(){return typeof this.#e[this.#t]=="string"}isGlobstar(){return this.#e[this.#t]===oe}isRegExp(){return this.#e[this.#t]instanceof RegExp}globString(){return this.#g=this.#g||(this.#t===0?this.isAbsolute()?this.#s[0]+this.#s.slice(1).join("/"):this.#s.join("/"):this.#s.slice(this.#t).join("/"))}hasMore(){return this.length>this.#t+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new s(this.#e,this.#s,this.#t+1,this.#r),this.#i.#p=this.#p,this.#i.#a=this.#a,this.#i.#u=this.#u,this.#i):this.#i=null}isUNC(){let e=this.#e;return this.#a!==void 0?this.#a:this.#a=this.#r==="win32"&&this.#t===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#u!==void 0?this.#u:this.#u=this.#r==="win32"&&this.#t===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#p!==void 0?this.#p:this.#p=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#t===0?e:""}checkFollowGlobstar(){return!(this.#t===0||!this.isGlobstar()||!this.#c)}markFollowGlobstar(){return this.#t===0||!this.isGlobstar()||!this.#c?!1:(this.#c=!1,!0)}};var nI=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",$i=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:r,noext:i,noglobstar:o,platform:n=nI}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=n,this.mmopts={dot:!0,nobrace:t,nocase:r,noext:i,noglobstar:o,optimizationLevel:2,platform:n,nocomment:!0,nonegate:!0};for(let a of e)this.add(a)}add(e){let t=new Qe(e,this.mmopts);for(let r=0;r<t.set.length;r++){let i=t.set[r],o=t.globParts[r];if(!i||!o)throw new Error("invalid pattern object");for(;i[0]==="."&&o[0]===".";)i.shift(),o.shift();let n=new Ti(i,o,0,this.platform),a=new Qe(n.globString(),this.mmopts),c=o[o.length-1]==="**",l=n.isAbsolute();l?this.absolute.push(a):this.relative.push(a),c&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(e){let t=e.fullpath(),r=`${t}/`,i=e.relative()||".",o=`${i}/`;for(let n of this.relative)if(n.match(i)||n.match(o))return!0;for(let n of this.absolute)if(n.match(t)||n.match(r))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",r=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(r))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}};var Pf=class s{store;constructor(e=new Map){this.store=e}copy(){return new s(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let r=e.fullpath(),i=this.store.get(r);i?i.add(t.globString()):this.store.set(r,new Set([t.globString()]))}},Cf=class{store=new Map;add(e,t,r){let i=(t?2:0)|(r?1:0),o=this.store.get(e);this.store.set(e,o===void 0?i:i&o)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},qf=class{store=new Map;add(e,t){if(!e.canReaddir())return;let r=this.store.get(e);r?r.find(i=>i.globString()===t.globString())||r.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},pn=class s{hasWalkedCache;matches=new Cf;subwalks=new qf;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new Pf}processPatterns(e,t){this.patterns=t;let r=t.map(i=>[e,i]);for(let[i,o]of r){this.hasWalkedCache.storeWalked(i,o);let n=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(n){i=i.resolve(n==="/"&&this.opts.root!==void 0?this.opts.root:n);let p=o.rest();if(p)o=p;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let c,l,d=!1;for(;typeof(c=o.pattern())=="string"&&(l=o.rest());)i=i.resolve(c),o=l,d=!0;if(c=o.pattern(),l=o.rest(),d){if(this.hasWalkedCache.hasWalked(i,o))continue;this.hasWalkedCache.storeWalked(i,o)}if(typeof c=="string"){let p=c===".."||c===""||c===".";this.matches.add(i.resolve(c),a,p);continue}else if(c===oe){(!i.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(i,o);let p=l?.pattern(),u=l?.rest();if(!l||(p===""||p===".")&&!u)this.matches.add(i,a,p===""||p===".");else if(p===".."){let m=i.parent||i;u?this.hasWalkedCache.hasWalked(m,u)||this.subwalks.add(m,u):this.matches.add(m,a,!0)}}else c instanceof RegExp&&this.subwalks.add(i,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new s(this.opts,this.hasWalkedCache)}filterEntries(e,t){let r=this.subwalks.get(e),i=this.child();for(let o of t)for(let n of r){let a=n.isAbsolute(),c=n.pattern(),l=n.rest();c===oe?i.testGlobstar(o,n,l,a):c instanceof RegExp?i.testRegExp(o,c,l,a):i.testString(o,c,l,a)}return i}testGlobstar(e,t,r,i){if((this.dot||!e.name.startsWith("."))&&(t.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(r&&t.checkFollowGlobstar()?this.subwalks.add(e,r):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),r){let o=r.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(e,o,r.rest(),i);else if(o===".."){let n=e.parent||e;this.subwalks.add(n,r)}else o instanceof RegExp&&this.testRegExp(e,o,r.rest(),i)}}testRegExp(e,t,r,i){t.test(e.name)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}testString(e,t,r,i){e.isNamed(t)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}};var aI=(s,e)=>typeof s=="string"?new $i([s],e):Array.isArray(s)?new $i(s,e):s,Kc=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#s;#t;signal;maxDepth;includeChildMatches;constructor(e,t,r){if(this.patterns=e,this.path=t,this.opts=r,this.#t=!r.posix&&r.platform==="win32"?"\\":"/",this.includeChildMatches=r.includeChildMatches!==!1,(r.ignore||!this.includeChildMatches)&&(this.#s=aI(r.ignore??[],r),!this.includeChildMatches&&typeof this.#s.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=r.maxDepth||1/0,r.signal&&(this.signal=r.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#r(e){return this.seen.has(e)||!!this.#s?.ignored?.(e)}#i(e){return!!this.#s?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||await e.realpath(),!r)return;e=r}let o=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let n=await o.realpath();n&&(n.isUnknown()||this.opts.stat)&&await n.lstat()}return this.matchCheckTest(o,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#r(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||e.realpathSync(),!r)return;e=r}let o=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let n=o.realpathSync();n&&(n?.isUnknown()||this.opts.stat)&&n.lstatSync()}return this.matchCheckTest(o,t)}matchFinish(e,t){if(this.#r(e))return;if(!this.includeChildMatches&&this.#s?.add){let o=`${e.relativePosix()}/**`;this.#s.add(o)}let r=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#t:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(r){let o=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(o+i)}else{let o=this.opts.posix?e.relativePosix():e.relative(),n=this.opts.dotRelative&&!o.startsWith(".."+this.#t)?"."+this.#t:"";this.matchEmit(o?n+o+i:"."+i)}}async match(e,t,r){let i=await this.matchCheck(e,r);i&&this.matchFinish(i,t)}matchSync(e,t,r){let i=this.matchCheckSync(e,r);i&&this.matchFinish(i,t)}walkCB(e,t,r){this.signal?.aborted&&r(),this.walkCB2(e,t,new pn(this.opts),r)}walkCB2(e,t,r,i){if(this.#i(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,r,i));return}r.processPatterns(e,t);let o=1,n=()=>{--o===0&&i()};for(let[a,c,l]of r.matches.entries())this.#r(a)||(o++,this.match(a,c,l).then(()=>n()));for(let a of r.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirCached();a.calledReaddir()?this.walkCB3(a,c,r,n):a.readdirCB((l,d)=>this.walkCB3(a,d,r,n),!0)}n()}walkCB3(e,t,r,i){r=r.filterEntries(e,t);let o=1,n=()=>{--o===0&&i()};for(let[a,c,l]of r.matches.entries())this.#r(a)||(o++,this.match(a,c,l).then(()=>n()));for(let[a,c]of r.subwalks.entries())o++,this.walkCB2(a,c,r.child(),n);n()}walkCBSync(e,t,r){this.signal?.aborted&&r(),this.walkCB2Sync(e,t,new pn(this.opts),r)}walkCB2Sync(e,t,r,i){if(this.#i(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,r,i));return}r.processPatterns(e,t);let o=1,n=()=>{--o===0&&i()};for(let[a,c,l]of r.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let a of r.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirSync();this.walkCB3Sync(a,c,r,n)}n()}walkCB3Sync(e,t,r,i){r=r.filterEntries(e,t);let o=1,n=()=>{--o===0&&i()};for(let[a,c,l]of r.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let[a,c]of r.subwalks.entries())o++,this.walkCB2Sync(a,c,r.child(),n);n()}},dn=class extends Kc{matches=new Set;constructor(e,t,r){super(e,t,r)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},un=class extends Kc{results;constructor(e,t,r){super(e,t,r),this.results=new Ls({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var cI=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Nt=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,Xw.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=e,this.platform=t.platform||cI,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=t.platform==="win32"?Si:t.platform==="darwin"?ln:t.platform?Ei:Qw;this.scurry=new c(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let r=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:r,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},o=this.pattern.map(c=>new Qe(c,i)),[n,a]=o.reduce((c,l)=>(c[0].push(...l.set),c[1].push(...l.globParts),c),[[],[]]);this.patterns=n.map((c,l)=>{let d=a[l];if(!d)throw new Error("invalid pattern object");return new Ti(c,d,0,this.platform)})}async walk(){return[...await new dn(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new dn(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new un(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new un(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var Nf=(s,e={})=>{Array.isArray(s)||(s=[s]);for(let t of s)if(new Qe(t,e).hasMagic())return!0;return!1};function Jc(s,e={}){return new Nt(s,e).streamSync()}function tv(s,e={}){return new Nt(s,e).stream()}function sv(s,e={}){return new Nt(s,e).walkSync()}async function Zw(s,e={}){return new Nt(s,e).walk()}function Yc(s,e={}){return new Nt(s,e).iterateSync()}function rv(s,e={}){return new Nt(s,e).iterate()}var lI=Jc,pI=Object.assign(tv,{sync:Jc}),dI=Yc,uI=Object.assign(rv,{sync:Yc}),Of=Object.assign(sv,{stream:Jc,iterate:Yc}),ev=Object.assign(Zw,{glob:Zw,globSync:sv,sync:Of,globStream:tv,stream:pI,globStreamSync:Jc,streamSync:lI,globIterate:rv,iterate:uI,globIterateSync:Yc,iterateSync:dI,Glob:Nt,hasMagic:Nf,escape:xi,unescape:Pt});ev.glob=ev;var Lh=class{debug=!1;log(e){this.debug&&console.error(e)}result(e){console.error(e)}error(e){console.error(e)}},R=new Lh,Qt=1,U=2,tt=3,I1=300;async function L1(s,e,t,r,i={}){let o=de.resolve(t),n=de.resolve(o,s);if(r.log(`Attempting to assemble workblock from: ${n} (identifier: ${s})`),!kt.existsSync(n))throw r.error(`Directory does not exist: ${n}`),new Error(`Directory does not exist: ${n}`);let a=await ri(n,r);if(!a)throw r.error(`Failed to assemble workblock from ${n}`),new Error(`Failed to assemble workblock from ${n}`);let c=JSON.stringify(a,null,2);r.log(`Submitting workblock from ${s} to ${e}...`);let l={"Content-Type":"application/json",...i},d=await fetch(e,{method:"POST",headers:l,body:c});if(d.ok){r.log(`Workblock from ${s} submitted successfully to ${e}. Status: ${d.status}`);let p=await d.text();p&&r.log(`Response: ${p}`)}else{r.error(`Failed to submit workblock from ${s}. Status: ${d.status}`);let p=await d.text();throw p&&r.error(`Error details: ${p}`),new Error(`Failed to submit workblock from ${s}. Status: ${d.status}`)}}async function F1(s,e,t,r,i){let o=de.resolve(e);i.log("Determining changed workblock directories..."),i.log(`Workspace: ${o}`),i.log(`Workblock Base Directory (relative to workspace): ${s}`);let n="";try{let u=`git diff --name-only "${t}" "${r}"`;i.log(`Running git diff: ${u} in ${o}`),n=(0,Li.execSync)(u,{cwd:o,encoding:"utf8"})}catch(u){let m=u instanceof Error?u.message:String(u);throw i.error(`Failed to run git diff: ${m}`),u&&typeof u=="object"&&"stderr"in u&&u.stderr&&i.error(`Git stderr: ${String(u.stderr)}`),new Error(`Failed to run git diff: ${m}`)}let a=n.split(`
14582
+ `).filter(u=>u.trim()!=="");if(i.log(`All changed files (${a.length}): ${a.join(", ")||"None"}`),a.length===0)return i.log("No files changed according to git diff."),[];let c=de.join(s,"**/{manifest.yaml,*manifest.yaml}");i.log(`Searching for manifest files with pattern: ${c} (relative to ${o})`);let l=Of(c,{cwd:o,nodir:!0,absolute:!0});if(i.log(`Found manifest files (${l.length}): ${l.join(", ")||"None"}`),l.length===0)return i.log("No manifest files found."),[];let d=new Set;for(let u of l){let m=de.dirname(u);i.log(`Potential workblock root (absolute): ${m}`);for(let h of a){let f=de.resolve(o,h);if(f.startsWith(m+de.sep)||f===m){let g=de.relative(o,m);d.add(g),i.log(`Found changed file '${h}' in workblock '${g}'. Adding to process list.`);break}}}let p=Array.from(d);return i.log(`Found ${p.length} changed workblock directories: ${p.join(", ")||"None"}`),p}H.name("wb-cli").description("CLI for working with Beyond Work workblocks").version("0.1.38").option("-d, --debug","Enable verbose debug logging").exitOverride(s=>process.exit(s.exitCode===0?0:U)).hook("preAction",s=>{R.debug=!!s.opts().debug});H.command("assemble <directory>").description("Assemble a workblock from a directory").option("-o, --output <file>","Output file (defaults to stdout)").action(async(s,e)=>{try{let t=de.resolve(s);kt.existsSync(t)||(R.error(`Directory does not exist: ${t}`),process.exit(1));let r=await ri(t,R);r||(R.error("Failed to assemble workblock"),process.exit(1));let i=JSON.stringify(r,null,2);if(e.output){let o=de.resolve(e.output);kt.writeFileSync(o,i),R.result(`Workblock written to ${o}`)}else process.stdout.write(i)}catch(t){let r=t instanceof Error?t.message:String(t);R.error(`Error: ${r}`),process.exit(1)}});H.command("split <manifest> <workblockDir>").description("Split a workblock manifest into files").action(async(s,e)=>{try{let t=de.resolve(s),r=de.resolve(e);kt.existsSync(t)||(R.error(`Manifest file does not exist: ${t}`),process.exit(1)),R.log(`Reading manifest from: ${t}`);let i=kt.readFileSync(t,"utf8"),o=(0,D1.parse)(i);o||(R.error("Failed to parse workblock from manifest"),process.exit(1)),R.log(`Splitting workblock into: ${r}`),await ii(r,o,{getBlob:async a=>a}),R.result(`Successfully split workblock into ${r}`)}catch(t){let r=t instanceof Error?t.message:String(t);R.error(`Error: ${r}`),process.exit(1)}});H.command("submit <directory> <url>").description("Assemble a workblock and POST it to a URL").option("-w, --workspace <path>","Workspace path, if directory is relative to it",".").option("-H, --header <header>","Add custom header in format 'Header-Name: value' (can be used multiple times)",(s,e=[])=>{let t=e;return t.push(s),t},[]).action(async(s,e,t)=>{try{let r={};for(let i of t.header){let o=i.indexOf(":");o===-1&&(R.error(`Invalid header format: ${i}. Expected 'Header-Name: value'`),process.exit(1));let n=i.substring(0,o).trim(),a=i.substring(o+1).trim();n||(R.error(`Invalid header format: ${i}. Header name cannot be empty`),process.exit(1)),r[n]=a}await L1(s,e,t.workspace,R,r)}catch(r){let i=r instanceof Error?r.message:String(r);R.error(`Error: ${i}`),process.exit(1)}});H.command("publish-changed-workblocks").description("Detects changed workblocks based on git diff and submits them. Optionally comments on a PR.").requiredOption("-u, --publish-url <url>","URL to publish/submit the workblocks to").requiredOption("-b, --workblock-base-dir <dir>","Base directory within the workspace where workblocks are located").option("-w, --workspace <path>","Path to the git workspace root",".").option("-t, --github-token <token>","GitHub token for PR commenting and API interactions").option("--git-diff-base <ref>","Base ref for git diff (e.g., HEAD^, origin/main)","HEAD^").option("--git-diff-head <ref>","Head ref for git diff","HEAD").action(async s=>{let{publishUrl:e,workblockBaseDir:t,workspace:r,githubToken:i,gitDiffBase:o,gitDiffHead:n}=s,{Octokit:a}=await Promise.resolve().then(()=>(eS(),Zv)),c;i&&(c=new a({auth:i}));let l=await F1(t,r,o,n,R),d,p,u;if(c){R.log("Attempting to determine PR information from the current commit...");try{let h=(0,Li.execSync)("git rev-parse HEAD",{cwd:r,encoding:"utf8"}).trim();R.log(`Current commit SHA: ${h}`);let f=(0,Li.execSync)("git remote get-url origin",{cwd:r,encoding:"utf8"}).trim();R.log(`Git remote origin URL: ${f}`);let g=f.split("/");if(g.length<2){R.log(`Could not parse owner/repo from git remote URL: '${f}'. Skipping PR interaction.`);return}let b=g[g.length-1];u=b.endsWith(".git")?b.slice(0,-4):b,p=g[g.length-2],R.log(`Inferred repository: ${p}/${u}`);let{data:x}=await c.rest.repos.listPullRequestsAssociatedWithCommit({owner:p,repo:u,commit_sha:h});if(x.length>0){let _=x.find(k=>k.state==="open")||x[0];d=_.number,R.log(`Found PR #${d} (state: ${_.state}) associated with commit ${h} in ${p}/${u}.`)}else R.log(`No PRs found associated with commit ${h} in ${p}/${u}.`)}catch(h){let f=h instanceof Error?h.message:String(h);R.error(`Error determining PR information: ${f}. Skipping PR interaction.`)}}if(l.length===0){R.log("No changed workblock directories (containing a manifest and changes) found.");return}R.log(`Found ${l.length} changed workblock directories to process: ${l.join(", ")}`);let m=!1;for(let h of l){R.log(`Processing directory: ${h}`);try{await L1(h,e,r,R,{}),R.log(`Successfully submitted workblock for directory: ${h}`)}catch(f){let g=f instanceof Error?f.message:String(f);R.error(`Failed to submit workblock for directory ${h}: ${g}`),m=!0}}if(d&&p&&u&&c&&l.length>0){R.log(`Attempting to comment on PR #${d} in repo ${p}/${u}`);let h="The following workblock directories were processed by `wb-cli publish-changed-workblocks`:\n";for(let f of l)h+=`- \`\`\`${f}\`\`\`
14374
14583
  `;m&&(h+=`
14375
14584
  Note: One or more submissions failed. Check logs for details.`);try{await c.rest.issues.createComment({owner:p,repo:u,issue_number:d,body:h}),R.log(`Successfully commented on PR #${d}.`)}catch(f){let g=f instanceof Error?f.message:String(f);R.error(`Failed to comment on PR #${d}: ${g}`),m=!0}}else l.length>0&&i&&R.log("Workblock directories were processed. PR commenting skipped: Could not automatically determine PR information, no relevant PR found for the current commit, or GitHub token was missing/invalid.");m?(R.error("One or more operations failed during 'publish-changed-workblocks'."),process.exit(1)):R.log("'publish-changed-workblocks' completed successfully.")});H.command("list-changed-workblocks").description("List workblock directories that have changes based on git diff").requiredOption("-b, --workblock-base-dir <dir>","Base directory within the workspace where workblocks are located").option("-w, --workspace <path>","Path to the git workspace root",".").option("--git-diff-base <ref>","Base ref for git diff (e.g., HEAD^, origin/main)","HEAD^").option("--git-diff-head <ref>","Head ref for git diff","HEAD").action(async s=>{let{workblockBaseDir:e,workspace:t,gitDiffBase:r,gitDiffHead:i}=s;try{let o=await F1(e,t,r,i,R);if(o.length===0){R.log("No changed workblock directories found.");return}process.stdout.write(o.join(`
14376
14585
  `)+`