@junobuild/cli-tools 0.7.0 → 0.7.1

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.
@@ -16,7 +16,7 @@ ${i}`,Ru=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Iu=Objec
16
16
  `),l=Zt(e);c===a&&n===l||(a=c,n=l,c=_i(c,l,{trim:!1,hard:!0,wordWrap:!1}),e.write(ai.eraseLines(t)+c),t=c.split(`
17
17
  `).length)};return o.clear=()=>{e.write(ai.eraseLines(t)),s()},o.done=()=>{s(),i||_t.show()},o}var ll,Zt,ml,dl,fl,hl,no=S(()=>{gs();Bs();Gt();eo();Ii();ll=24,Zt=({columns:e=80})=>e,ml=(e,i)=>{let t=e.rows??ll,n=i.split(`
18
18
  `),a=Math.max(0,n.length-t);return a?Vt(i,ye(n.slice(0,a).join(`
19
- `)).length+1):i};dl=Jt(io.stdout),fl=dl,hl=Jt(io.stderr)});function Xt(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var ao=S(()=>{});function vl(){let e=new Map;for(let[i,t]of Object.entries(R)){for(let[n,a]of Object.entries(t))R[n]={open:`\x1B[${a[0]}m`,close:`\x1B[${a[1]}m`},t[n]=R[n],e.set(a[0],a[1]);Object.defineProperty(R,i,{value:t,enumerable:!1})}return Object.defineProperty(R,"codes",{value:e,enumerable:!1}),R.color.close="\x1B[39m",R.bgColor.close="\x1B[49m",R.color.ansi=so(),R.color.ansi256=oo(),R.color.ansi16m=ro(),R.bgColor.ansi=so(10),R.bgColor.ansi256=oo(10),R.bgColor.ansi16m=ro(10),Object.defineProperties(R,{rgbToAnsi256:{value:(i,t,n)=>i===t&&t===n?i<8?16:i>248?231:Math.round((i-8)/247*24)+232:16+36*Math.round(i/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:i=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(i.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(s=>s+s).join(""));let a=Number.parseInt(n,16);return[a>>16&255,a>>8&255,a&255]},enumerable:!1},hexToAnsi256:{value:i=>R.rgbToAnsi256(...R.hexToRgb(i)),enumerable:!1},ansi256ToAnsi:{value:i=>{if(i<8)return 30+i;if(i<16)return 90+(i-8);let t,n,a;if(i>=232)t=((i-232)*10+8)/255,n=t,a=t;else{i-=16;let r=i%36;t=Math.floor(i/36)/5,n=Math.floor(r/6)/5,a=r%6/5}let s=Math.max(t,n,a)*2;if(s===0)return 30;let o=30+(Math.round(a)<<2|Math.round(n)<<1|Math.round(t));return s===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(i,t,n)=>R.ansi256ToAnsi(R.rgbToAnsi256(i,t,n)),enumerable:!1},hexToAnsi:{value:i=>R.ansi256ToAnsi(R.hexToAnsi256(i)),enumerable:!1}}),R}var so,oo,ro,R,h0,xl,gl,x0,Dl,Qt,co=S(()=>{so=(e=0)=>i=>`\x1B[${i+e}m`,oo=(e=0)=>i=>`\x1B[${38+e};5;${i}m`,ro=(e=0)=>(i,t,n)=>`\x1B[${38+e};2;${i};${t};${n}m`,R={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},h0=Object.keys(R.modifier),xl=Object.keys(R.color),gl=Object.keys(R.bgColor),x0=[...xl,...gl];Dl=vl(),Qt=Dl});function se(e,i,t){let n=[...e],a=[],s=typeof t=="number"?t:n.length,o=!1,r,c=0,l="";for(let[u,p]of n.entries()){let m=!1;if(uo.includes(p)){let d=/\d[^m]*/.exec(e.slice(u,u+18));r=d&&d.length>0?d[0]:void 0,c<s&&(o=!0,r!==void 0&&a.push(r))}else o&&p==="m"&&(o=!1,m=!0);if(!o&&!m&&c++,!bl.test(p)&&Xt(p.codePointAt())&&(c++,typeof t!="number"&&s++),c>i&&c<=s)l+=p;else if(c===i&&!o&&r!==void 0)l=po(a);else if(c>=s){l+=po(a,!0,r);break}}return l}var bl,uo,Mi,po,lo=S(()=>{ao();co();bl=/^[\uD800-\uDBFF][\uDC00-\uDFFF]$/,uo=["\x1B","\x9B"],Mi=e=>`${uo[0]}[${e}m`,po=(e,i,t)=>{let n=[];e=[...e];for(let a of e){let s=a;a.includes(";")&&(a=a.split(";")[0][0]+"0");let o=Qt.codes.get(Number.parseInt(a,10));if(o){let r=e.indexOf(o.toString());r===-1?n.push(Mi(i?o:s)):e.splice(r,1)}else if(i){n.push(Mi(0));break}else n.push(Mi(s))}if(i&&(n=n.filter((a,s)=>n.indexOf(a)===s),t!==void 0)){let a=Mi(Qt.codes.get(Number.parseInt(t,10)));n=n.reduce((s,o)=>o===a?[o,...s]:[...s,o],[])}return n.join("")}});var fo={};mi(fo,{default:()=>mo});function Ni(e,i,t){if(e.charAt(i)===" ")return i;let n=t?1:-1;for(let a=0;a<=3;a++){let s=i+a*n;if(e.charAt(s)===" ")return s}return i}function mo(e,i,t={}){let{position:n="end",space:a=!1,preferTruncationOnSpace:s=!1}=t,{truncationCharacter:o="\u2026"}=t;if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof i!="number")throw new TypeError(`Expected \`columns\` to be a number, got ${typeof i}`);if(i<1)return"";if(i===1)return o;let r=ie(e);if(r<=i)return e;if(n==="start"){if(s){let c=Ni(e,r-i+1,!0);return o+se(e,c,r).trim()}return a===!0&&(o+=" "),o+se(e,r-i+ie(o),r)}if(n==="middle"){a===!0&&(o=` ${o} `);let c=Math.floor(i/2);if(s){let l=Ni(e,c),u=Ni(e,r-(i-c)+1,!0);return se(e,0,l)+o+se(e,u,r).trim()}return se(e,0,c)+o+se(e,r-(i-c)+ie(o),r)}if(n==="end"){if(s){let c=Ni(e,i-1);return se(e,0,c)+o}return a===!0&&(o=` ${o}`),se(e,0,i-ie(o))+o}throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${n}`)}var ho=S(()=>{lo();Wt()});import{rm as Zo}from"node:fs/promises";var gm=async({infile:e,outfile:i,banner:t})=>{await Jo();let{build:n,version:a}=await import("esbuild");await Zo(i,{force:!0});let{metafile:s,errors:o,warnings:r}=await n({entryPoints:[e],outfile:i,bundle:!0,minify:!0,treeShaking:!0,format:"esm",platform:"browser",write:!0,supported:{"top-level-await":!1,"inline-script":!1},define:{self:"globalThis"},metafile:!0,banner:t});return{metafile:s,errors:o,warnings:r,version:a}},Jo=async()=>{try{await import("esbuild")}catch{console.error("Esbuild is required to build your functions. Please install it by running: npm i esbuild"),process.exit(1)}};import{nonNullish as om,toNullable as rm}from"@dfinity/utils";import cm from"ora";var vn="build",Dn=[],bn=[],le={pattern:"**/*.+(css|js|mjs|html)",mode:"both",algorithm:"gzip"},Fn=[".ds_store","thumbs.db"],qe=20,Qi="#dapp",wn="#_juno/releases";import{nonNullish as di}from"@dfinity/utils";import{spawn as An}from"child_process";import{nonNullish as Xo}from"@dfinity/utils";import{stat as Qo}from"node:fs/promises";import yn from"node:path";import En from"node:process";import{URL as er}from"node:url";var it=async(e,i,t)=>await ir(e,t)?[et(e),i.map(n=>sr(n)),{...t,shell:!0}]:[e,i,t],ir=async(e,{shell:i,cwd:t,env:n=En.env})=>En.platform==="win32"&&!i&&!await tr(e,t,n),tr=async(e,i,{Path:t="",PATH:n=t})=>Cn.some(a=>e.toLowerCase().endsWith(a))||(nr[`${e}\0${i}\0${n}`]??=await ar(e,i,n)),nr={},ar=async(e,i,t)=>{let n=t.split(yn.delimiter).filter(Boolean).map(a=>a.replace(/^"(.*)"$/,"$1"));try{await Promise.all(Cn.flatMap(a=>[i,...n].filter(Xo).map(s=>`${yn.resolve(s instanceof er?s.toString():s,e)}${a}`)).map(async a=>{try{await Qo(a)}catch{return}throw 0}))}catch{return!0}return!1},Cn=[".exe",".com"],sr=e=>et(et(`"${e.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),et=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");var Bm=async({command:e,cwd:i,args:t,env:n,stdout:a,silentOut:s=!1,silentErrors:o=!1})=>await new Promise(async(r,c)=>{let[l,u,p]=await it(e,t??[],{shell:!0,...di(i)&&{cwd:i},...di(n)&&{env:n}}),m=An(l,u,p);m.stdout.on("data",d=>{if(di(a)){a(`${d}`);return}s||console.log(`${d}`)}),m.stderr.on("data",d=>{o||c(new Error(`${d}`))}),m.on("close",d=>{r(d)}),m.on("error",d=>{c(d)})}),kn=async({command:e,args:i,env:t})=>await new Promise(async n=>{let[a,s,o]=await it(e,i??[],{stdio:"inherit",...di(t)&&{env:t}});An(a,s??[],o).on("close",c=>{if(c===0){n(c);return}process.exit(1)})});var tt=async e=>{for(let i of e??[]){let[t,...n]=i.split(" ");await kn({command:t,args:n})}};import{isNullish as kp,nonNullish as Tp}from"@dfinity/utils";import Bp from"crypto";import{ReadableStream as sc}from"node:stream/web";import{pipeline as fa,PassThrough as oc,Readable as rc}from"node:stream";import{stat as ur}from"node:fs/promises";var or="End-Of-Stream",B=class extends Error{constructor(){super(or),this.name="EndOfStreamError"}},me=class extends Error{constructor(i="The operation was aborted"){super(i),this.name="AbortError"}};var fi=class{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise((i,t)=>{this.reject=t,this.resolve=i})}};var de=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(i,t=!1){let n=await this.read(i,t);return this.peekQueue.push(i.subarray(0,n)),n}async read(i,t=!1){if(i.length===0)return 0;let n=this.readFromPeekBuffer(i);if(this.endOfStream||(n+=await this.readRemainderFromStream(i.subarray(n),t)),n===0)throw new B;return n}readFromPeekBuffer(i){let t=i.length,n=0;for(;this.peekQueue.length>0&&t>0;){let a=this.peekQueue.pop();if(!a)throw new Error("peekData should be defined");let s=Math.min(a.length,t);i.set(a.subarray(0,s),n),n+=s,t-=s,s<a.length&&this.peekQueue.push(a.subarray(s))}return n}async readRemainderFromStream(i,t){let n=0;for(;n<i.length&&!this.endOfStream;){if(this.interrupted)throw new me;let a=await this.readFromStream(i.subarray(n),t);if(a===0)break;n+=a}if(!t&&n<i.length)throw new B;return n}};var $e=class extends de{constructor(i){if(super(),this.s=i,this.deferred=null,!i.read||!i.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>{this.endOfStream=!0,this.deferred&&this.deferred.resolve(0)}),this.s.once("error",t=>this.reject(t)),this.s.once("close",()=>this.abort())}async readFromStream(i,t){if(i.length===0)return 0;let n=this.s.read(i.length);if(n)return i.set(n),n.length;let a={buffer:i,mayBeLess:t,deferred:new fi};return this.deferred=a.deferred,this.s.once("readable",()=>{this.readDeferred(a)}),a.deferred.promise}readDeferred(i){let t=this.s.read(i.buffer.length);t?(i.buffer.set(t),i.deferred.resolve(t.length),this.deferred=null):this.s.once("readable",()=>{this.readDeferred(i)})}reject(i){this.interrupted=!0,this.deferred&&(this.deferred.reject(i),this.deferred=null)}async abort(){this.reject(new me)}async close(){return this.abort()}};var hi=class extends de{constructor(i){super(),this.reader=i}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var Ge=class extends hi{async readFromStream(i,t){if(i.length===0)return 0;let n=await this.reader.read(new Uint8Array(i.length),{min:t?void 0:i.length});return n.done&&(this.endOfStream=n.done),n.value?(i.set(n.value),n.value.length):0}};var ke=class extends de{constructor(i){super(),this.reader=i,this.buffer=null}writeChunk(i,t){let n=Math.min(t.length,i.length);return i.set(t.subarray(0,n)),n<t.length?this.buffer=t.subarray(n):this.buffer=null,n}async readFromStream(i,t){if(i.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(i,this.buffer));n<i.length&&!this.endOfStream;){let a=await this.reader.read();if(a.done){this.endOfStream=!0;break}a.value&&(n+=this.writeChunk(i.subarray(n),a.value))}if(n===0&&this.endOfStream)throw new B;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function nt(e){try{let i=e.getReader({mode:"byob"});return i instanceof ReadableStreamDefaultReader?new ke(i):new Ge(i)}catch(i){if(i instanceof TypeError)return new ke(e.getReader());throw i}}var re=class{constructor(i){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=i?.onClose,i?.abortSignal&&i.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(i,t=this.position){let n=new Uint8Array(i.len);if(await this.readBuffer(n,{position:t})<i.len)throw new B;return i.get(n,0)}async peekToken(i,t=this.position){let n=new Uint8Array(i.len);if(await this.peekBuffer(n,{position:t})<i.len)throw new B;return i.get(n,0)}async readNumber(i){if(await this.readBuffer(this.numBuffer,{length:i.len})<i.len)throw new B;return i.get(this.numBuffer,0)}async peekNumber(i){if(await this.peekBuffer(this.numBuffer,{length:i.len})<i.len)throw new B;return i.get(this.numBuffer,0)}async ignore(i){if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(i>t)return this.position+=t,t}return this.position+=i,i}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(i,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:i.length,position:this.position,...t}}abort(){return Promise.resolve()}};var rr=256e3,He=class extends re{constructor(i,t){super(t),this.streamReader=i,this.fileInfo=t?.fileInfo??{}}async readBuffer(i,t){let n=this.normalizeOptions(i,t),a=n.position-this.position;if(a>0)return await this.ignore(a),this.readBuffer(i,t);if(a<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let s=await this.streamReader.read(i.subarray(0,n.length),n.mayBeLess);if(this.position+=s,(!t||!t.mayBeLess)&&s<n.length)throw new B;return s}async peekBuffer(i,t){let n=this.normalizeOptions(i,t),a=0;if(n.position){let s=n.position-this.position;if(s>0){let o=new Uint8Array(n.length+s);return a=await this.peekBuffer(o,{mayBeLess:n.mayBeLess}),i.set(o.subarray(s)),a-s}if(s<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{a=await this.streamReader.peek(i.subarray(0,n.length),n.mayBeLess)}catch(s){if(t?.mayBeLess&&s instanceof B)return 0;throw s}if(!n.mayBeLess&&a<n.length)throw new B}return a}async ignore(i){let t=Math.min(rr,i),n=new Uint8Array(t),a=0;for(;a<i;){let s=i-a,o=await this.readBuffer(n,{length:Math.min(t,s)});if(o<0)return o;a+=o}return a}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}};var xi=class extends re{constructor(i,t){super(t),this.uint8Array=i,this.fileInfo={...t?.fileInfo??{},size:i.length}}async readBuffer(i,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(i,t);return this.position+=n,n}async peekBuffer(i,t){let n=this.normalizeOptions(i,t),a=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&a<n.length)throw new B;return i.set(this.uint8Array.subarray(n.position,n.position+a)),a}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(i){this.position=i}};function Tn(e,i){let t=new $e(e),n=i??{},a=n.onClose;return n.onClose=async()=>{if(await t.close(),a)return a()},new He(t,n)}function gi(e,i){let t=nt(e),n=i??{},a=n.onClose;return n.onClose=async()=>{if(await t.close(),a)return a()},new He(t,n)}function Bn(e,i){return new xi(e,i)}import{open as pr}from"node:fs/promises";var Ke=class e extends re{static async fromFile(i){let t=await pr(i,"r"),n=await t.stat();return new e(t,{fileInfo:{path:i,size:n.size}})}constructor(i,t){super(t),this.fileHandle=i,this.fileInfo=t.fileInfo}async readBuffer(i,t){let n=this.normalizeOptions(i,t);if(this.position=n.position,n.length===0)return 0;let a=await this.fileHandle.read(i,0,n.length,n.position);if(this.position+=a.bytesRead,a.bytesRead<n.length&&(!t||!t.mayBeLess))throw new B;return a.bytesRead}async peekBuffer(i,t){let n=this.normalizeOptions(i,t),a=await this.fileHandle.read(i,0,n.length,n.position);if(!n.mayBeLess&&a.bytesRead<n.length)throw new B;return a.bytesRead}async close(){return await this.fileHandle.close(),super.close()}setPosition(i){this.position=i}supportsRandomAccess(){return!0}};async function Sn(e,i){let t=Tn(e,i);if(e.path){let n=await ur(e.path);t.fileInfo.path=e.path,t.fileInfo.size=n.size}return t}var On=Ke.fromFile;var jn=Ae(Pn(),1);function H(e){return new DataView(e.buffer,e.byteOffset)}var Rn={len:1,get(e,i){return H(e).getUint8(i)},put(e,i,t){return H(e).setUint8(i,t),i+1}},O={len:2,get(e,i){return H(e).getUint16(i,!0)},put(e,i,t){return H(e).setUint16(i,t,!0),i+2}},Te={len:2,get(e,i){return H(e).getUint16(i)},put(e,i,t){return H(e).setUint16(i,t),i+2}};var L={len:4,get(e,i){return H(e).getUint32(i,!0)},put(e,i,t){return H(e).setUint32(i,t,!0),i+4}},In={len:4,get(e,i){return H(e).getUint32(i)},put(e,i,t){return H(e).setUint32(i,t),i+4}};var Un={len:4,get(e,i){return H(e).getInt32(i)},put(e,i,t){return H(e).setInt32(i,t),i+4}};var zn={len:8,get(e,i){return H(e).getBigUint64(i,!0)},put(e,i,t){return H(e).setBigUint64(i,t,!0),i+8}};var K=class{constructor(i,t){this.len=i,this.encoding=t,this.textDecoder=new TextDecoder(t)}get(i,t){return this.textDecoder.decode(i.subarray(t,t+this.len))}};import{createRequire as dr}from"module";var fr=dr("/"),hr;try{hr=fr("worker_threads").Worker}catch{}var Z=Uint8Array,Be=Uint16Array,xr=Int32Array,Ln=new Z([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),_n=new Z([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),gr=new Z([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mn=function(e,i){for(var t=new Be(31),n=0;n<31;++n)t[n]=i+=1<<e[n-1];for(var a=new xr(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)a[s]=s-t[n]<<5|n;return{b:t,r:a}},Nn=Mn(Ln,2),Wn=Nn.b,vr=Nn.r;Wn[28]=258,vr[258]=28;var qn=Mn(_n,0),Dr=qn.b,kd=qn.r,rt=new Be(32768);for(C=0;C<32768;++C)ce=(C&43690)>>1|(C&21845)<<1,ce=(ce&52428)>>2|(ce&13107)<<2,ce=(ce&61680)>>4|(ce&3855)<<4,rt[C]=((ce&65280)>>8|(ce&255)<<8)>>1;var ce,C,Ye=(function(e,i,t){for(var n=e.length,a=0,s=new Be(i);a<n;++a)e[a]&&++s[e[a]-1];var o=new Be(i);for(a=1;a<i;++a)o[a]=o[a-1]+s[a-1]<<1;var r;if(t){r=new Be(1<<i);var c=15-i;for(a=0;a<n;++a)if(e[a])for(var l=a<<4|e[a],u=i-e[a],p=o[e[a]-1]++<<u,m=p|(1<<u)-1;p<=m;++p)r[rt[p]>>c]=l}else for(r=new Be(n),a=0;a<n;++a)e[a]&&(r[a]=rt[o[e[a]-1]++]>>15-e[a]);return r}),Ve=new Z(288);for(C=0;C<144;++C)Ve[C]=8;var C;for(C=144;C<256;++C)Ve[C]=9;var C;for(C=256;C<280;++C)Ve[C]=7;var C;for(C=280;C<288;++C)Ve[C]=8;var C,$n=new Z(32);for(C=0;C<32;++C)$n[C]=5;var C;var br=Ye(Ve,9,1);var Fr=Ye($n,5,1),st=function(e){for(var i=e[0],t=1;t<e.length;++t)e[t]>i&&(i=e[t]);return i},te=function(e,i,t){var n=i/8|0;return(e[n]|e[n+1]<<8)>>(i&7)&t},ot=function(e,i){var t=i/8|0;return(e[t]|e[t+1]<<8|e[t+2]<<16)>>(i&7)},wr=function(e){return(e+7)/8|0},yr=function(e,i,t){return(i==null||i<0)&&(i=0),(t==null||t>e.length)&&(t=e.length),new Z(e.subarray(i,t))};var Er=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],V=function(e,i,t){var n=new Error(i||Er[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,V),!t)throw n;return n},ct=function(e,i,t,n){var a=e.length,s=n?n.length:0;if(!a||i.f&&!i.l)return t||new Z(0);var o=!t,r=o||i.i!=2,c=i.i;o&&(t=new Z(a*3));var l=function(hn){var xn=t.length;if(hn>xn){var gn=new Z(Math.max(xn*2,hn));gn.set(t),t=gn}},u=i.f||0,p=i.p||0,m=i.b||0,d=i.l,h=i.d,f=i.m,y=i.n,T=a*8;do{if(!d){u=te(e,p,1);var g=te(e,p+1,3);if(p+=3,g)if(g==1)d=br,h=Fr,f=9,y=5;else if(g==2){var z=te(e,p,31)+257,ui=te(e,p+10,15)+4,Me=z+te(e,p+5,31)+1;p+=14;for(var ve=new Z(Me),Yi=new Z(19),J=0;J<ui;++J)Yi[gr[J]]=te(e,p+J*3,7);p+=ui*3;for(var pn=st(Yi),_o=(1<<pn)-1,Mo=Ye(Yi,pn,1),J=0;J<Me;){var un=Mo[te(e,p,_o)];p+=un&15;var v=un>>4;if(v<16)ve[J++]=v;else{var Ee=0,li=0;for(v==16?(li=3+te(e,p,3),p+=2,Ee=ve[J-1]):v==17?(li=3+te(e,p,7),p+=3):v==18&&(li=11+te(e,p,127),p+=7);li--;)ve[J++]=Ee}}var ln=ve.subarray(0,z),ue=ve.subarray(z);f=st(ln),y=st(ue),d=Ye(ln,f,1),h=Ye(ue,y,1)}else V(1);else{var v=wr(p)+4,D=e[v-4]|e[v-3]<<8,U=v+D;if(U>a){c&&V(0);break}r&&l(m+D),t.set(e.subarray(v,U),m),i.b=m+=D,i.p=p=U*8,i.f=u;continue}if(p>T){c&&V(0);break}}r&&l(m+131072);for(var No=(1<<f)-1,Wo=(1<<y)-1,Vi=p;;Vi=p){var Ee=d[ot(e,p)&No],Ce=Ee>>4;if(p+=Ee&15,p>T){c&&V(0);break}if(Ee||V(2),Ce<256)t[m++]=Ce;else if(Ce==256){Vi=p,d=null;break}else{var mn=Ce-254;if(Ce>264){var J=Ce-257,Ne=Ln[J];mn=te(e,p,(1<<Ne)-1)+Wn[J],p+=Ne}var Zi=h[ot(e,p)&Wo],Ji=Zi>>4;Zi||V(3),p+=Zi&15;var ue=Dr[Ji];if(Ji>3){var Ne=_n[Ji];ue+=ot(e,p)&(1<<Ne)-1,p+=Ne}if(p>T){c&&V(0);break}r&&l(m+131072);var dn=m+mn;if(m<ue){var fn=s-ue,qo=Math.min(ue,dn);for(fn+m<0&&V(3);m<qo;++m)t[m]=n[fn+m]}for(;m<dn;++m)t[m]=t[m-ue]}}i.l=d,i.p=Vi,i.b=m,i.f=u,d&&(u=1,i.m=f,i.d=h,i.n=y)}while(!u);return m!=t.length&&o?yr(t,0,m):t.subarray(0,m)};var Cr=new Z(0);var Ar=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&V(6,"invalid gzip data");var i=e[3],t=10;i&4&&(t+=(e[10]|e[11]<<8)+2);for(var n=(i>>3&1)+(i>>4&1);n>0;n-=!e[t++]);return t+(i&2)},kr=function(e){var i=e.length;return(e[i-4]|e[i-3]<<8|e[i-2]<<16|e[i-1]<<24)>>>0};var Tr=function(e,i){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&V(6,"invalid zlib data"),(e[1]>>5&1)==+!i&&V(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function Br(e,i){return ct(e,{i:2},i&&i.out,i&&i.dictionary)}function Sr(e,i){var t=Ar(e);return t+8>e.length&&V(6,"invalid gzip data"),ct(e.subarray(t,-8),{i:2},i&&i.out||new Z(kr(e)),i&&i.dictionary)}function Or(e,i){return ct(e.subarray(Tr(e,i&&i.dictionary),-4),{i:2},i&&i.out,i&&i.dictionary)}function Gn(e,i){return e[0]==31&&e[1]==139&&e[2]==8?Sr(e,i):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?Br(e,i):Or(e,i)}var Pr=typeof TextDecoder<"u"&&new TextDecoder,jr=0;try{Pr.decode(Cr,{stream:!0}),jr=1}catch{}var ra=Ae(na(),1);var be={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},dt={get(e){let i=O.get(e,6);return{signature:L.get(e,0),compressedSize:L.get(e,8),uncompressedSize:L.get(e,12)}},len:16},aa={get(e){let i=O.get(e,6);return{signature:L.get(e,0),minVersion:O.get(e,4),dataDescriptor:!!(i&8),compressedMethod:O.get(e,8),compressedSize:L.get(e,18),uncompressedSize:L.get(e,22),filenameLength:O.get(e,26),extraFieldLength:O.get(e,28),filename:null}},len:30},sa={get(e){return{signature:L.get(e,0),nrOfThisDisk:O.get(e,4),nrOfThisDiskWithTheStart:O.get(e,6),nrOfEntriesOnThisDisk:O.get(e,8),nrOfEntriesOfSize:O.get(e,10),sizeOfCd:L.get(e,12),offsetOfStartOfCd:L.get(e,16),zipFileCommentLength:O.get(e,20)}},len:22},oa={get(e){let i=O.get(e,8);return{signature:L.get(e,0),minVersion:O.get(e,6),dataDescriptor:!!(i&8),compressedMethod:O.get(e,10),compressedSize:L.get(e,20),uncompressedSize:L.get(e,24),filenameLength:O.get(e,28),extraFieldLength:O.get(e,30),fileCommentLength:O.get(e,32),relativeOffsetOfLocalHeader:L.get(e,42),filename:null}},len:46};function ca(e){let i=new Uint8Array(L.len);return L.put(i,0,e),i}var ne=(0,ra.default)("tokenizer:inflate"),ft=256*1024,tc=ca(be.DataDescriptor),wi=ca(be.EndOfCentralDirectory),yi=class{constructor(i){this.tokenizer=i,this.syncBuffer=new Uint8Array(ft)}async isZip(){return await this.peekSignature()===be.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(L)}async findEndOfCentralDirectoryLocator(){let i=this.tokenizer,t=Math.min(16*1024,i.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:i.fileInfo.size-t});for(let a=n.length-4;a>=0;a--)if(n[a]===wi[0]&&n[a+1]===wi[1]&&n[a+2]===wi[2]&&n[a+3]===wi[3])return i.fileInfo.size-t+a;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){ne("Cannot reading central-directory without random-read support");return}ne("Reading central-directory...");let i=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){ne("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(sa,t),a=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let s=0;s<n.nrOfEntriesOfSize;++s){let o=await this.tokenizer.readToken(oa);if(o.signature!==be.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new K(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),a.push(o),ne(`Add central-directory file-entry: n=${s+1}/${a.length}: filename=${a[s].filename}`)}return this.tokenizer.setPosition(i),a}this.tokenizer.setPosition(i)}async unzip(i){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,i);let n=!1;do{let a=await this.readLocalFileHeader();if(!a)break;let s=i(a);n=!!s.stop;let o;if(await this.tokenizer.ignore(a.extraFieldLength),a.dataDescriptor&&a.compressedSize===0){let r=[],c=ft;ne("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let l=-1;for(;l<0&&c===ft;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),l=nc(this.syncBuffer.subarray(0,c),tc);let u=l>=0?l:c;if(s.handler){let p=new Uint8Array(u);await this.tokenizer.readBuffer(p),r.push(p)}else await this.tokenizer.ignore(u)}ne(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),s.handler&&await this.inflate(a,ac(r),s.handler)}else s.handler?(ne(`Reading compressed-file-data: ${a.compressedSize} bytes`),o=new Uint8Array(a.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(a,o,s.handler)):(ne(`Ignoring compressed-file-data: ${a.compressedSize} bytes`),await this.tokenizer.ignore(a.compressedSize));if(ne(`Reading data-descriptor at pos=${this.tokenizer.position}`),a.dataDescriptor&&(await this.tokenizer.readToken(dt)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-dt.len}`)}while(!n)}async iterateOverCentralDirectory(i,t){for(let n of i){let a=t(n);if(a.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let s=await this.readLocalFileHeader();if(s){await this.tokenizer.ignore(s.extraFieldLength);let o=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(s,o,a.handler)}}if(a.stop)break}}inflate(i,t,n){if(i.compressedMethod===0)return n(t);ne(`Decompress filename=${i.filename}, compressed-size=${t.length}`);let a=Gn(t);return n(a)}async readLocalFileHeader(){let i=await this.tokenizer.peekToken(L);if(i===be.LocalFileHeader){let t=await this.tokenizer.readToken(aa);return t.filename=await this.tokenizer.readToken(new K(t.filenameLength,"utf-8")),t}if(i===be.CentralFileHeader)return!1;throw i===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function nc(e,i){let t=e.length,n=i.length;if(n>t)return-1;for(let a=0;a<=t-n;a++){let s=!0;for(let o=0;o<n;o++)if(e[a+o]!==i[o]){s=!1;break}if(s)return a}return-1}function ac(e){let i=e.reduce((a,s)=>a+s.length,0),t=new Uint8Array(i),n=0;for(let a of e)t.set(a,n),n+=a.length;return t}var Md={utf8:new globalThis.TextDecoder("utf8")};var Nd=new globalThis.TextEncoder;var Wd=Array.from({length:256},(e,i)=>i.toString(16).padStart(2,"0"));function ht(e){let{byteLength:i}=e;if(i===6)return e.getUint16(0)*2**32+e.getUint32(2);if(i===5)return e.getUint8(0)*2**32+e.getUint32(1);if(i===4)return e.getUint32(0);if(i===3)return e.getUint8(0)*2**16+e.getUint16(1);if(i===2)return e.getUint16(0);if(i===1)return e.getUint8(0)}function pa(e){return[...e].map(i=>i.charCodeAt(0))}function ua(e,i=0){let t=Number.parseInt(new K(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let n=256;for(let a=i;a<i+148;a++)n+=e[a];for(let a=i+156;a<i+512;a++)n+=e[a];return t===n}var la={get:(e,i)=>e[i+3]&127|e[i+2]<<7|e[i+1]<<14|e[i]<<21,len:4};var ma=["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","rm","ppsm","ppsx"],da=["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"];var Ze=4100;function xt(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};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:e};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:e};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:e};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:e};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:e};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 ae(e,i,t){t={offset:0,...t};for(let[n,a]of i.entries())if(t.mask){if(a!==(t.mask[n]&e[n+t.offset]))return!1}else if(a!==e[n+t.offset])return!1;return!0}var Ei=class{constructor(i){this.options={mpegOffsetTolerance:0,...i},this.detectors=[...i?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:i?.signal}}async fromTokenizer(i){let t=i.position;for(let n of this.detectors){let a=await n.detect(i);if(a)return a;if(t!==i.position)return}}async fromBuffer(i){if(!(i instanceof Uint8Array||i instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof i}\``);let t=i instanceof Uint8Array?i:new Uint8Array(i);if(t?.length>1)return this.fromTokenizer(Bn(t,this.tokenizerOptions))}async fromBlob(i){return this.fromStream(i.stream())}async fromStream(i){let t=await gi(i,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(i,t){let{sampleSize:n=Ze}=t,a,s,o=i.getReader({mode:"byob"});try{let{value:l,done:u}=await o.read(new Uint8Array(n));if(s=l,!u&&l)try{a=await this.fromBuffer(l.subarray(0,n))}catch(p){if(!(p instanceof B))throw p;a=void 0}s=l}finally{o.releaseLock()}let r=new TransformStream({async start(l){l.enqueue(s)},transform(l,u){u.enqueue(l)}}),c=i.pipeThrough(r);return c.fileType=a,c}check(i,t){return ae(this.buffer,i,t)}checkString(i,t){return this.check(pa(i),t)}detectConfident=async i=>{if(this.buffer=new Uint8Array(Ze),i.fileInfo.size===void 0&&(i.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=i,await i.peekBuffer(this.buffer,{length:12,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 i.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.tokenizer.ignore(3),this.detectConfident(i);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{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await i.ignore(6);let t=await i.readToken(la);return i.position+t>i.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await i.ignore(t),this.fromTokenizer(i))}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;return await new yi(i).unzip(n=>{switch(n.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{async handler(a){let s=new TextDecoder("utf-8").decode(a).trim();t=xt(s)},stop:!0};case"[Content_Types].xml":return{async handler(a){let s=new TextDecoder("utf-8").decode(a),o=s.indexOf('.main+xml"');if(o===-1){let r="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";s.includes(`ContentType="${r}"`)&&(t=xt(r))}else{s=s.slice(0,Math.max(0,o));let r=s.lastIndexOf('"'),c=s.slice(Math.max(0,r+1));t=xt(c)}},stop:!0};default:return/classes\d*\.dex/.test(n.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}),t??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await i.ignore(28);let t=new Uint8Array(8);return await i.readBuffer(t),ae(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:ae(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:ae(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:ae(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:ae(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:ae(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 r=await i.peekNumber(Rn),c=128,l=0;for(;(r&c)===0&&c!==0;)++l,c>>=1;let u=new Uint8Array(l+1);return await i.readBuffer(u),u}async function n(){let r=await t(),c=await t();c[0]^=128>>c.length-1;let l=Math.min(6,c.length),u=new DataView(r.buffer),p=new DataView(c.buffer,c.length-l,l);return{id:ht(u),len:ht(p)}}async function a(r){for(;r>0;){let c=await n();if(c.id===17026)return(await i.readToken(new K(c.len))).replaceAll(/\00.*$/g,"");await i.ignore(c.len),--r}}let s=await n();switch(await a(s.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([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.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]))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 K(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 i.ignore(8),await i.readToken(new K(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
19
+ `)).length+1):i};dl=Jt(io.stdout),fl=dl,hl=Jt(io.stderr)});function Xt(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var ao=S(()=>{});function vl(){let e=new Map;for(let[i,t]of Object.entries(R)){for(let[n,a]of Object.entries(t))R[n]={open:`\x1B[${a[0]}m`,close:`\x1B[${a[1]}m`},t[n]=R[n],e.set(a[0],a[1]);Object.defineProperty(R,i,{value:t,enumerable:!1})}return Object.defineProperty(R,"codes",{value:e,enumerable:!1}),R.color.close="\x1B[39m",R.bgColor.close="\x1B[49m",R.color.ansi=so(),R.color.ansi256=oo(),R.color.ansi16m=ro(),R.bgColor.ansi=so(10),R.bgColor.ansi256=oo(10),R.bgColor.ansi16m=ro(10),Object.defineProperties(R,{rgbToAnsi256:{value:(i,t,n)=>i===t&&t===n?i<8?16:i>248?231:Math.round((i-8)/247*24)+232:16+36*Math.round(i/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:i=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(i.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(s=>s+s).join(""));let a=Number.parseInt(n,16);return[a>>16&255,a>>8&255,a&255]},enumerable:!1},hexToAnsi256:{value:i=>R.rgbToAnsi256(...R.hexToRgb(i)),enumerable:!1},ansi256ToAnsi:{value:i=>{if(i<8)return 30+i;if(i<16)return 90+(i-8);let t,n,a;if(i>=232)t=((i-232)*10+8)/255,n=t,a=t;else{i-=16;let r=i%36;t=Math.floor(i/36)/5,n=Math.floor(r/6)/5,a=r%6/5}let s=Math.max(t,n,a)*2;if(s===0)return 30;let o=30+(Math.round(a)<<2|Math.round(n)<<1|Math.round(t));return s===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(i,t,n)=>R.ansi256ToAnsi(R.rgbToAnsi256(i,t,n)),enumerable:!1},hexToAnsi:{value:i=>R.ansi256ToAnsi(R.hexToAnsi256(i)),enumerable:!1}}),R}var so,oo,ro,R,h0,xl,gl,x0,Dl,Qt,co=S(()=>{so=(e=0)=>i=>`\x1B[${i+e}m`,oo=(e=0)=>i=>`\x1B[${38+e};5;${i}m`,ro=(e=0)=>(i,t,n)=>`\x1B[${38+e};2;${i};${t};${n}m`,R={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},h0=Object.keys(R.modifier),xl=Object.keys(R.color),gl=Object.keys(R.bgColor),x0=[...xl,...gl];Dl=vl(),Qt=Dl});function se(e,i,t){let n=[...e],a=[],s=typeof t=="number"?t:n.length,o=!1,r,c=0,l="";for(let[u,p]of n.entries()){let m=!1;if(uo.includes(p)){let d=/\d[^m]*/.exec(e.slice(u,u+18));r=d&&d.length>0?d[0]:void 0,c<s&&(o=!0,r!==void 0&&a.push(r))}else o&&p==="m"&&(o=!1,m=!0);if(!o&&!m&&c++,!bl.test(p)&&Xt(p.codePointAt())&&(c++,typeof t!="number"&&s++),c>i&&c<=s)l+=p;else if(c===i&&!o&&r!==void 0)l=po(a);else if(c>=s){l+=po(a,!0,r);break}}return l}var bl,uo,Mi,po,lo=S(()=>{ao();co();bl=/^[\uD800-\uDBFF][\uDC00-\uDFFF]$/,uo=["\x1B","\x9B"],Mi=e=>`${uo[0]}[${e}m`,po=(e,i,t)=>{let n=[];e=[...e];for(let a of e){let s=a;a.includes(";")&&(a=a.split(";")[0][0]+"0");let o=Qt.codes.get(Number.parseInt(a,10));if(o){let r=e.indexOf(o.toString());r===-1?n.push(Mi(i?o:s)):e.splice(r,1)}else if(i){n.push(Mi(0));break}else n.push(Mi(s))}if(i&&(n=n.filter((a,s)=>n.indexOf(a)===s),t!==void 0)){let a=Mi(Qt.codes.get(Number.parseInt(t,10)));n=n.reduce((s,o)=>o===a?[o,...s]:[...s,o],[])}return n.join("")}});var fo={};mi(fo,{default:()=>mo});function Ni(e,i,t){if(e.charAt(i)===" ")return i;let n=t?1:-1;for(let a=0;a<=3;a++){let s=i+a*n;if(e.charAt(s)===" ")return s}return i}function mo(e,i,t={}){let{position:n="end",space:a=!1,preferTruncationOnSpace:s=!1}=t,{truncationCharacter:o="\u2026"}=t;if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof i!="number")throw new TypeError(`Expected \`columns\` to be a number, got ${typeof i}`);if(i<1)return"";if(i===1)return o;let r=ie(e);if(r<=i)return e;if(n==="start"){if(s){let c=Ni(e,r-i+1,!0);return o+se(e,c,r).trim()}return a===!0&&(o+=" "),o+se(e,r-i+ie(o),r)}if(n==="middle"){a===!0&&(o=` ${o} `);let c=Math.floor(i/2);if(s){let l=Ni(e,c),u=Ni(e,r-(i-c)+1,!0);return se(e,0,l)+o+se(e,u,r).trim()}return se(e,0,c)+o+se(e,r-(i-c)+ie(o),r)}if(n==="end"){if(s){let c=Ni(e,i-1);return se(e,0,c)+o}return a===!0&&(o=` ${o}`),se(e,0,i-ie(o))+o}throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${n}`)}var ho=S(()=>{lo();Wt()});import{rm as Zo}from"node:fs/promises";var gm=async({infile:e,outfile:i,banner:t})=>{await Jo();let{build:n,version:a}=await import("esbuild");await Zo(i,{force:!0});let{metafile:s,errors:o,warnings:r}=await n({entryPoints:[e],outfile:i,bundle:!0,minify:!0,treeShaking:!0,format:"esm",platform:"browser",write:!0,supported:{"top-level-await":!1,"inline-script":!1},define:{self:"globalThis"},metafile:!0,banner:t});return{metafile:s,errors:o,warnings:r,version:a}},Jo=async()=>{try{await import("esbuild")}catch{console.error("Esbuild is required to build your functions. Please install it by running: npm i esbuild"),process.exit(1)}};import{nonNullish as om,toNullable as rm}from"@dfinity/utils";import cm from"ora";var vn="build",Dn=[],bn=[],le={pattern:"**/*.+(css|js|mjs|html)",mode:"both",algorithm:"gzip"},Fn=[".ds_store","thumbs.db"],qe=50,Qi="#dapp",wn="#_juno/releases";import{nonNullish as di}from"@dfinity/utils";import{spawn as An}from"child_process";import{nonNullish as Xo}from"@dfinity/utils";import{stat as Qo}from"node:fs/promises";import yn from"node:path";import En from"node:process";import{URL as er}from"node:url";var it=async(e,i,t)=>await ir(e,t)?[et(e),i.map(n=>sr(n)),{...t,shell:!0}]:[e,i,t],ir=async(e,{shell:i,cwd:t,env:n=En.env})=>En.platform==="win32"&&!i&&!await tr(e,t,n),tr=async(e,i,{Path:t="",PATH:n=t})=>Cn.some(a=>e.toLowerCase().endsWith(a))||(nr[`${e}\0${i}\0${n}`]??=await ar(e,i,n)),nr={},ar=async(e,i,t)=>{let n=t.split(yn.delimiter).filter(Boolean).map(a=>a.replace(/^"(.*)"$/,"$1"));try{await Promise.all(Cn.flatMap(a=>[i,...n].filter(Xo).map(s=>`${yn.resolve(s instanceof er?s.toString():s,e)}${a}`)).map(async a=>{try{await Qo(a)}catch{return}throw 0}))}catch{return!0}return!1},Cn=[".exe",".com"],sr=e=>et(et(`"${e.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),et=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");var Bm=async({command:e,cwd:i,args:t,env:n,stdout:a,silentOut:s=!1,silentErrors:o=!1})=>await new Promise(async(r,c)=>{let[l,u,p]=await it(e,t??[],{shell:!0,...di(i)&&{cwd:i},...di(n)&&{env:n}}),m=An(l,u,p);m.stdout.on("data",d=>{if(di(a)){a(`${d}`);return}s||console.log(`${d}`)}),m.stderr.on("data",d=>{o||c(new Error(`${d}`))}),m.on("close",d=>{r(d)}),m.on("error",d=>{c(d)})}),kn=async({command:e,args:i,env:t})=>await new Promise(async n=>{let[a,s,o]=await it(e,i??[],{stdio:"inherit",...di(t)&&{env:t}});An(a,s??[],o).on("close",c=>{if(c===0){n(c);return}process.exit(1)})});var tt=async e=>{for(let i of e??[]){let[t,...n]=i.split(" ");await kn({command:t,args:n})}};import{isNullish as kp,nonNullish as Tp}from"@dfinity/utils";import Bp from"crypto";import{ReadableStream as sc}from"node:stream/web";import{pipeline as fa,PassThrough as oc,Readable as rc}from"node:stream";import{stat as ur}from"node:fs/promises";var or="End-Of-Stream",B=class extends Error{constructor(){super(or),this.name="EndOfStreamError"}},me=class extends Error{constructor(i="The operation was aborted"){super(i),this.name="AbortError"}};var fi=class{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise((i,t)=>{this.reject=t,this.resolve=i})}};var de=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(i,t=!1){let n=await this.read(i,t);return this.peekQueue.push(i.subarray(0,n)),n}async read(i,t=!1){if(i.length===0)return 0;let n=this.readFromPeekBuffer(i);if(this.endOfStream||(n+=await this.readRemainderFromStream(i.subarray(n),t)),n===0)throw new B;return n}readFromPeekBuffer(i){let t=i.length,n=0;for(;this.peekQueue.length>0&&t>0;){let a=this.peekQueue.pop();if(!a)throw new Error("peekData should be defined");let s=Math.min(a.length,t);i.set(a.subarray(0,s),n),n+=s,t-=s,s<a.length&&this.peekQueue.push(a.subarray(s))}return n}async readRemainderFromStream(i,t){let n=0;for(;n<i.length&&!this.endOfStream;){if(this.interrupted)throw new me;let a=await this.readFromStream(i.subarray(n),t);if(a===0)break;n+=a}if(!t&&n<i.length)throw new B;return n}};var $e=class extends de{constructor(i){if(super(),this.s=i,this.deferred=null,!i.read||!i.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>{this.endOfStream=!0,this.deferred&&this.deferred.resolve(0)}),this.s.once("error",t=>this.reject(t)),this.s.once("close",()=>this.abort())}async readFromStream(i,t){if(i.length===0)return 0;let n=this.s.read(i.length);if(n)return i.set(n),n.length;let a={buffer:i,mayBeLess:t,deferred:new fi};return this.deferred=a.deferred,this.s.once("readable",()=>{this.readDeferred(a)}),a.deferred.promise}readDeferred(i){let t=this.s.read(i.buffer.length);t?(i.buffer.set(t),i.deferred.resolve(t.length),this.deferred=null):this.s.once("readable",()=>{this.readDeferred(i)})}reject(i){this.interrupted=!0,this.deferred&&(this.deferred.reject(i),this.deferred=null)}async abort(){this.reject(new me)}async close(){return this.abort()}};var hi=class extends de{constructor(i){super(),this.reader=i}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var Ge=class extends hi{async readFromStream(i,t){if(i.length===0)return 0;let n=await this.reader.read(new Uint8Array(i.length),{min:t?void 0:i.length});return n.done&&(this.endOfStream=n.done),n.value?(i.set(n.value),n.value.length):0}};var ke=class extends de{constructor(i){super(),this.reader=i,this.buffer=null}writeChunk(i,t){let n=Math.min(t.length,i.length);return i.set(t.subarray(0,n)),n<t.length?this.buffer=t.subarray(n):this.buffer=null,n}async readFromStream(i,t){if(i.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(i,this.buffer));n<i.length&&!this.endOfStream;){let a=await this.reader.read();if(a.done){this.endOfStream=!0;break}a.value&&(n+=this.writeChunk(i.subarray(n),a.value))}if(n===0&&this.endOfStream)throw new B;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function nt(e){try{let i=e.getReader({mode:"byob"});return i instanceof ReadableStreamDefaultReader?new ke(i):new Ge(i)}catch(i){if(i instanceof TypeError)return new ke(e.getReader());throw i}}var re=class{constructor(i){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=i?.onClose,i?.abortSignal&&i.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(i,t=this.position){let n=new Uint8Array(i.len);if(await this.readBuffer(n,{position:t})<i.len)throw new B;return i.get(n,0)}async peekToken(i,t=this.position){let n=new Uint8Array(i.len);if(await this.peekBuffer(n,{position:t})<i.len)throw new B;return i.get(n,0)}async readNumber(i){if(await this.readBuffer(this.numBuffer,{length:i.len})<i.len)throw new B;return i.get(this.numBuffer,0)}async peekNumber(i){if(await this.peekBuffer(this.numBuffer,{length:i.len})<i.len)throw new B;return i.get(this.numBuffer,0)}async ignore(i){if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(i>t)return this.position+=t,t}return this.position+=i,i}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(i,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:i.length,position:this.position,...t}}abort(){return Promise.resolve()}};var rr=256e3,He=class extends re{constructor(i,t){super(t),this.streamReader=i,this.fileInfo=t?.fileInfo??{}}async readBuffer(i,t){let n=this.normalizeOptions(i,t),a=n.position-this.position;if(a>0)return await this.ignore(a),this.readBuffer(i,t);if(a<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let s=await this.streamReader.read(i.subarray(0,n.length),n.mayBeLess);if(this.position+=s,(!t||!t.mayBeLess)&&s<n.length)throw new B;return s}async peekBuffer(i,t){let n=this.normalizeOptions(i,t),a=0;if(n.position){let s=n.position-this.position;if(s>0){let o=new Uint8Array(n.length+s);return a=await this.peekBuffer(o,{mayBeLess:n.mayBeLess}),i.set(o.subarray(s)),a-s}if(s<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{a=await this.streamReader.peek(i.subarray(0,n.length),n.mayBeLess)}catch(s){if(t?.mayBeLess&&s instanceof B)return 0;throw s}if(!n.mayBeLess&&a<n.length)throw new B}return a}async ignore(i){let t=Math.min(rr,i),n=new Uint8Array(t),a=0;for(;a<i;){let s=i-a,o=await this.readBuffer(n,{length:Math.min(t,s)});if(o<0)return o;a+=o}return a}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}};var xi=class extends re{constructor(i,t){super(t),this.uint8Array=i,this.fileInfo={...t?.fileInfo??{},size:i.length}}async readBuffer(i,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(i,t);return this.position+=n,n}async peekBuffer(i,t){let n=this.normalizeOptions(i,t),a=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&a<n.length)throw new B;return i.set(this.uint8Array.subarray(n.position,n.position+a)),a}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(i){this.position=i}};function Tn(e,i){let t=new $e(e),n=i??{},a=n.onClose;return n.onClose=async()=>{if(await t.close(),a)return a()},new He(t,n)}function gi(e,i){let t=nt(e),n=i??{},a=n.onClose;return n.onClose=async()=>{if(await t.close(),a)return a()},new He(t,n)}function Bn(e,i){return new xi(e,i)}import{open as pr}from"node:fs/promises";var Ke=class e extends re{static async fromFile(i){let t=await pr(i,"r"),n=await t.stat();return new e(t,{fileInfo:{path:i,size:n.size}})}constructor(i,t){super(t),this.fileHandle=i,this.fileInfo=t.fileInfo}async readBuffer(i,t){let n=this.normalizeOptions(i,t);if(this.position=n.position,n.length===0)return 0;let a=await this.fileHandle.read(i,0,n.length,n.position);if(this.position+=a.bytesRead,a.bytesRead<n.length&&(!t||!t.mayBeLess))throw new B;return a.bytesRead}async peekBuffer(i,t){let n=this.normalizeOptions(i,t),a=await this.fileHandle.read(i,0,n.length,n.position);if(!n.mayBeLess&&a.bytesRead<n.length)throw new B;return a.bytesRead}async close(){return await this.fileHandle.close(),super.close()}setPosition(i){this.position=i}supportsRandomAccess(){return!0}};async function Sn(e,i){let t=Tn(e,i);if(e.path){let n=await ur(e.path);t.fileInfo.path=e.path,t.fileInfo.size=n.size}return t}var On=Ke.fromFile;var jn=Ae(Pn(),1);function H(e){return new DataView(e.buffer,e.byteOffset)}var Rn={len:1,get(e,i){return H(e).getUint8(i)},put(e,i,t){return H(e).setUint8(i,t),i+1}},O={len:2,get(e,i){return H(e).getUint16(i,!0)},put(e,i,t){return H(e).setUint16(i,t,!0),i+2}},Te={len:2,get(e,i){return H(e).getUint16(i)},put(e,i,t){return H(e).setUint16(i,t),i+2}};var L={len:4,get(e,i){return H(e).getUint32(i,!0)},put(e,i,t){return H(e).setUint32(i,t,!0),i+4}},In={len:4,get(e,i){return H(e).getUint32(i)},put(e,i,t){return H(e).setUint32(i,t),i+4}};var Un={len:4,get(e,i){return H(e).getInt32(i)},put(e,i,t){return H(e).setInt32(i,t),i+4}};var zn={len:8,get(e,i){return H(e).getBigUint64(i,!0)},put(e,i,t){return H(e).setBigUint64(i,t,!0),i+8}};var K=class{constructor(i,t){this.len=i,this.encoding=t,this.textDecoder=new TextDecoder(t)}get(i,t){return this.textDecoder.decode(i.subarray(t,t+this.len))}};import{createRequire as dr}from"module";var fr=dr("/"),hr;try{hr=fr("worker_threads").Worker}catch{}var Z=Uint8Array,Be=Uint16Array,xr=Int32Array,Ln=new Z([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),_n=new Z([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),gr=new Z([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mn=function(e,i){for(var t=new Be(31),n=0;n<31;++n)t[n]=i+=1<<e[n-1];for(var a=new xr(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)a[s]=s-t[n]<<5|n;return{b:t,r:a}},Nn=Mn(Ln,2),Wn=Nn.b,vr=Nn.r;Wn[28]=258,vr[258]=28;var qn=Mn(_n,0),Dr=qn.b,kd=qn.r,rt=new Be(32768);for(C=0;C<32768;++C)ce=(C&43690)>>1|(C&21845)<<1,ce=(ce&52428)>>2|(ce&13107)<<2,ce=(ce&61680)>>4|(ce&3855)<<4,rt[C]=((ce&65280)>>8|(ce&255)<<8)>>1;var ce,C,Ye=(function(e,i,t){for(var n=e.length,a=0,s=new Be(i);a<n;++a)e[a]&&++s[e[a]-1];var o=new Be(i);for(a=1;a<i;++a)o[a]=o[a-1]+s[a-1]<<1;var r;if(t){r=new Be(1<<i);var c=15-i;for(a=0;a<n;++a)if(e[a])for(var l=a<<4|e[a],u=i-e[a],p=o[e[a]-1]++<<u,m=p|(1<<u)-1;p<=m;++p)r[rt[p]>>c]=l}else for(r=new Be(n),a=0;a<n;++a)e[a]&&(r[a]=rt[o[e[a]-1]++]>>15-e[a]);return r}),Ve=new Z(288);for(C=0;C<144;++C)Ve[C]=8;var C;for(C=144;C<256;++C)Ve[C]=9;var C;for(C=256;C<280;++C)Ve[C]=7;var C;for(C=280;C<288;++C)Ve[C]=8;var C,$n=new Z(32);for(C=0;C<32;++C)$n[C]=5;var C;var br=Ye(Ve,9,1);var Fr=Ye($n,5,1),st=function(e){for(var i=e[0],t=1;t<e.length;++t)e[t]>i&&(i=e[t]);return i},te=function(e,i,t){var n=i/8|0;return(e[n]|e[n+1]<<8)>>(i&7)&t},ot=function(e,i){var t=i/8|0;return(e[t]|e[t+1]<<8|e[t+2]<<16)>>(i&7)},wr=function(e){return(e+7)/8|0},yr=function(e,i,t){return(i==null||i<0)&&(i=0),(t==null||t>e.length)&&(t=e.length),new Z(e.subarray(i,t))};var Er=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],V=function(e,i,t){var n=new Error(i||Er[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,V),!t)throw n;return n},ct=function(e,i,t,n){var a=e.length,s=n?n.length:0;if(!a||i.f&&!i.l)return t||new Z(0);var o=!t,r=o||i.i!=2,c=i.i;o&&(t=new Z(a*3));var l=function(hn){var xn=t.length;if(hn>xn){var gn=new Z(Math.max(xn*2,hn));gn.set(t),t=gn}},u=i.f||0,p=i.p||0,m=i.b||0,d=i.l,h=i.d,f=i.m,y=i.n,T=a*8;do{if(!d){u=te(e,p,1);var g=te(e,p+1,3);if(p+=3,g)if(g==1)d=br,h=Fr,f=9,y=5;else if(g==2){var z=te(e,p,31)+257,ui=te(e,p+10,15)+4,Me=z+te(e,p+5,31)+1;p+=14;for(var ve=new Z(Me),Yi=new Z(19),J=0;J<ui;++J)Yi[gr[J]]=te(e,p+J*3,7);p+=ui*3;for(var pn=st(Yi),_o=(1<<pn)-1,Mo=Ye(Yi,pn,1),J=0;J<Me;){var un=Mo[te(e,p,_o)];p+=un&15;var v=un>>4;if(v<16)ve[J++]=v;else{var Ee=0,li=0;for(v==16?(li=3+te(e,p,3),p+=2,Ee=ve[J-1]):v==17?(li=3+te(e,p,7),p+=3):v==18&&(li=11+te(e,p,127),p+=7);li--;)ve[J++]=Ee}}var ln=ve.subarray(0,z),ue=ve.subarray(z);f=st(ln),y=st(ue),d=Ye(ln,f,1),h=Ye(ue,y,1)}else V(1);else{var v=wr(p)+4,D=e[v-4]|e[v-3]<<8,U=v+D;if(U>a){c&&V(0);break}r&&l(m+D),t.set(e.subarray(v,U),m),i.b=m+=D,i.p=p=U*8,i.f=u;continue}if(p>T){c&&V(0);break}}r&&l(m+131072);for(var No=(1<<f)-1,Wo=(1<<y)-1,Vi=p;;Vi=p){var Ee=d[ot(e,p)&No],Ce=Ee>>4;if(p+=Ee&15,p>T){c&&V(0);break}if(Ee||V(2),Ce<256)t[m++]=Ce;else if(Ce==256){Vi=p,d=null;break}else{var mn=Ce-254;if(Ce>264){var J=Ce-257,Ne=Ln[J];mn=te(e,p,(1<<Ne)-1)+Wn[J],p+=Ne}var Zi=h[ot(e,p)&Wo],Ji=Zi>>4;Zi||V(3),p+=Zi&15;var ue=Dr[Ji];if(Ji>3){var Ne=_n[Ji];ue+=ot(e,p)&(1<<Ne)-1,p+=Ne}if(p>T){c&&V(0);break}r&&l(m+131072);var dn=m+mn;if(m<ue){var fn=s-ue,qo=Math.min(ue,dn);for(fn+m<0&&V(3);m<qo;++m)t[m]=n[fn+m]}for(;m<dn;++m)t[m]=t[m-ue]}}i.l=d,i.p=Vi,i.b=m,i.f=u,d&&(u=1,i.m=f,i.d=h,i.n=y)}while(!u);return m!=t.length&&o?yr(t,0,m):t.subarray(0,m)};var Cr=new Z(0);var Ar=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&V(6,"invalid gzip data");var i=e[3],t=10;i&4&&(t+=(e[10]|e[11]<<8)+2);for(var n=(i>>3&1)+(i>>4&1);n>0;n-=!e[t++]);return t+(i&2)},kr=function(e){var i=e.length;return(e[i-4]|e[i-3]<<8|e[i-2]<<16|e[i-1]<<24)>>>0};var Tr=function(e,i){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&V(6,"invalid zlib data"),(e[1]>>5&1)==+!i&&V(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function Br(e,i){return ct(e,{i:2},i&&i.out,i&&i.dictionary)}function Sr(e,i){var t=Ar(e);return t+8>e.length&&V(6,"invalid gzip data"),ct(e.subarray(t,-8),{i:2},i&&i.out||new Z(kr(e)),i&&i.dictionary)}function Or(e,i){return ct(e.subarray(Tr(e,i&&i.dictionary),-4),{i:2},i&&i.out,i&&i.dictionary)}function Gn(e,i){return e[0]==31&&e[1]==139&&e[2]==8?Sr(e,i):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?Br(e,i):Or(e,i)}var Pr=typeof TextDecoder<"u"&&new TextDecoder,jr=0;try{Pr.decode(Cr,{stream:!0}),jr=1}catch{}var ra=Ae(na(),1);var be={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},dt={get(e){let i=O.get(e,6);return{signature:L.get(e,0),compressedSize:L.get(e,8),uncompressedSize:L.get(e,12)}},len:16},aa={get(e){let i=O.get(e,6);return{signature:L.get(e,0),minVersion:O.get(e,4),dataDescriptor:!!(i&8),compressedMethod:O.get(e,8),compressedSize:L.get(e,18),uncompressedSize:L.get(e,22),filenameLength:O.get(e,26),extraFieldLength:O.get(e,28),filename:null}},len:30},sa={get(e){return{signature:L.get(e,0),nrOfThisDisk:O.get(e,4),nrOfThisDiskWithTheStart:O.get(e,6),nrOfEntriesOnThisDisk:O.get(e,8),nrOfEntriesOfSize:O.get(e,10),sizeOfCd:L.get(e,12),offsetOfStartOfCd:L.get(e,16),zipFileCommentLength:O.get(e,20)}},len:22},oa={get(e){let i=O.get(e,8);return{signature:L.get(e,0),minVersion:O.get(e,6),dataDescriptor:!!(i&8),compressedMethod:O.get(e,10),compressedSize:L.get(e,20),uncompressedSize:L.get(e,24),filenameLength:O.get(e,28),extraFieldLength:O.get(e,30),fileCommentLength:O.get(e,32),relativeOffsetOfLocalHeader:L.get(e,42),filename:null}},len:46};function ca(e){let i=new Uint8Array(L.len);return L.put(i,0,e),i}var ne=(0,ra.default)("tokenizer:inflate"),ft=256*1024,tc=ca(be.DataDescriptor),wi=ca(be.EndOfCentralDirectory),yi=class{constructor(i){this.tokenizer=i,this.syncBuffer=new Uint8Array(ft)}async isZip(){return await this.peekSignature()===be.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(L)}async findEndOfCentralDirectoryLocator(){let i=this.tokenizer,t=Math.min(16*1024,i.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:i.fileInfo.size-t});for(let a=n.length-4;a>=0;a--)if(n[a]===wi[0]&&n[a+1]===wi[1]&&n[a+2]===wi[2]&&n[a+3]===wi[3])return i.fileInfo.size-t+a;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){ne("Cannot reading central-directory without random-read support");return}ne("Reading central-directory...");let i=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){ne("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(sa,t),a=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let s=0;s<n.nrOfEntriesOfSize;++s){let o=await this.tokenizer.readToken(oa);if(o.signature!==be.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new K(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),a.push(o),ne(`Add central-directory file-entry: n=${s+1}/${a.length}: filename=${a[s].filename}`)}return this.tokenizer.setPosition(i),a}this.tokenizer.setPosition(i)}async unzip(i){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,i);let n=!1;do{let a=await this.readLocalFileHeader();if(!a)break;let s=i(a);n=!!s.stop;let o;if(await this.tokenizer.ignore(a.extraFieldLength),a.dataDescriptor&&a.compressedSize===0){let r=[],c=ft;ne("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let l=-1;for(;l<0&&c===ft;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),l=nc(this.syncBuffer.subarray(0,c),tc);let u=l>=0?l:c;if(s.handler){let p=new Uint8Array(u);await this.tokenizer.readBuffer(p),r.push(p)}else await this.tokenizer.ignore(u)}ne(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),s.handler&&await this.inflate(a,ac(r),s.handler)}else s.handler?(ne(`Reading compressed-file-data: ${a.compressedSize} bytes`),o=new Uint8Array(a.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(a,o,s.handler)):(ne(`Ignoring compressed-file-data: ${a.compressedSize} bytes`),await this.tokenizer.ignore(a.compressedSize));if(ne(`Reading data-descriptor at pos=${this.tokenizer.position}`),a.dataDescriptor&&(await this.tokenizer.readToken(dt)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-dt.len}`)}while(!n)}async iterateOverCentralDirectory(i,t){for(let n of i){let a=t(n);if(a.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let s=await this.readLocalFileHeader();if(s){await this.tokenizer.ignore(s.extraFieldLength);let o=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(s,o,a.handler)}}if(a.stop)break}}inflate(i,t,n){if(i.compressedMethod===0)return n(t);ne(`Decompress filename=${i.filename}, compressed-size=${t.length}`);let a=Gn(t);return n(a)}async readLocalFileHeader(){let i=await this.tokenizer.peekToken(L);if(i===be.LocalFileHeader){let t=await this.tokenizer.readToken(aa);return t.filename=await this.tokenizer.readToken(new K(t.filenameLength,"utf-8")),t}if(i===be.CentralFileHeader)return!1;throw i===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function nc(e,i){let t=e.length,n=i.length;if(n>t)return-1;for(let a=0;a<=t-n;a++){let s=!0;for(let o=0;o<n;o++)if(e[a+o]!==i[o]){s=!1;break}if(s)return a}return-1}function ac(e){let i=e.reduce((a,s)=>a+s.length,0),t=new Uint8Array(i),n=0;for(let a of e)t.set(a,n),n+=a.length;return t}var Md={utf8:new globalThis.TextDecoder("utf8")};var Nd=new globalThis.TextEncoder;var Wd=Array.from({length:256},(e,i)=>i.toString(16).padStart(2,"0"));function ht(e){let{byteLength:i}=e;if(i===6)return e.getUint16(0)*2**32+e.getUint32(2);if(i===5)return e.getUint8(0)*2**32+e.getUint32(1);if(i===4)return e.getUint32(0);if(i===3)return e.getUint8(0)*2**16+e.getUint16(1);if(i===2)return e.getUint16(0);if(i===1)return e.getUint8(0)}function pa(e){return[...e].map(i=>i.charCodeAt(0))}function ua(e,i=0){let t=Number.parseInt(new K(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let n=256;for(let a=i;a<i+148;a++)n+=e[a];for(let a=i+156;a<i+512;a++)n+=e[a];return t===n}var la={get:(e,i)=>e[i+3]&127|e[i+2]<<7|e[i+1]<<14|e[i]<<21,len:4};var ma=["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","rm","ppsm","ppsx"],da=["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"];var Ze=4100;function xt(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};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:e};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:e};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:e};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:e};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:e};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 ae(e,i,t){t={offset:0,...t};for(let[n,a]of i.entries())if(t.mask){if(a!==(t.mask[n]&e[n+t.offset]))return!1}else if(a!==e[n+t.offset])return!1;return!0}var Ei=class{constructor(i){this.options={mpegOffsetTolerance:0,...i},this.detectors=[...i?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:i?.signal}}async fromTokenizer(i){let t=i.position;for(let n of this.detectors){let a=await n.detect(i);if(a)return a;if(t!==i.position)return}}async fromBuffer(i){if(!(i instanceof Uint8Array||i instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof i}\``);let t=i instanceof Uint8Array?i:new Uint8Array(i);if(t?.length>1)return this.fromTokenizer(Bn(t,this.tokenizerOptions))}async fromBlob(i){return this.fromStream(i.stream())}async fromStream(i){let t=await gi(i,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(i,t){let{sampleSize:n=Ze}=t,a,s,o=i.getReader({mode:"byob"});try{let{value:l,done:u}=await o.read(new Uint8Array(n));if(s=l,!u&&l)try{a=await this.fromBuffer(l.subarray(0,n))}catch(p){if(!(p instanceof B))throw p;a=void 0}s=l}finally{o.releaseLock()}let r=new TransformStream({async start(l){l.enqueue(s)},transform(l,u){u.enqueue(l)}}),c=i.pipeThrough(r);return c.fileType=a,c}check(i,t){return ae(this.buffer,i,t)}checkString(i,t){return this.check(pa(i),t)}detectConfident=async i=>{if(this.buffer=new Uint8Array(Ze),i.fileInfo.size===void 0&&(i.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=i,await i.peekBuffer(this.buffer,{length:12,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 i.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.tokenizer.ignore(3),this.detectConfident(i);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{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await i.ignore(6);let t=await i.readToken(la);return i.position+t>i.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await i.ignore(t),this.fromTokenizer(i))}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;return await new yi(i).unzip(n=>{switch(n.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{async handler(a){let s=new TextDecoder("utf-8").decode(a).trim();t=xt(s)},stop:!0};case"[Content_Types].xml":return{async handler(a){let s=new TextDecoder("utf-8").decode(a),o=s.indexOf('.main+xml"');if(o===-1){let r="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";s.includes(`ContentType="${r}"`)&&(t=xt(r))}else{s=s.slice(0,Math.max(0,o));let r=s.lastIndexOf('"'),c=s.slice(Math.max(0,r+1));t=xt(c)}},stop:!0};default:return/classes\d*\.dex/.test(n.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}),t??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await i.ignore(28);let t=new Uint8Array(8);return await i.readBuffer(t),ae(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:ae(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:ae(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:ae(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:ae(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:ae(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 r=await i.peekNumber(Rn),c=128,l=0;for(;(r&c)===0&&c!==0;)++l,c>>=1;let u=new Uint8Array(l+1);return await i.readBuffer(u),u}async function n(){let r=await t(),c=await t();c[0]^=128>>c.length-1;let l=Math.min(6,c.length),u=new DataView(r.buffer),p=new DataView(c.buffer,c.length-l,l);return{id:ht(u),len:ht(p)}}async function a(r){for(;r>0;){let c=await n();if(c.id===17026)return(await i.readToken(new K(c.len))).replaceAll(/\00.*$/g,"");await i.ignore(c.len),--r}}let s=await n();switch(await a(s.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([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.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]))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 K(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 i.ignore(8),await i.readToken(new K(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
20
20
  `,"\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])){await i.ignore(8);async function t(){return{length:await i.readToken(Un),type:await i.readToken(new K(4,"latin1"))}}do{let n=await t();if(n.length<0)return;switch(n.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await i.ignore(n.length+4)}}while(i.position+8<i.fileInfo.size);return{ext:"png",mime:"image/png"}}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 K(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.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])){async function t(){let n=new Uint8Array(16);return await i.readBuffer(n),{id:n,size:Number(await i.readToken(zn))}}for(await i.ignore(30);i.position+24<i.fileInfo.size;){let n=await t(),a=n.size-24;if(ae(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let s=new Uint8Array(16);if(a-=await i.readBuffer(s),ae(s,[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(ae(s,[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}await i.ignore(a)}return{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 i.ignore(20),await i.readToken(new K(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.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{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 i.peekBuffer(this.buffer,{length:Math.min(256,i.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 n=new TextDecoder().decode(this.buffer.subarray(16,t+16));if(JSON.parse(n).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(await i.peekBuffer(this.buffer,{length:Math.min(512,i.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})&&ua(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254]))return this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0;if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async i=>{if(this.buffer=new Uint8Array(Ze),await i.peekBuffer(this.buffer,{length:Math.min(8,i.fileInfo.size),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 i.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,i.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let t=0;t<=this.options.mpegOffsetTolerance;++t){let n=this.scanMpeg(t);if(n)return n}};async readTiffTag(i){let t=await this.tokenizer.readToken(i?Te:O);switch(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(i){let t=await this.tokenizer.readToken(i?Te:O);for(let n=0;n<t;++n){let a=await this.readTiffTag(i);if(a)return a}}async readTiffHeader(i){let t=(i?Te:O).get(this.buffer,2),n=(i?In:L).get(this.buffer,4);if(t===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8){let s=(i?Te:O).get(this.buffer,8),o=(i?Te:O).get(this.buffer,10);if(s===28&&o===254||s===31&&o===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(n),await this.readTiffIFD(i)??{ext:"tif",mime:"image/tiff"}}if(t===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(i){if(this.check([255,224],{offset:i,mask:[255,224]})){if(this.check([16],{offset:i+1,mask:[22]}))return this.check([8],{offset:i+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:i+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:i+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:i+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},Jd=new Set(ma),Xd=new Set(da);var gt=class extends Ei{async fromStream(i){let t=await(i instanceof sc?gi(i,this.tokenizerOptions):Sn(i,this.tokenizerOptions));try{return await super.fromTokenizer(t)}finally{await t.close()}}async fromFile(i){let t=await On(i);try{return await super.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(i,t={}){if(!(i instanceof rc))return super.toDetectionStream(i,t);let{sampleSize:n=Ze}=t;return new Promise((a,s)=>{i.on("error",s),i.once("readable",()=>{(async()=>{try{let o=new oc,r=fa?fa(i,o,()=>{}):i.pipe(o),c=i.read(n)??i.read()??new Uint8Array(0);try{o.fileType=await this.fromBuffer(c)}catch(l){l instanceof B?o.fileType=void 0:s(l)}a(r)}catch(o){s(o)}})()})})}};async function ha(e,i){return new gt(i).fromFile(e,i)}var Xa=Ae(ka(),1);var Dt=(e,i,t)=>{let n=e instanceof RegExp?Ta(e,t):e,a=i instanceof RegExp?Ta(i,t):i,s=n!==null&&a!=null&&xc(n,a,t);return s&&{start:s[0],end:s[1],pre:t.slice(0,s[0]),body:t.slice(s[0]+n.length,s[1]),post:t.slice(s[1]+a.length)}},Ta=(e,i)=>{let t=i.match(e);return t?t[0]:null},xc=(e,i,t)=>{let n,a,s,o,r,c=t.indexOf(e),l=t.indexOf(i,c+1),u=c;if(c>=0&&l>0){if(e===i)return[c,l];for(n=[],s=t.length;u>=0&&!r;){if(u===c)n.push(u),c=t.indexOf(e,u+1);else if(n.length===1){let p=n.pop();p!==void 0&&(r=[p,l])}else a=n.pop(),a!==void 0&&a<s&&(s=a,o=l),l=t.indexOf(i,u+1);u=c<l&&c>=0?c:l}n.length&&o!==void 0&&(r=[s,o])}return r};var Ba="\0SLASH"+Math.random()+"\0",Sa="\0OPEN"+Math.random()+"\0",Ft="\0CLOSE"+Math.random()+"\0",Oa="\0COMMA"+Math.random()+"\0",Pa="\0PERIOD"+Math.random()+"\0",gc=new RegExp(Ba,"g"),vc=new RegExp(Sa,"g"),Dc=new RegExp(Ft,"g"),bc=new RegExp(Oa,"g"),Fc=new RegExp(Pa,"g"),wc=/\\\\/g,yc=/\\{/g,Ec=/\\}/g,Cc=/\\,/g,Ac=/\\./g;function bt(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function kc(e){return e.replace(wc,Ba).replace(yc,Sa).replace(Ec,Ft).replace(Cc,Oa).replace(Ac,Pa)}function Tc(e){return e.replace(gc,"\\").replace(vc,"{").replace(Dc,"}").replace(bc,",").replace(Fc,".")}function ja(e){if(!e)return[""];let i=[],t=Dt("{","}",e);if(!t)return e.split(",");let{pre:n,body:a,post:s}=t,o=n.split(",");o[o.length-1]+="{"+a+"}";let r=ja(s);return s.length&&(o[o.length-1]+=r.shift(),o.push.apply(o,r)),i.push.apply(i,o),i}function Ra(e){return e?(e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Je(kc(e),!0).map(Tc)):[]}function Bc(e){return"{"+e+"}"}function Sc(e){return/^-?0\d/.test(e)}function Oc(e,i){return e<=i}function Pc(e,i){return e>=i}function Je(e,i){let t=[],n=Dt("{","}",e);if(!n)return[e];let a=n.pre,s=n.post.length?Je(n.post,!1):[""];if(/\$$/.test(n.pre))for(let o=0;o<s.length;o++){let r=a+"{"+n.body+"}"+s[o];t.push(r)}else{let o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),r=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=o||r,l=n.body.indexOf(",")>=0;if(!c&&!l)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+Ft+n.post,Je(e)):[e];let u;if(c)u=n.body.split(/\.\./);else if(u=ja(n.body),u.length===1&&u[0]!==void 0&&(u=Je(u[0],!1).map(Bc),u.length===1))return s.map(m=>n.pre+u[0]+m);let p;if(c&&u[0]!==void 0&&u[1]!==void 0){let m=bt(u[0]),d=bt(u[1]),h=Math.max(u[0].length,u[1].length),f=u.length===3&&u[2]!==void 0?Math.abs(bt(u[2])):1,y=Oc;d<m&&(f*=-1,y=Pc);let g=u.some(Sc);p=[];for(let v=m;y(v,d);v+=f){let D;if(r)D=String.fromCharCode(v),D==="\\"&&(D="");else if(D=String(v),g){let U=h-D.length;if(U>0){let z=new Array(U+1).join("0");v<0?D="-"+z+D.slice(1):D=z+D}}p.push(D)}}else{p=[];for(let m=0;m<u.length;m++)p.push.apply(p,Je(u[m],!1))}for(let m=0;m<p.length;m++)for(let d=0;d<s.length;d++){let h=a+p[m]+s[d];(!i||c||h)&&t.push(h)}}return t}var Xe=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var jc={"[: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]},Qe=e=>e.replace(/[[\]\\-]/g,"\\$&"),Rc=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ia=e=>e.join(""),Ua=(e,i)=>{let t=i;if(e.charAt(t)!=="[")throw new Error("not in a brace expression");let n=[],a=[],s=t+1,o=!1,r=!1,c=!1,l=!1,u=t,p="";e:for(;s<e.length;){let f=e.charAt(s);if((f==="!"||f==="^")&&s===t+1){l=!0,s++;continue}if(f==="]"&&o&&!c){u=s+1;break}if(o=!0,f==="\\"&&!c){c=!0,s++;continue}if(f==="["&&!c){for(let[y,[T,g,v]]of Object.entries(jc))if(e.startsWith(y,s)){if(p)return["$.",!1,e.length-t,!0];s+=y.length,v?a.push(T):n.push(T),r=r||g;continue e}}if(c=!1,p){f>p?n.push(Qe(p)+"-"+Qe(f)):f===p&&n.push(Qe(f)),p="",s++;continue}if(e.startsWith("-]",s+1)){n.push(Qe(f+"-")),s+=2;continue}if(e.startsWith("-",s+1)){p=f,s+=2;continue}n.push(Qe(f)),s++}if(u<s)return["",!1,0,!1];if(!n.length&&!a.length)return["$.",!1,e.length-t,!0];if(a.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){let f=n[0].length===2?n[0].slice(-1):n[0];return[Rc(f),!1,u-t,!1]}let m="["+(l?"^":"")+Ia(n)+"]",d="["+(l?"":"^")+Ia(a)+"]";return[n.length&&a.length?"("+m+"|"+d+")":n.length?m:d,r,u-t,!0]};var he=(e,{windowsPathsNoEscape:i=!1}={})=>i?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var Ic=new Set(["!","?","+","*","@"]),za=e=>Ic.has(e),Uc="(?!(?:^|/)\\.\\.?(?:$|/))",Ci="(?!\\.)",zc=new Set(["[","."]),Lc=new Set(["..","."]),_c=new Set("().*{}+?[]^$\\!"),Mc=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),wt="[^/]",La=wt+"*?",_a=wt+"+?",je=class e{type;#a;#e;#i=!1;#t=[];#n;#s;#o;#c=!1;#r;#p;#l=!1;constructor(i,t,n={}){this.type=i,i&&(this.#e=!0),this.#n=t,this.#a=this.#n?this.#n.#a:this,this.#r=this.#a===this?n:this.#a.#r,this.#o=this.#a===this?[]:this.#a.#o,i==="!"&&!this.#a.#c&&this.#o.push(this),this.#s=this.#n?this.#n.#t.length:0}get hasMagic(){if(this.#e!==void 0)return this.#e;for(let i of this.#t)if(typeof i!="string"&&(i.type||i.hasMagic))return this.#e=!0;return this.#e}toString(){return this.#p!==void 0?this.#p:this.type?this.#p=this.type+"("+this.#t.map(i=>String(i)).join("|")+")":this.#p=this.#t.map(i=>String(i)).join("")}#d(){if(this!==this.#a)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let i;for(;i=this.#o.pop();){if(i.type!=="!")continue;let t=i,n=t.#n;for(;n;){for(let a=t.#s+1;!n.type&&a<n.#t.length;a++)for(let s of i.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#t[a])}t=n,n=t.#n}}return this}push(...i){for(let t of i)if(t!==""){if(typeof t!="string"&&!(t instanceof e&&t.#n===this))throw new Error("invalid part: "+t);this.#t.push(t)}}toJSON(){let i=this.type===null?this.#t.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#t.map(t=>t.toJSON())];return this.isStart()&&!this.type&&i.unshift([]),this.isEnd()&&(this===this.#a||this.#a.#c&&this.#n?.type==="!")&&i.push({}),i}isStart(){if(this.#a===this)return!0;if(!this.#n?.isStart())return!1;if(this.#s===0)return!0;let i=this.#n;for(let t=0;t<this.#s;t++){let n=i.#t[t];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#a===this||this.#n?.type==="!")return!0;if(!this.#n?.isEnd())return!1;if(!this.type)return this.#n?.isEnd();let i=this.#n?this.#n.#t.length:0;return this.#s===i-1}copyIn(i){typeof i=="string"?this.push(i):this.push(i.clone(this))}clone(i){let t=new e(this.type,i);for(let n of this.#t)t.copyIn(n);return t}static#u(i,t,n,a){let s=!1,o=!1,r=-1,c=!1;if(t.type===null){let d=n,h="";for(;d<i.length;){let f=i.charAt(d++);if(s||f==="\\"){s=!s,h+=f;continue}if(o){d===r+1?(f==="^"||f==="!")&&(c=!0):f==="]"&&!(d===r+2&&c)&&(o=!1),h+=f;continue}else if(f==="["){o=!0,r=d,c=!1,h+=f;continue}if(!a.noext&&za(f)&&i.charAt(d)==="("){t.push(h),h="";let y=new e(f,t);d=e.#u(i,y,d,a),t.push(y);continue}h+=f}return t.push(h),d}let l=n+1,u=new e(null,t),p=[],m="";for(;l<i.length;){let d=i.charAt(l++);if(s||d==="\\"){s=!s,m+=d;continue}if(o){l===r+1?(d==="^"||d==="!")&&(c=!0):d==="]"&&!(l===r+2&&c)&&(o=!1),m+=d;continue}else if(d==="["){o=!0,r=l,c=!1,m+=d;continue}if(za(d)&&i.charAt(l)==="("){u.push(m),m="";let h=new e(d,u);u.push(h),l=e.#u(i,h,l,a);continue}if(d==="|"){u.push(m),m="",p.push(u),u=new e(null,t);continue}if(d===")")return m===""&&t.#t.length===0&&(t.#l=!0),u.push(m),m="",t.push(...p,u),l;m+=d}return t.type=null,t.#e=void 0,t.#t=[i.substring(n-1)],l}static fromGlob(i,t={}){let n=new e(null,void 0,t);return e.#u(i,n,0,t),n}toMMPattern(){if(this!==this.#a)return this.#a.toMMPattern();let i=this.toString(),[t,n,a,s]=this.toRegExpSource();if(!(a||this.#e||this.#r.nocase&&!this.#r.nocaseMagicOnly&&i.toUpperCase()!==i.toLowerCase()))return n;let r=(this.#r.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,r),{_src:t,_glob:i})}get options(){return this.#r}toRegExpSource(i){let t=i??!!this.#r.dot;if(this.#a===this&&this.#d(),!this.type){let c=this.isStart()&&this.isEnd(),l=this.#t.map(d=>{let[h,f,y,T]=typeof d=="string"?e.#f(d,this.#e,c):d.toRegExpSource(i);return this.#e=this.#e||y,this.#i=this.#i||T,h}).join(""),u="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&Lc.has(this.#t[0]))){let h=zc,f=t&&h.has(l.charAt(0))||l.startsWith("\\.")&&h.has(l.charAt(2))||l.startsWith("\\.\\.")&&h.has(l.charAt(4)),y=!t&&!i&&h.has(l.charAt(0));u=f?Uc:y?Ci:""}let p="";return this.isEnd()&&this.#a.#c&&this.#n?.type==="!"&&(p="(?:$|\\/)"),[u+l+p,he(l),this.#e=!!this.#e,this.#i]}let n=this.type==="*"||this.type==="+",a=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#m(t);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString();return this.#t=[c],this.type=null,this.#e=void 0,[c,he(this.toString()),!1,!1]}let o=!n||i||t||!Ci?"":this.#m(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let r="";if(this.type==="!"&&this.#l)r=(this.isStart()&&!t?Ci:"")+_a;else{let c=this.type==="!"?"))"+(this.isStart()&&!t&&!i?Ci:"")+La+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;r=a+s+c}return[r,he(s),this.#e=!!this.#e,this.#i]}#m(i){return this.#t.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[n,a,s,o]=t.toRegExpSource(i);return this.#i=this.#i||o,n}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#f(i,t,n=!1){let a=!1,s="",o=!1;for(let r=0;r<i.length;r++){let c=i.charAt(r);if(a){a=!1,s+=(_c.has(c)?"\\":"")+c;continue}if(c==="\\"){r===i.length-1?s+="\\\\":a=!0;continue}if(c==="["){let[l,u,p,m]=Ua(i,r);if(p){s+=l,o=o||u,r+=p-1,t=t||m;continue}}if(c==="*"){n&&i==="*"?s+=_a:s+=La,t=!0;continue}if(c==="?"){s+=wt,t=!0;continue}s+=Mc(c)}return[s,he(i),!!t,o]}};var yt=(e,{windowsPathsNoEscape:i=!1}={})=>i?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var _=(e,i,t={})=>(Xe(i),!t.nocomment&&i.charAt(0)==="#"?!1:new Re(i,t).match(e)),Nc=/^\*+([^+@!?\*\[\(]*)$/,Wc=e=>i=>!i.startsWith(".")&&i.endsWith(e),qc=e=>i=>i.endsWith(e),$c=e=>(e=e.toLowerCase(),i=>!i.startsWith(".")&&i.toLowerCase().endsWith(e)),Gc=e=>(e=e.toLowerCase(),i=>i.toLowerCase().endsWith(e)),Hc=/^\*+\.\*+$/,Kc=e=>!e.startsWith(".")&&e.includes("."),Yc=e=>e!=="."&&e!==".."&&e.includes("."),Vc=/^\.\*+$/,Zc=e=>e!=="."&&e!==".."&&e.startsWith("."),Jc=/^\*+$/,Xc=e=>e.length!==0&&!e.startsWith("."),Qc=e=>e.length!==0&&e!=="."&&e!=="..",ep=/^\?+([^+@!?\*\[\(]*)?$/,ip=([e,i=""])=>{let t=Wa([e]);return i?(i=i.toLowerCase(),n=>t(n)&&n.toLowerCase().endsWith(i)):t},tp=([e,i=""])=>{let t=qa([e]);return i?(i=i.toLowerCase(),n=>t(n)&&n.toLowerCase().endsWith(i)):t},np=([e,i=""])=>{let t=qa([e]);return i?n=>t(n)&&n.endsWith(i):t},ap=([e,i=""])=>{let t=Wa([e]);return i?n=>t(n)&&n.endsWith(i):t},Wa=([e])=>{let i=e.length;return t=>t.length===i&&!t.startsWith(".")},qa=([e])=>{let i=e.length;return t=>t.length===i&&t!=="."&&t!==".."},$a=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ma={win32:{sep:"\\"},posix:{sep:"/"}},sp=$a==="win32"?Ma.win32.sep:Ma.posix.sep;_.sep=sp;var ee=Symbol("globstar **");_.GLOBSTAR=ee;var op="[^/]",rp=op+"*?",cp="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",pp="(?:(?!(?:\\/|^)\\.).)*?",up=(e,i={})=>t=>_(t,e,i);_.filter=up;var Q=(e,i={})=>Object.assign({},e,i),lp=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return _;let i=_;return Object.assign((n,a,s={})=>i(n,a,Q(e,s)),{Minimatch:class extends i.Minimatch{constructor(a,s={}){super(a,Q(e,s))}static defaults(a){return i.defaults(Q(e,a)).Minimatch}},AST:class extends i.AST{constructor(a,s,o={}){super(a,s,Q(e,o))}static fromGlob(a,s={}){return i.AST.fromGlob(a,Q(e,s))}},unescape:(n,a={})=>i.unescape(n,Q(e,a)),escape:(n,a={})=>i.escape(n,Q(e,a)),filter:(n,a={})=>i.filter(n,Q(e,a)),defaults:n=>i.defaults(Q(e,n)),makeRe:(n,a={})=>i.makeRe(n,Q(e,a)),braceExpand:(n,a={})=>i.braceExpand(n,Q(e,a)),match:(n,a,s={})=>i.match(n,a,Q(e,s)),sep:i.sep,GLOBSTAR:ee})};_.defaults=lp;var Ga=(e,i={})=>(Xe(e),i.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ra(e));_.braceExpand=Ga;var mp=(e,i={})=>new Re(e,i).makeRe();_.makeRe=mp;var dp=(e,i,t={})=>{let n=new Re(i,t);return e=e.filter(a=>n.match(a)),n.options.nonull&&!e.length&&e.push(i),e};_.match=dp;var Na=/[?*]|[+@!]\(.*?\)|\[|\]/,fp=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Re=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(i,t={}){Xe(i),t=t||{},this.options=t,this.pattern=i,this.platform=t.platform||$a,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!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 i of this.set)for(let t of i)if(typeof t!="string")return!0;return!1}debug(...i){}make(){let i=this.pattern,t=this.options;if(!t.nocomment&&i.charAt(0)==="#"){this.comment=!0;return}if(!i){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let a=this.globParts.map((s,o,r)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!Na.test(s[2]))&&!Na.test(s[3]),l=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(u=>this.parse(u))];if(l)return[s[0],...s.slice(1).map(u=>this.parse(u))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,a),this.set=a.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(i){if(this.options.noglobstar)for(let n=0;n<i.length;n++)for(let a=0;a<i[n].length;a++)i[n][a]==="**"&&(i[n][a]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(i=this.firstPhasePreProcess(i),i=this.secondPhasePreProcess(i)):t>=1?i=this.levelOneOptimize(i):i=this.adjascentGlobstarOptimize(i),i}adjascentGlobstarOptimize(i){return i.map(t=>{let n=-1;for(;(n=t.indexOf("**",n+1))!==-1;){let a=n;for(;t[a+1]==="**";)a++;a!==n&&t.splice(n,a-n)}return t})}levelOneOptimize(i){return i.map(t=>(t=t.reduce((n,a)=>{let s=n[n.length-1];return a==="**"&&s==="**"?n:a===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(a),n)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(i){Array.isArray(i)||(i=this.slashSplit(i));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let a=1;a<i.length-1;a++){let s=i[a];a===1&&s===""&&i[0]===""||(s==="."||s==="")&&(t=!0,i.splice(a,1),a--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(t=!0,i.pop())}let n=0;for(;(n=i.indexOf("..",n+1))!==-1;){let a=i[n-1];a&&a!=="."&&a!==".."&&a!=="**"&&(t=!0,i.splice(n-1,2),n-=2)}}while(t);return i.length===0?[""]:i}firstPhasePreProcess(i){let t=!1;do{t=!1;for(let n of i){let a=-1;for(;(a=n.indexOf("**",a+1))!==-1;){let o=a;for(;n[o+1]==="**";)o++;o>a&&n.splice(a+1,o-a);let r=n[a+1],c=n[a+2],l=n[a+3];if(r!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;t=!0,n.splice(a,1);let u=n.slice(0);u[a]="**",i.push(u),a--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let r=n[o];o===1&&r===""&&n[0]===""||(r==="."||r==="")&&(t=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(t=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(t);return i}secondPhasePreProcess(i){for(let t=0;t<i.length-1;t++)for(let n=t+1;n<i.length;n++){let a=this.partsMatch(i[t],i[n],!this.preserveMultipleSlashes);if(a){i[t]=[],i[n]=a;break}}return i.filter(t=>t.length)}partsMatch(i,t,n=!1){let a=0,s=0,o=[],r="";for(;a<i.length&&s<t.length;)if(i[a]===t[s])o.push(r==="b"?t[s]:i[a]),a++,s++;else if(n&&i[a]==="**"&&t[s]===i[a+1])o.push(i[a]),a++;else if(n&&t[s]==="**"&&i[a]===t[s+1])o.push(t[s]),s++;else if(i[a]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(r==="b")return!1;r="a",o.push(i[a]),a++,s++}else if(t[s]==="*"&&i[a]&&(this.options.dot||!i[a].startsWith("."))&&i[a]!=="**"){if(r==="a")return!1;r="b",o.push(t[s]),a++,s++}else return!1;return i.length===t.length&&o}parseNegate(){if(this.nonegate)return;let i=this.pattern,t=!1,n=0;for(let a=0;a<i.length&&i.charAt(a)==="!";a++)t=!t,n++;n&&(this.pattern=i.slice(n)),this.negate=t}matchOne(i,t,n=!1){let a=this.options;if(this.isWindows){let f=typeof i[0]=="string"&&/^[a-z]:$/i.test(i[0]),y=!f&&i[0]===""&&i[1]===""&&i[2]==="?"&&/^[a-z]:$/i.test(i[3]),T=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),g=!T&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),v=y?3:f?0:void 0,D=g?3:T?0:void 0;if(typeof v=="number"&&typeof D=="number"){let[U,z]=[i[v],t[D]];U.toLowerCase()===z.toLowerCase()&&(t[D]=U,D>v?t=t.slice(D):v>D&&(i=i.slice(v)))}}let{optimizationLevel:s=1}=this.options;s>=2&&(i=this.levelTwoFileOptimize(i)),this.debug("matchOne",this,{file:i,pattern:t}),this.debug("matchOne",i.length,t.length);for(var o=0,r=0,c=i.length,l=t.length;o<c&&r<l;o++,r++){this.debug("matchOne loop");var u=t[r],p=i[o];if(this.debug(t,u,p),u===!1)return!1;if(u===ee){this.debug("GLOBSTAR",[t,u,p]);var m=o,d=r+1;if(d===l){for(this.debug("** at the end");o<c;o++)if(i[o]==="."||i[o]===".."||!a.dot&&i[o].charAt(0)===".")return!1;return!0}for(;m<c;){var h=i[m];if(this.debug(`
21
21
  globstar while`,i,m,t,d,h),this.matchOne(i.slice(m),t.slice(d),n))return this.debug("globstar found match!",m,c,h),!0;if(h==="."||h===".."||!a.dot&&h.charAt(0)==="."){this.debug("dot detected!",i,m,t,d);break}this.debug("globstar swallow a segment, and continue"),m++}return!!(n&&(this.debug(`
22
22
  >>> no match, partial?`,i,m,t,d),m===c))}let f;if(typeof u=="string"?(f=p===u,this.debug("string match",u,p,f)):(f=u.test(p),this.debug("pattern match",u,p,f)),!f)return!1}if(o===c&&r===l)return!0;if(o===c)return n;if(r===l)return o===c-1&&i[o]==="";throw new Error("wtf?")}braceExpand(){return Ga(this.pattern,this.options)}parse(i){Xe(i);let t=this.options;if(i==="**")return ee;if(i==="")return"";let n,a=null;(n=i.match(Jc))?a=t.dot?Qc:Xc:(n=i.match(Nc))?a=(t.nocase?t.dot?Gc:$c:t.dot?qc:Wc)(n[1]):(n=i.match(ep))?a=(t.nocase?t.dot?tp:ip:t.dot?np:ap)(n):(n=i.match(Hc))?a=t.dot?Yc:Kc:(n=i.match(Vc))&&(a=Zc);let s=je.fromGlob(i,this.options).toMMPattern();return a&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:a}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let i=this.set;if(!i.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?rp:t.dot?cp:pp,a=new Set(t.nocase?["i"]:[]),s=i.map(c=>{let l=c.map(u=>{if(u instanceof RegExp)for(let p of u.flags.split(""))a.add(p);return typeof u=="string"?fp(u):u===ee?ee:u._src});return l.forEach((u,p)=>{let m=l[p+1],d=l[p-1];u!==ee||d===ee||(d===void 0?m!==void 0&&m!==ee?l[p+1]="(?:\\/|"+n+"\\/)?"+m:l[p]=n:m===void 0?l[p-1]=d+"(?:\\/|"+n+")?":m!==ee&&(l[p-1]=d+"(?:\\/|\\/"+n+"\\/)"+m,l[p+1]=ee))}),l.filter(u=>u!==ee).join("/")}).join("|"),[o,r]=i.length>1?["(?:",")"]:["",""];s="^"+o+s+r+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...a].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(i){return this.preserveMultipleSlashes?i.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(i)?["",...i.split(/\/+/)]:i.split(/\/+/)}match(i,t=this.partial){if(this.debug("match",i,this.pattern),this.comment)return!1;if(this.empty)return i==="";if(i==="/"&&t)return!0;let n=this.options;this.isWindows&&(i=i.split("\\").join("/"));let a=this.slashSplit(i);this.debug(this.pattern,"split",a);let s=this.set;this.debug(this.pattern,"set",s);let o=a[a.length-1];if(!o)for(let r=a.length-2;!o&&r>=0;r--)o=a[r];for(let r=0;r<s.length;r++){let c=s[r],l=a;if(n.matchBase&&c.length===1&&(l=[o]),this.matchOne(l,c,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(i){return _.defaults(i).Minimatch}};_.AST=je;_.Minimatch=Re;_.escape=yt;_.unescape=he;import{readFile as Sp}from"node:fs/promises";import{extname as Ja,join as Op}from"node:path";import{createReadStream as hp,createWriteStream as xp}from"node:fs";import{Readable as gp}from"node:stream";import{createBrotliCompress as vp,createGunzip as Dp,createGzip as bp}from"node:zlib";var If=async({source:e})=>await new Promise((i,t)=>{let n=gp.from(e),a=[],s=Dp();n.pipe(s),s.on("data",o=>a.push(o)),s.on("end",()=>{i(Buffer.concat(a))}),s.on("error",t)}),Ha=async({sourceFiles:e,precompress:i})=>{if(i===!1)return[];let t=Array.isArray(i)?i:[i];return(await Promise.all(t.map(async a=>await Fp({sourceFiles:e,precompress:a})))).reduce((a,s)=>[...a,...s],[])},Fp=async({sourceFiles:e,precompress:i})=>{let t=i===!0?le.pattern:i.pattern??le.pattern,n=i===!0?le.algorithm:i.algorithm??le.algorithm,a=e.filter(s=>_(s,t));return await Promise.all(a.map(async s=>({source:s,compressed:await Et({source:s,algorithm:n}),mode:i?.mode??le.mode})))},Uf=async e=>await Et({...e,algorithm:"gzip"}),zf=async e=>await Et({...e,algorithm:"brotli"}),Et=async({source:e,algorithm:i,destination:t})=>await new Promise((n,a)=>{let s=hp(e),o=t??`${e}.${i==="brotli"?"br":"gz"}`,r=xp(o),c=i==="brotli"?vp():bp();s.pipe(c).pipe(r),r.on("close",()=>{n(o)}),r.on("error",a)}),Lf=e=>e.length>2&&e[0]===31&&e[1]===139;import{lstatSync as Ep}from"node:fs";import{basename as Cp}from"node:path";import{lstatSync as Ya,readdirSync as wp}from"node:fs";import{access as yp}from"node:fs/promises";import{join as Ka}from"node:path";var Ct=e=>wp(e).flatMap(i=>{let t=Ka(e,i);return Ya(t).isDirectory()?Ct(t):Ka(t)}),qf=async e=>{try{return await yp(e),!0}catch(i){if(i instanceof Error&&"code"in i&&i.code==="ENOENT")return!1;throw i}},Va=e=>{let{size:i}=Ya(e);return i};var Ai=({file:e,sourceAbsolutePath:i})=>e.replace(i,"").replace(/\\/g,"/"),Za=({sourceAbsolutePath:e,ignore:i})=>Ct(e).filter(n=>Ap({file:n,ignore:i})),Ap=({file:e,ignore:i})=>Ep(e).size<=0||Fn.includes(Cp(e).toLowerCase())?!1:i.find(t=>_(e,t))===void 0;var Qa=async({config:e,listAssets:i,assertSourceDirExists:t,includeAllFiles:n})=>{let{source:a=vn,ignore:s=Dn,encoding:o=bn,precompress:r=le}=e,c=Op(process.cwd(),a);return t?.(c),{files:await Ip({sourceAbsolutePath:c,ignore:s,encoding:o,precompress:r,listAssets:i,includeAllFiles:n}),sourceAbsolutePath:c}},Pp=async({files:e,sourceAbsolutePath:i,listAssets:t})=>{let n=await t({}),a=e.map(async o=>await Rp({file:o,sourceAbsolutePath:i,existingAssets:n}));return(await Promise.all(a)).filter(({upload:o})=>o).map(({file:o})=>o)},jp=async e=>{let i=await Sp(e);return Bp.createHash("sha256").update(i).digest("base64")},Rp=async({file:e,existingAssets:i,sourceAbsolutePath:t})=>{let n=e.alternateFile??e.file,a=i.find(({fullPath:c})=>c===Ai({file:n,sourceAbsolutePath:t}));if(kp(a))return{file:e,upload:!0};let{encoding:s,file:o}=e,r=await jp(o);return{file:e,upload:r!==a.encodings[s??"identity"]?.sha256}},Ip=async({sourceAbsolutePath:e,ignore:i,encoding:t,precompress:n,listAssets:a,includeAllFiles:s})=>{let o=Za({sourceAbsolutePath:e,ignore:i}),c=(await Ha({sourceFiles:o,precompress:n})).filter(({compressed:g})=>!o.includes(g)),l=o.filter(g=>c.find(({source:v})=>v===g)===void 0),u=({file:g,ext:v})=>{let D=t.find(([U,z])=>_(g,U));if(Tp(D)){let[U,z]=D;return z}if(v==="Z")return"compress";if(v==="gz")return"gzip";if(Ja(g).toLowerCase()===".br")return"br";if(Ja(g).toLowerCase()===".zlib")return"deflate"},p=async({file:g,alternateFile:v})=>{let D=await ha(g),U=u({file:g,ext:D?.ext}),z=Xa.default.lookup(v??g);return{file:g,alternateFile:v,mime:typeof z=="string"?z:void 0,encoding:U}},m=await Promise.all(l.map(async g=>await p({file:g}))),d=async({source:g,compressed:v})=>{let D=async()=>await p({file:v,alternateFile:g}),U=async()=>await p({file:g});return await Promise.all([D(),U()])},h=async({compressed:g,source:v})=>await(async()=>await p({file:g,alternateFile:v}))(),f=await Promise.all(c.filter(({mode:g})=>g==="both").map(async({source:g,compressed:v})=>await d({source:g,compressed:v}))),T=[...await Promise.all(c.filter(({mode:g})=>g==="replace").map(async({source:g,compressed:v})=>await h({source:g,compressed:v}))),...f.flatMap(g=>g),...m];return s===!0?T:await Pp({files:T,sourceAbsolutePath:e,listAssets:a})};import{fromNullable as Up,isNullish as zp,uint8ArrayToHexString as Lp}from"@dfinity/utils";import{commitProposal as _p,initProposal as Mp,submitProposal as Np}from"@junobuild/cdn";import At from"ora";var es=async({proposalType:e,cdn:i,executeChanges:t,autoCommit:n})=>{let a=async()=>{let l=At("Opening proposal...").start();try{let[u,p]=await Mp({proposalType:e,cdn:i});return{proposalId:u}}finally{l.stop()}},{proposalId:s}=await a();await t(s);let o=async()=>{console.log("");let l=At("Submitting proposal...").start();try{let[u,{sha256:p,status:m}]=await Np({cdn:i,proposalId:s}),d=Up(p);return l.stop(),console.log(`Change submitted.