@zenfs/dom 0.0.2 → 0.0.3
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.
|
@@ -15,7 +15,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
15
15
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
16
16
|
};
|
|
17
17
|
var _a;
|
|
18
|
-
import { basename, dirname, join } from 'path';
|
|
18
|
+
import { basename, dirname, join } from '@zenfs/core/emulation/path.js';
|
|
19
19
|
import { ApiError, ErrorCode } from '@zenfs/core/ApiError.js';
|
|
20
20
|
import { Cred } from '@zenfs/core/cred.js';
|
|
21
21
|
import { FileFlag, PreloadFile } from '@zenfs/core/file.js';
|
|
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
var _a;
|
|
11
11
|
import { BaseFileSystem } from '@zenfs/core/filesystem.js';
|
|
12
12
|
import { ApiError, ErrorCode } from '@zenfs/core/ApiError.js';
|
|
13
|
-
import { copyingSlice } from '@zenfs/core/utils.js';
|
|
14
13
|
import { ActionType, NoSyncFile } from '@zenfs/core/file.js';
|
|
15
14
|
import { Stats } from '@zenfs/core/stats.js';
|
|
16
15
|
import { fetchIsAvailable, fetchFile, fetchFileSize } from '../fetch.js';
|
|
17
16
|
import { FileIndex, isIndexFileInode, isIndexDirInode } from '@zenfs/core/FileIndex.js';
|
|
18
17
|
import { CreateBackend } from '@zenfs/core/backends/backend.js';
|
|
19
18
|
import { R_OK } from '@zenfs/core/emulation/constants.js';
|
|
19
|
+
import { Buffer } from 'buffer';
|
|
20
20
|
/**
|
|
21
21
|
* A simple filesystem backed by HTTP downloads. You must create a directory listing using the
|
|
22
22
|
* `make_http_index` tool provided by ZenFS.
|
|
@@ -181,7 +181,7 @@ export class HTTPRequest extends BaseFileSystem {
|
|
|
181
181
|
const fdCast = fd;
|
|
182
182
|
const fdBuff = fdCast.getBuffer();
|
|
183
183
|
if (encoding === null) {
|
|
184
|
-
return
|
|
184
|
+
return Buffer.from(fdBuff);
|
|
185
185
|
}
|
|
186
186
|
return fdBuff.toString(encoding);
|
|
187
187
|
}
|
|
@@ -3,18 +3,6 @@ import { AsyncKeyValueFileSystem } from '@zenfs/core/backends/AsyncStore.js';
|
|
|
3
3
|
import { ApiError, ErrorCode } from '@zenfs/core/ApiError.js';
|
|
4
4
|
import { Buffer } from 'buffer';
|
|
5
5
|
import { CreateBackend } from '@zenfs/core/backends/backend.js';
|
|
6
|
-
/**
|
|
7
|
-
* Get the indexedDB constructor for the current browser.
|
|
8
|
-
* @hidden
|
|
9
|
-
*/
|
|
10
|
-
const indexedDB = (() => {
|
|
11
|
-
try {
|
|
12
|
-
return globalThis.indexedDB || globalThis.mozIndexedDB || globalThis.webkitIndexedDB || globalThis.msIndexedDB;
|
|
13
|
-
}
|
|
14
|
-
catch (_b) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
})();
|
|
18
6
|
/**
|
|
19
7
|
* Converts a DOMException or a DOMError from an IndexedDB event into a
|
|
20
8
|
* standardized ZenFS API error.
|
|
@@ -195,7 +183,7 @@ export class IndexedDBFileSystem extends AsyncKeyValueFileSystem {
|
|
|
195
183
|
if (!(idbFactory instanceof IDBFactory)) {
|
|
196
184
|
return false;
|
|
197
185
|
}
|
|
198
|
-
const req =
|
|
186
|
+
const req = idbFactory.open('__zenfs_test__');
|
|
199
187
|
if (!req) {
|
|
200
188
|
return false;
|
|
201
189
|
}
|
|
@@ -5,9 +5,9 @@ import { type BackendOptions } from '@zenfs/core/backends/backend.js';
|
|
|
5
5
|
* A synchronous key-value store backed by Storage.
|
|
6
6
|
*/
|
|
7
7
|
export declare class StorageStore implements SyncKeyValueStore, SimpleSyncStore {
|
|
8
|
-
protected _storage:
|
|
8
|
+
protected _storage: Storage;
|
|
9
9
|
name(): string;
|
|
10
|
-
constructor(_storage:
|
|
10
|
+
constructor(_storage: Storage);
|
|
11
11
|
clear(): void;
|
|
12
12
|
beginTransaction(type: string): SyncKeyValueRWTransaction;
|
|
13
13
|
get(key: string): Buffer | undefined;
|
package/dist/browser.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var ZenFS_DOM=(()=>{var Mt=Object.defineProperty,wr=Object.defineProperties,gr=Object.getOwnPropertyDescriptor,Er=Object.getOwnPropertyDescriptors,Sr=Object.getOwnPropertyNames,De=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,Ir=Object.prototype.propertyIsEnumerable;var U=Math.pow,Ue=(d,t,e)=>t in d?Mt(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,yt=(d,t)=>{for(var e in t||(t={}))Le.call(t,e)&&Ue(d,e,t[e]);if(De)for(var e of De(t))Ir.call(t,e)&&Ue(d,e,t[e]);return d},At=(d,t)=>wr(d,Er(t)),h=(d,t)=>Mt(d,"name",{value:t,configurable:!0});var xr=(d,t)=>{for(var e in t)Mt(d,e,{get:t[e],enumerable:!0})},br=(d,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Sr(t))!Le.call(d,s)&&s!==e&&Mt(d,s,{get:()=>t[s],enumerable:!(o=gr(t,s))||o.enumerable});return d};var Nr=d=>br(Mt({},"__esModule",{value:!0}),d);var P=(d,t,e)=>new Promise((o,s)=>{var c=p=>{try{l(e.next(p))}catch(w){s(w)}},n=p=>{try{l(e.throw(p))}catch(w){s(w)}},l=p=>p.done?o(p.value):Promise.resolve(p.value).then(c,n);l((e=e.apply(d,t)).next())}),ke=(d,t,e)=>(t=d[Symbol.asyncIterator],e=(o,s)=>(s=d[o])&&(t[o]=c=>new Promise((n,l,p)=>(c=s.call(d,c),p=c.done,Promise.resolve(c.value).then(w=>n({value:w,done:p}),l)))),t?t.call(d):(d=d[Symbol.iterator](),t={},e("next"),e("return"),t));var Dr={};xr(Dr,{FileSystemAccessFile:()=>Wt,FileSystemAccessFileSystem:()=>Nt,HTTPRequest:()=>_t,IndexedDBFileSystem:()=>pt,IndexedDBROTransaction:()=>Lt,IndexedDBRWTransaction:()=>Gt,IndexedDBStore:()=>Tt,StorageFileSystem:()=>mt,StorageStore:()=>Zt,WorkerFS:()=>Ot});var zt={},Me=!1;function vr(){if(Me)return zt;Me=!0,zt.byteLength=l,zt.toByteArray=w,zt.fromByteArray=b;for(var d=[],t=[],e=typeof Uint8Array!="undefined"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=o.length;s<c;++s)d[s]=o[s],t[o.charCodeAt(s)]=s;t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63;function n(x){var N=x.length;if(N%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var v=x.indexOf("=");v===-1&&(v=N);var _=v===N?0:4-v%4;return[v,_]}h(n,"getLens");function l(x){var N=n(x),v=N[0],_=N[1];return(v+_)*3/4-_}h(l,"byteLength");function p(x,N,v){return(N+v)*3/4-v}h(p,"_byteLength");function w(x){var N,v=n(x),_=v[0],F=v[1],C=new e(p(x,_,F)),$=0,it=F>0?_-4:_,Q;for(Q=0;Q<it;Q+=4)N=t[x.charCodeAt(Q)]<<18|t[x.charCodeAt(Q+1)]<<12|t[x.charCodeAt(Q+2)]<<6|t[x.charCodeAt(Q+3)],C[$++]=N>>16&255,C[$++]=N>>8&255,C[$++]=N&255;return F===2&&(N=t[x.charCodeAt(Q)]<<2|t[x.charCodeAt(Q+1)]>>4,C[$++]=N&255),F===1&&(N=t[x.charCodeAt(Q)]<<10|t[x.charCodeAt(Q+1)]<<4|t[x.charCodeAt(Q+2)]>>2,C[$++]=N>>8&255,C[$++]=N&255),C}h(w,"toByteArray");function m(x){return d[x>>18&63]+d[x>>12&63]+d[x>>6&63]+d[x&63]}h(m,"tripletToBase64");function E(x,N,v){for(var _,F=[],C=N;C<v;C+=3)_=(x[C]<<16&16711680)+(x[C+1]<<8&65280)+(x[C+2]&255),F.push(m(_));return F.join("")}h(E,"encodeChunk");function b(x){for(var N,v=x.length,_=v%3,F=[],C=16383,$=0,it=v-_;$<it;$+=C)F.push(E(x,$,$+C>it?it:$+C));return _===1?(N=x[v-1],F.push(d[N>>2]+d[N<<4&63]+"==")):_===2&&(N=(x[v-2]<<8)+x[v-1],F.push(d[N>>10]+d[N>>4&63]+d[N<<2&63]+"=")),F.join("")}return h(b,"fromByteArray"),zt}h(vr,"dew$2");var re={},ze=!1;function _r(){if(ze)return re;ze=!0;return re.read=function(d,t,e,o,s){var c,n,l=s*8-o-1,p=(1<<l)-1,w=p>>1,m=-7,E=e?s-1:0,b=e?-1:1,x=d[t+E];for(E+=b,c=x&(1<<-m)-1,x>>=-m,m+=l;m>0;c=c*256+d[t+E],E+=b,m-=8);for(n=c&(1<<-m)-1,c>>=-m,m+=o;m>0;n=n*256+d[t+E],E+=b,m-=8);if(c===0)c=1-w;else{if(c===p)return n?NaN:(x?-1:1)*(1/0);n=n+Math.pow(2,o),c=c-w}return(x?-1:1)*n*Math.pow(2,c-o)},re.write=function(d,t,e,o,s,c){var n,l,p,w=c*8-s-1,m=(1<<w)-1,E=m>>1,b=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=o?0:c-1,N=o?1:-1,v=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,n=m):(n=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-n))<1&&(n--,p*=2),n+E>=1?t+=b/p:t+=b*Math.pow(2,1-E),t*p>=2&&(n++,p/=2),n+E>=m?(l=0,n=m):n+E>=1?(l=(t*p-1)*Math.pow(2,s),n=n+E):(l=t*Math.pow(2,E-1)*Math.pow(2,s),n=0));s>=8;d[e+x]=l&255,x+=N,l/=256,s-=8);for(n=n<<s|l,w+=s;w>0;d[e+x]=n&255,x+=N,n/=256,w-=8);d[e+x-N]|=v*128},re}h(_r,"dew$1");var wt={},$e=!1;function Tr(){if($e)return wt;$e=!0;let d=vr(),t=_r(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;wt.Buffer=n,wt.SlowBuffer=F,wt.INSPECT_MAX_BYTES=50;let o=2147483647;wt.kMaxLength=o,n.TYPED_ARRAY_SUPPORT=s(),!n.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{let a=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(a,r),a.foo()===42}catch(a){return!1}}h(s,"typedArraySupport"),Object.defineProperty(n.prototype,"parent",{enumerable:!0,get:function(){if(n.isBuffer(this))return this.buffer}}),Object.defineProperty(n.prototype,"offset",{enumerable:!0,get:function(){if(n.isBuffer(this))return this.byteOffset}});function c(a){if(a>o)throw new RangeError('The value "'+a+'" is invalid for option "size"');let r=new Uint8Array(a);return Object.setPrototypeOf(r,n.prototype),r}h(c,"createBuffer");function n(a,r,i){if(typeof a=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(a)}return l(a,r,i)}h(n,"Buffer"),n.poolSize=8192;function l(a,r,i){if(typeof a=="string")return E(a,r);if(ArrayBuffer.isView(a))return x(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(at(a,ArrayBuffer)||a&&at(a.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(at(a,SharedArrayBuffer)||a&&at(a.buffer,SharedArrayBuffer)))return N(a,r,i);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=a.valueOf&&a.valueOf();if(u!=null&&u!==a)return n.from(u,r,i);let f=v(a);if(f)return f;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return n.from(a[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}h(l,"from"),n.from=function(a,r,i){return l(a,r,i)},Object.setPrototypeOf(n.prototype,Uint8Array.prototype),Object.setPrototypeOf(n,Uint8Array);function p(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}h(p,"assertSize");function w(a,r,i){return p(a),a<=0?c(a):r!==void 0?typeof i=="string"?c(a).fill(r,i):c(a).fill(r):c(a)}h(w,"alloc"),n.alloc=function(a,r,i){return w(a,r,i)};function m(a){return p(a),c(a<0?0:_(a)|0)}h(m,"allocUnsafe"),n.allocUnsafe=function(a){return m(a)},n.allocUnsafeSlow=function(a){return m(a)};function E(a,r){if((typeof r!="string"||r==="")&&(r="utf8"),!n.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let i=C(a,r)|0,u=c(i),f=u.write(a,r);return f!==i&&(u=u.slice(0,f)),u}h(E,"fromString");function b(a){let r=a.length<0?0:_(a.length)|0,i=c(r);for(let u=0;u<r;u+=1)i[u]=a[u]&255;return i}h(b,"fromArrayLike");function x(a){if(at(a,Uint8Array)){let r=new Uint8Array(a);return N(r.buffer,r.byteOffset,r.byteLength)}return b(a)}h(x,"fromArrayView");function N(a,r,i){if(r<0||a.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let u;return r===void 0&&i===void 0?u=new Uint8Array(a):i===void 0?u=new Uint8Array(a,r):u=new Uint8Array(a,r,i),Object.setPrototypeOf(u,n.prototype),u}h(N,"fromArrayBuffer");function v(a){if(n.isBuffer(a)){let r=_(a.length)|0,i=c(r);return i.length===0||a.copy(i,0,0,r),i}if(a.length!==void 0)return typeof a.length!="number"||we(a.length)?c(0):b(a);if(a.type==="Buffer"&&Array.isArray(a.data))return b(a.data)}h(v,"fromObject");function _(a){if(a>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return a|0}h(_,"checked");function F(a){return+a!=a&&(a=0),n.alloc(+a)}h(F,"SlowBuffer"),n.isBuffer=h(function(r){return r!=null&&r._isBuffer===!0&&r!==n.prototype},"isBuffer"),n.compare=h(function(r,i){if(at(r,Uint8Array)&&(r=n.from(r,r.offset,r.byteLength)),at(i,Uint8Array)&&(i=n.from(i,i.offset,i.byteLength)),!n.isBuffer(r)||!n.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let u=r.length,f=i.length;for(let g=0,S=Math.min(u,f);g<S;++g)if(r[g]!==i[g]){u=r[g],f=i[g];break}return u<f?-1:f<u?1:0},"compare"),n.isEncoding=h(function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},"isEncoding"),n.concat=h(function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return n.alloc(0);let u;if(i===void 0)for(i=0,u=0;u<r.length;++u)i+=r[u].length;let f=n.allocUnsafe(i),g=0;for(u=0;u<r.length;++u){let S=r[u];if(at(S,Uint8Array))g+S.length>f.length?(n.isBuffer(S)||(S=n.from(S)),S.copy(f,g)):Uint8Array.prototype.set.call(f,S,g);else if(n.isBuffer(S))S.copy(f,g);else throw new TypeError('"list" argument must be an Array of Buffers');g+=S.length}return f},"concat");function C(a,r){if(n.isBuffer(a))return a.length;if(ArrayBuffer.isView(a)||at(a,ArrayBuffer))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);let i=a.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&i===0)return 0;let f=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return ye(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return Pe(a).length;default:if(f)return u?-1:ye(a).length;r=(""+r).toLowerCase(),f=!0}}h(C,"byteLength"),n.byteLength=C;function $(a,r,i){let u=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(a||(a="utf8");;)switch(a){case"hex":return cr(this,r,i);case"utf8":case"utf-8":return ve(this,r,i);case"ascii":return sr(this,r,i);case"latin1":case"binary":return ar(this,r,i);case"base64":return nr(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ur(this,r,i);default:if(u)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),u=!0}}h($,"slowToString"),n.prototype._isBuffer=!0;function it(a,r,i){let u=a[r];a[r]=a[i],a[i]=u}h(it,"swap"),n.prototype.swap16=h(function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)it(this,i,i+1);return this},"swap16"),n.prototype.swap32=h(function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)it(this,i,i+3),it(this,i+1,i+2);return this},"swap32"),n.prototype.swap64=h(function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)it(this,i,i+7),it(this,i+1,i+6),it(this,i+2,i+5),it(this,i+3,i+4);return this},"swap64"),n.prototype.toString=h(function(){let r=this.length;return r===0?"":arguments.length===0?ve(this,0,r):$.apply(this,arguments)},"toString"),n.prototype.toLocaleString=n.prototype.toString,n.prototype.equals=h(function(r){if(!n.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:n.compare(this,r)===0},"equals"),n.prototype.inspect=h(function(){let r="",i=wt.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},"inspect"),e&&(n.prototype[e]=n.prototype.inspect),n.prototype.compare=h(function(r,i,u,f,g){if(at(r,Uint8Array)&&(r=n.from(r,r.offset,r.byteLength)),!n.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),u===void 0&&(u=r?r.length:0),f===void 0&&(f=0),g===void 0&&(g=this.length),i<0||u>r.length||f<0||g>this.length)throw new RangeError("out of range index");if(f>=g&&i>=u)return 0;if(f>=g)return-1;if(i>=u)return 1;if(i>>>=0,u>>>=0,f>>>=0,g>>>=0,this===r)return 0;let S=g-f,O=u-i,j=Math.min(S,O),k=this.slice(f,g),Y=r.slice(i,u);for(let R=0;R<j;++R)if(k[R]!==Y[R]){S=k[R],O=Y[R];break}return S<O?-1:O<S?1:0},"compare");function Q(a,r,i,u,f){if(a.length===0)return-1;if(typeof i=="string"?(u=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,we(i)&&(i=f?0:a.length-1),i<0&&(i=a.length+i),i>=a.length){if(f)return-1;i=a.length-1}else if(i<0)if(f)i=0;else return-1;if(typeof r=="string"&&(r=n.from(r,u)),n.isBuffer(r))return r.length===0?-1:Ne(a,r,i,u,f);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?f?Uint8Array.prototype.indexOf.call(a,r,i):Uint8Array.prototype.lastIndexOf.call(a,r,i):Ne(a,[r],i,u,f);throw new TypeError("val must be string, number or Buffer")}h(Q,"bidirectionalIndexOf");function Ne(a,r,i,u,f){let g=1,S=a.length,O=r.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(a.length<2||r.length<2)return-1;g=2,S/=2,O/=2,i/=2}function j(Y,R){return g===1?Y[R]:Y.readUInt16BE(R*g)}h(j,"read");let k;if(f){let Y=-1;for(k=i;k<S;k++)if(j(a,k)===j(r,Y===-1?0:k-Y)){if(Y===-1&&(Y=k),k-Y+1===O)return Y*g}else Y!==-1&&(k-=k-Y),Y=-1}else for(i+O>S&&(i=S-O),k=i;k>=0;k--){let Y=!0;for(let R=0;R<O;R++)if(j(a,k+R)!==j(r,R)){Y=!1;break}if(Y)return k}return-1}h(Ne,"arrayIndexOf"),n.prototype.includes=h(function(r,i,u){return this.indexOf(r,i,u)!==-1},"includes"),n.prototype.indexOf=h(function(r,i,u){return Q(this,r,i,u,!0)},"indexOf"),n.prototype.lastIndexOf=h(function(r,i,u){return Q(this,r,i,u,!1)},"lastIndexOf");function Ze(a,r,i,u){i=Number(i)||0;let f=a.length-i;u?(u=Number(u),u>f&&(u=f)):u=f;let g=r.length;u>g/2&&(u=g/2);let S;for(S=0;S<u;++S){let O=parseInt(r.substr(S*2,2),16);if(we(O))return S;a[i+S]=O}return S}h(Ze,"hexWrite");function tr(a,r,i,u){return ee(ye(r,a.length-i),a,i,u)}h(tr,"utf8Write");function er(a,r,i,u){return ee(fr(r),a,i,u)}h(er,"asciiWrite");function rr(a,r,i,u){return ee(Pe(r),a,i,u)}h(rr,"base64Write");function ir(a,r,i,u){return ee(pr(r,a.length-i),a,i,u)}h(ir,"ucs2Write"),n.prototype.write=h(function(r,i,u,f){if(i===void 0)f="utf8",u=this.length,i=0;else if(u===void 0&&typeof i=="string")f=i,u=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(u)?(u=u>>>0,f===void 0&&(f="utf8")):(f=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let g=this.length-i;if((u===void 0||u>g)&&(u=g),r.length>0&&(u<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");f||(f="utf8");let S=!1;for(;;)switch(f){case"hex":return Ze(this,r,i,u);case"utf8":case"utf-8":return tr(this,r,i,u);case"ascii":case"latin1":case"binary":return er(this,r,i,u);case"base64":return rr(this,r,i,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ir(this,r,i,u);default:if(S)throw new TypeError("Unknown encoding: "+f);f=(""+f).toLowerCase(),S=!0}},"write"),n.prototype.toJSON=h(function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},"toJSON");function nr(a,r,i){return r===0&&i===a.length?d.fromByteArray(a):d.fromByteArray(a.slice(r,i))}h(nr,"base64Slice");function ve(a,r,i){i=Math.min(a.length,i);let u=[],f=r;for(;f<i;){let g=a[f],S=null,O=g>239?4:g>223?3:g>191?2:1;if(f+O<=i){let j,k,Y,R;switch(O){case 1:g<128&&(S=g);break;case 2:j=a[f+1],(j&192)===128&&(R=(g&31)<<6|j&63,R>127&&(S=R));break;case 3:j=a[f+1],k=a[f+2],(j&192)===128&&(k&192)===128&&(R=(g&15)<<12|(j&63)<<6|k&63,R>2047&&(R<55296||R>57343)&&(S=R));break;case 4:j=a[f+1],k=a[f+2],Y=a[f+3],(j&192)===128&&(k&192)===128&&(Y&192)===128&&(R=(g&15)<<18|(j&63)<<12|(k&63)<<6|Y&63,R>65535&&R<1114112&&(S=R))}}S===null?(S=65533,O=1):S>65535&&(S-=65536,u.push(S>>>10&1023|55296),S=56320|S&1023),u.push(S),f+=O}return or(u)}h(ve,"utf8Slice");let _e=4096;function or(a){let r=a.length;if(r<=_e)return String.fromCharCode.apply(String,a);let i="",u=0;for(;u<r;)i+=String.fromCharCode.apply(String,a.slice(u,u+=_e));return i}h(or,"decodeCodePointsArray");function sr(a,r,i){let u="";i=Math.min(a.length,i);for(let f=r;f<i;++f)u+=String.fromCharCode(a[f]&127);return u}h(sr,"asciiSlice");function ar(a,r,i){let u="";i=Math.min(a.length,i);for(let f=r;f<i;++f)u+=String.fromCharCode(a[f]);return u}h(ar,"latin1Slice");function cr(a,r,i){let u=a.length;(!r||r<0)&&(r=0),(!i||i<0||i>u)&&(i=u);let f="";for(let g=r;g<i;++g)f+=mr[a[g]];return f}h(cr,"hexSlice");function ur(a,r,i){let u=a.slice(r,i),f="";for(let g=0;g<u.length-1;g+=2)f+=String.fromCharCode(u[g]+u[g+1]*256);return f}h(ur,"utf16leSlice"),n.prototype.slice=h(function(r,i){let u=this.length;r=~~r,i=i===void 0?u:~~i,r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),i<0?(i+=u,i<0&&(i=0)):i>u&&(i=u),i<r&&(i=r);let f=this.subarray(r,i);return Object.setPrototypeOf(f,n.prototype),f},"slice");function K(a,r,i){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+r>i)throw new RangeError("Trying to access beyond buffer length")}h(K,"checkOffset"),n.prototype.readUintLE=n.prototype.readUIntLE=h(function(r,i,u){r=r>>>0,i=i>>>0,u||K(r,i,this.length);let f=this[r],g=1,S=0;for(;++S<i&&(g*=256);)f+=this[r+S]*g;return f},"readUIntLE"),n.prototype.readUintBE=n.prototype.readUIntBE=h(function(r,i,u){r=r>>>0,i=i>>>0,u||K(r,i,this.length);let f=this[r+--i],g=1;for(;i>0&&(g*=256);)f+=this[r+--i]*g;return f},"readUIntBE"),n.prototype.readUint8=n.prototype.readUInt8=h(function(r,i){return r=r>>>0,i||K(r,1,this.length),this[r]},"readUInt8"),n.prototype.readUint16LE=n.prototype.readUInt16LE=h(function(r,i){return r=r>>>0,i||K(r,2,this.length),this[r]|this[r+1]<<8},"readUInt16LE"),n.prototype.readUint16BE=n.prototype.readUInt16BE=h(function(r,i){return r=r>>>0,i||K(r,2,this.length),this[r]<<8|this[r+1]},"readUInt16BE"),n.prototype.readUint32LE=n.prototype.readUInt32LE=h(function(r,i){return r=r>>>0,i||K(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},"readUInt32LE"),n.prototype.readUint32BE=n.prototype.readUInt32BE=h(function(r,i){return r=r>>>0,i||K(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},"readUInt32BE"),n.prototype.readBigUInt64LE=ht(h(function(r){r=r>>>0,Ft(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&kt(r,this.length-8);let f=i+this[++r]*U(2,8)+this[++r]*U(2,16)+this[++r]*U(2,24),g=this[++r]+this[++r]*U(2,8)+this[++r]*U(2,16)+u*U(2,24);return BigInt(f)+(BigInt(g)<<BigInt(32))},"readBigUInt64LE")),n.prototype.readBigUInt64BE=ht(h(function(r){r=r>>>0,Ft(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&kt(r,this.length-8);let f=i*U(2,24)+this[++r]*U(2,16)+this[++r]*U(2,8)+this[++r],g=this[++r]*U(2,24)+this[++r]*U(2,16)+this[++r]*U(2,8)+u;return(BigInt(f)<<BigInt(32))+BigInt(g)},"readBigUInt64BE")),n.prototype.readIntLE=h(function(r,i,u){r=r>>>0,i=i>>>0,u||K(r,i,this.length);let f=this[r],g=1,S=0;for(;++S<i&&(g*=256);)f+=this[r+S]*g;return g*=128,f>=g&&(f-=Math.pow(2,8*i)),f},"readIntLE"),n.prototype.readIntBE=h(function(r,i,u){r=r>>>0,i=i>>>0,u||K(r,i,this.length);let f=i,g=1,S=this[r+--f];for(;f>0&&(g*=256);)S+=this[r+--f]*g;return g*=128,S>=g&&(S-=Math.pow(2,8*i)),S},"readIntBE"),n.prototype.readInt8=h(function(r,i){return r=r>>>0,i||K(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},"readInt8"),n.prototype.readInt16LE=h(function(r,i){r=r>>>0,i||K(r,2,this.length);let u=this[r]|this[r+1]<<8;return u&32768?u|4294901760:u},"readInt16LE"),n.prototype.readInt16BE=h(function(r,i){r=r>>>0,i||K(r,2,this.length);let u=this[r+1]|this[r]<<8;return u&32768?u|4294901760:u},"readInt16BE"),n.prototype.readInt32LE=h(function(r,i){return r=r>>>0,i||K(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},"readInt32LE"),n.prototype.readInt32BE=h(function(r,i){return r=r>>>0,i||K(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},"readInt32BE"),n.prototype.readBigInt64LE=ht(h(function(r){r=r>>>0,Ft(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&kt(r,this.length-8);let f=this[r+4]+this[r+5]*U(2,8)+this[r+6]*U(2,16)+(u<<24);return(BigInt(f)<<BigInt(32))+BigInt(i+this[++r]*U(2,8)+this[++r]*U(2,16)+this[++r]*U(2,24))},"readBigInt64LE")),n.prototype.readBigInt64BE=ht(h(function(r){r=r>>>0,Ft(r,"offset");let i=this[r],u=this[r+7];(i===void 0||u===void 0)&&kt(r,this.length-8);let f=(i<<24)+this[++r]*U(2,16)+this[++r]*U(2,8)+this[++r];return(BigInt(f)<<BigInt(32))+BigInt(this[++r]*U(2,24)+this[++r]*U(2,16)+this[++r]*U(2,8)+u)},"readBigInt64BE")),n.prototype.readFloatLE=h(function(r,i){return r=r>>>0,i||K(r,4,this.length),t.read(this,r,!0,23,4)},"readFloatLE"),n.prototype.readFloatBE=h(function(r,i){return r=r>>>0,i||K(r,4,this.length),t.read(this,r,!1,23,4)},"readFloatBE"),n.prototype.readDoubleLE=h(function(r,i){return r=r>>>0,i||K(r,8,this.length),t.read(this,r,!0,52,8)},"readDoubleLE"),n.prototype.readDoubleBE=h(function(r,i){return r=r>>>0,i||K(r,8,this.length),t.read(this,r,!1,52,8)},"readDoubleBE");function Z(a,r,i,u,f,g){if(!n.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>f||r<g)throw new RangeError('"value" argument is out of bounds');if(i+u>a.length)throw new RangeError("Index out of range")}h(Z,"checkInt"),n.prototype.writeUintLE=n.prototype.writeUIntLE=h(function(r,i,u,f){if(r=+r,i=i>>>0,u=u>>>0,!f){let O=Math.pow(2,8*u)-1;Z(this,r,i,u,O,0)}let g=1,S=0;for(this[i]=r&255;++S<u&&(g*=256);)this[i+S]=r/g&255;return i+u},"writeUIntLE"),n.prototype.writeUintBE=n.prototype.writeUIntBE=h(function(r,i,u,f){if(r=+r,i=i>>>0,u=u>>>0,!f){let O=Math.pow(2,8*u)-1;Z(this,r,i,u,O,0)}let g=u-1,S=1;for(this[i+g]=r&255;--g>=0&&(S*=256);)this[i+g]=r/S&255;return i+u},"writeUIntBE"),n.prototype.writeUint8=n.prototype.writeUInt8=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,1,255,0),this[i]=r&255,i+1},"writeUInt8"),n.prototype.writeUint16LE=n.prototype.writeUInt16LE=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},"writeUInt16LE"),n.prototype.writeUint16BE=n.prototype.writeUInt16BE=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},"writeUInt16BE"),n.prototype.writeUint32LE=n.prototype.writeUInt32LE=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},"writeUInt32LE"),n.prototype.writeUint32BE=n.prototype.writeUInt32BE=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},"writeUInt32BE");function Te(a,r,i,u,f){Re(r,u,f,a,i,7);let g=Number(r&BigInt(4294967295));a[i++]=g,g=g>>8,a[i++]=g,g=g>>8,a[i++]=g,g=g>>8,a[i++]=g;let S=Number(r>>BigInt(32)&BigInt(4294967295));return a[i++]=S,S=S>>8,a[i++]=S,S=S>>8,a[i++]=S,S=S>>8,a[i++]=S,i}h(Te,"wrtBigUInt64LE");function Oe(a,r,i,u,f){Re(r,u,f,a,i,7);let g=Number(r&BigInt(4294967295));a[i+7]=g,g=g>>8,a[i+6]=g,g=g>>8,a[i+5]=g,g=g>>8,a[i+4]=g;let S=Number(r>>BigInt(32)&BigInt(4294967295));return a[i+3]=S,S=S>>8,a[i+2]=S,S=S>>8,a[i+1]=S,S=S>>8,a[i]=S,i+8}h(Oe,"wrtBigUInt64BE"),n.prototype.writeBigUInt64LE=ht(h(function(r,i=0){return Te(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64LE")),n.prototype.writeBigUInt64BE=ht(h(function(r,i=0){return Oe(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64BE")),n.prototype.writeIntLE=h(function(r,i,u,f){if(r=+r,i=i>>>0,!f){let j=Math.pow(2,8*u-1);Z(this,r,i,u,j-1,-j)}let g=0,S=1,O=0;for(this[i]=r&255;++g<u&&(S*=256);)r<0&&O===0&&this[i+g-1]!==0&&(O=1),this[i+g]=(r/S>>0)-O&255;return i+u},"writeIntLE"),n.prototype.writeIntBE=h(function(r,i,u,f){if(r=+r,i=i>>>0,!f){let j=Math.pow(2,8*u-1);Z(this,r,i,u,j-1,-j)}let g=u-1,S=1,O=0;for(this[i+g]=r&255;--g>=0&&(S*=256);)r<0&&O===0&&this[i+g+1]!==0&&(O=1),this[i+g]=(r/S>>0)-O&255;return i+u},"writeIntBE"),n.prototype.writeInt8=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},"writeInt8"),n.prototype.writeInt16LE=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},"writeInt16LE"),n.prototype.writeInt16BE=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},"writeInt16BE"),n.prototype.writeInt32LE=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},"writeInt32LE"),n.prototype.writeInt32BE=h(function(r,i,u){return r=+r,i=i>>>0,u||Z(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},"writeInt32BE"),n.prototype.writeBigInt64LE=ht(h(function(r,i=0){return Te(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64LE")),n.prototype.writeBigInt64BE=ht(h(function(r,i=0){return Oe(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64BE"));function Be(a,r,i,u,f,g){if(i+u>a.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}h(Be,"checkIEEE754");function Fe(a,r,i,u,f){return r=+r,i=i>>>0,f||Be(a,r,i,4),t.write(a,r,i,u,23,4),i+4}h(Fe,"writeFloat"),n.prototype.writeFloatLE=h(function(r,i,u){return Fe(this,r,i,!0,u)},"writeFloatLE"),n.prototype.writeFloatBE=h(function(r,i,u){return Fe(this,r,i,!1,u)},"writeFloatBE");function Ae(a,r,i,u,f){return r=+r,i=i>>>0,f||Be(a,r,i,8),t.write(a,r,i,u,52,8),i+8}h(Ae,"writeDouble"),n.prototype.writeDoubleLE=h(function(r,i,u){return Ae(this,r,i,!0,u)},"writeDoubleLE"),n.prototype.writeDoubleBE=h(function(r,i,u){return Ae(this,r,i,!1,u)},"writeDoubleBE"),n.prototype.copy=h(function(r,i,u,f){if(!n.isBuffer(r))throw new TypeError("argument should be a Buffer");if(u||(u=0),!f&&f!==0&&(f=this.length),i>=r.length&&(i=r.length),i||(i=0),f>0&&f<u&&(f=u),f===u||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(f<0)throw new RangeError("sourceEnd out of bounds");f>this.length&&(f=this.length),r.length-i<f-u&&(f=r.length-i+u);let g=f-u;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,u,f):Uint8Array.prototype.set.call(r,this.subarray(u,f),i),g},"copy"),n.prototype.fill=h(function(r,i,u,f){if(typeof r=="string"){if(typeof i=="string"?(f=i,i=0,u=this.length):typeof u=="string"&&(f=u,u=this.length),f!==void 0&&typeof f!="string")throw new TypeError("encoding must be a string");if(typeof f=="string"&&!n.isEncoding(f))throw new TypeError("Unknown encoding: "+f);if(r.length===1){let S=r.charCodeAt(0);(f==="utf8"&&S<128||f==="latin1")&&(r=S)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<u)throw new RangeError("Out of range index");if(u<=i)return this;i=i>>>0,u=u===void 0?this.length:u>>>0,r||(r=0);let g;if(typeof r=="number")for(g=i;g<u;++g)this[g]=r;else{let S=n.isBuffer(r)?r:n.from(r,f),O=S.length;if(O===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(g=0;g<u-i;++g)this[g+i]=S[g%O]}return this},"fill");let Bt={};function me(a,r,i){Bt[a]=h(class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(f){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:f,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}},"NodeError")}h(me,"E"),me("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),me("ERR_INVALID_ARG_TYPE",function(a,r){return`The "${a}" argument must be of type number. Received type ${typeof r}`},TypeError),me("ERR_OUT_OF_RANGE",function(a,r,i){let u=`The value of "${a}" is out of range.`,f=i;return Number.isInteger(i)&&Math.abs(i)>U(2,32)?f=Ce(String(i)):typeof i=="bigint"&&(f=String(i),(i>U(BigInt(2),BigInt(32))||i<-U(BigInt(2),BigInt(32)))&&(f=Ce(f)),f+="n"),u+=` It must be ${r}. Received ${f}`,u},RangeError);function Ce(a){let r="",i=a.length,u=a[0]==="-"?1:0;for(;i>=u+4;i-=3)r=`_${a.slice(i-3,i)}${r}`;return`${a.slice(0,i)}${r}`}h(Ce,"addNumericalSeparator");function lr(a,r,i){Ft(r,"offset"),(a[r]===void 0||a[r+i]===void 0)&&kt(r,a.length-(i+1))}h(lr,"checkBounds");function Re(a,r,i,u,f,g){if(a>i||a<r){let S=typeof r=="bigint"?"n":"",O;throw g>3?r===0||r===BigInt(0)?O=`>= 0${S} and < 2${S} ** ${(g+1)*8}${S}`:O=`>= -(2${S} ** ${(g+1)*8-1}${S}) and < 2 ** ${(g+1)*8-1}${S}`:O=`>= ${r}${S} and <= ${i}${S}`,new Bt.ERR_OUT_OF_RANGE("value",O,a)}lr(u,f,g)}h(Re,"checkIntBI");function Ft(a,r){if(typeof a!="number")throw new Bt.ERR_INVALID_ARG_TYPE(r,"number",a)}h(Ft,"validateNumber");function kt(a,r,i){throw Math.floor(a)!==a?(Ft(a,i),new Bt.ERR_OUT_OF_RANGE(i||"offset","an integer",a)):r<0?new Bt.ERR_BUFFER_OUT_OF_BOUNDS:new Bt.ERR_OUT_OF_RANGE(i||"offset",`>= ${i?1:0} and <= ${r}`,a)}h(kt,"boundsError");let hr=/[^+/0-9A-Za-z-_]/g;function dr(a){if(a=a.split("=")[0],a=a.trim().replace(hr,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}h(dr,"base64clean");function ye(a,r){r=r||1/0;let i,u=a.length,f=null,g=[];for(let S=0;S<u;++S){if(i=a.charCodeAt(S),i>55295&&i<57344){if(!f){if(i>56319){(r-=3)>-1&&g.push(239,191,189);continue}else if(S+1===u){(r-=3)>-1&&g.push(239,191,189);continue}f=i;continue}if(i<56320){(r-=3)>-1&&g.push(239,191,189),f=i;continue}i=(f-55296<<10|i-56320)+65536}else f&&(r-=3)>-1&&g.push(239,191,189);if(f=null,i<128){if((r-=1)<0)break;g.push(i)}else if(i<2048){if((r-=2)<0)break;g.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;g.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;g.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return g}h(ye,"utf8ToBytes");function fr(a){let r=[];for(let i=0;i<a.length;++i)r.push(a.charCodeAt(i)&255);return r}h(fr,"asciiToBytes");function pr(a,r){let i,u,f,g=[];for(let S=0;S<a.length&&!((r-=2)<0);++S)i=a.charCodeAt(S),u=i>>8,f=i%256,g.push(f),g.push(u);return g}h(pr,"utf16leToBytes");function Pe(a){return d.toByteArray(dr(a))}h(Pe,"base64ToBytes");function ee(a,r,i,u){let f;for(f=0;f<u&&!(f+i>=r.length||f>=a.length);++f)r[f+i]=a[f];return f}h(ee,"blitBuffer");function at(a,r){return a instanceof r||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===r.name}h(at,"isInstance");function we(a){return a!==a}h(we,"numberIsNaN");let mr=function(){let a="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){let u=i*16;for(let f=0;f<16;++f)r[u+f]=a[i]+a[f]}return r}();function ht(a){return typeof BigInt=="undefined"?yr:a}h(ht,"defineBigIntMethod");function yr(){throw new Error("BigInt not supported")}return h(yr,"BufferBigIntNotDefined"),wt}h(Tr,"dew");var gt=Tr();gt.Buffer;gt.SlowBuffer;gt.INSPECT_MAX_BYTES;gt.kMaxLength;var T=gt.Buffer,kr=gt.INSPECT_MAX_BYTES,Mr=gt.kMaxLength;var ge={},He=!1,Ct=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:global;function Or(){if(He)return ge;He=!0;var d=ge={},t,e;function o(){throw new Error("setTimeout has not been defined")}h(o,"defaultSetTimout");function s(){throw new Error("clearTimeout has not been defined")}h(s,"defaultClearTimeout"),function(){try{typeof setTimeout=="function"?t=setTimeout:t=o}catch(v){t=o}try{typeof clearTimeout=="function"?e=clearTimeout:e=s}catch(v){e=s}}();function c(v){if(t===setTimeout)return setTimeout(v,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(v,0);try{return t(v,0)}catch(_){try{return t.call(null,v,0)}catch(F){return t.call(this||Ct,v,0)}}}h(c,"runTimeout");function n(v){if(e===clearTimeout)return clearTimeout(v);if((e===s||!e)&&clearTimeout)return e=clearTimeout,clearTimeout(v);try{return e(v)}catch(_){try{return e.call(null,v)}catch(F){return e.call(this||Ct,v)}}}h(n,"runClearTimeout");var l=[],p=!1,w,m=-1;function E(){!p||!w||(p=!1,w.length?l=w.concat(l):m=-1,l.length&&b())}h(E,"cleanUpNextTick");function b(){if(!p){var v=c(E);p=!0;for(var _=l.length;_;){for(w=l,l=[];++m<_;)w&&w[m].run();m=-1,_=l.length}w=null,p=!1,n(v)}}h(b,"drainQueue"),d.nextTick=function(v){var _=new Array(arguments.length-1);if(arguments.length>1)for(var F=1;F<arguments.length;F++)_[F-1]=arguments[F];l.push(new x(v,_)),l.length===1&&!p&&c(b)};function x(v,_){(this||Ct).fun=v,(this||Ct).array=_}h(x,"Item"),x.prototype.run=function(){(this||Ct).fun.apply(null,(this||Ct).array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={};function N(){}return h(N,"noop"),d.on=N,d.addListener=N,d.once=N,d.off=N,d.removeListener=N,d.removeAllListeners=N,d.emit=N,d.prependListener=N,d.prependOnceListener=N,d.listeners=function(v){return[]},d.binding=function(v){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(v){throw new Error("process.chdir is not supported")},d.umask=function(){return 0},ge}h(Or,"dew");var z=Or();z.platform="browser";z.addListener;z.argv;z.binding;z.browser;z.chdir;z.cwd;z.emit;z.env;z.listeners;z.nextTick;z.off;z.on;z.once;z.prependListener;z.prependOnceListener;z.removeAllListeners;z.removeListener;z.title;z.umask;z.version;z.versions;var Ee={},je=!1;function Br(){if(je)return Ee;je=!0;var d=z;function t(c){if(typeof c!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(c))}h(t,"assertPath");function e(c,n){for(var l="",p=0,w=-1,m=0,E,b=0;b<=c.length;++b){if(b<c.length)E=c.charCodeAt(b);else{if(E===47)break;E=47}if(E===47){if(!(w===b-1||m===1))if(w!==b-1&&m===2){if(l.length<2||p!==2||l.charCodeAt(l.length-1)!==46||l.charCodeAt(l.length-2)!==46){if(l.length>2){var x=l.lastIndexOf("/");if(x!==l.length-1){x===-1?(l="",p=0):(l=l.slice(0,x),p=l.length-1-l.lastIndexOf("/")),w=b,m=0;continue}}else if(l.length===2||l.length===1){l="",p=0,w=b,m=0;continue}}n&&(l.length>0?l+="/..":l="..",p=2)}else l.length>0?l+="/"+c.slice(w+1,b):l=c.slice(w+1,b),p=b-w-1;w=b,m=0}else E===46&&m!==-1?++m:m=-1}return l}h(e,"normalizeStringPosix");function o(c,n){var l=n.dir||n.root,p=n.base||(n.name||"")+(n.ext||"");return l?l===n.root?l+p:l+c+p:p}h(o,"_format");var s={resolve:h(function(){for(var n="",l=!1,p,w=arguments.length-1;w>=-1&&!l;w--){var m;w>=0?m=arguments[w]:(p===void 0&&(p=d.cwd()),m=p),t(m),m.length!==0&&(n=m+"/"+n,l=m.charCodeAt(0)===47)}return n=e(n,!l),l?n.length>0?"/"+n:"/":n.length>0?n:"."},"resolve"),normalize:h(function(n){if(t(n),n.length===0)return".";var l=n.charCodeAt(0)===47,p=n.charCodeAt(n.length-1)===47;return n=e(n,!l),n.length===0&&!l&&(n="."),n.length>0&&p&&(n+="/"),l?"/"+n:n},"normalize"),isAbsolute:h(function(n){return t(n),n.length>0&&n.charCodeAt(0)===47},"isAbsolute"),join:h(function(){if(arguments.length===0)return".";for(var n,l=0;l<arguments.length;++l){var p=arguments[l];t(p),p.length>0&&(n===void 0?n=p:n+="/"+p)}return n===void 0?".":s.normalize(n)},"join"),relative:h(function(n,l){if(t(n),t(l),n===l||(n=s.resolve(n),l=s.resolve(l),n===l))return"";for(var p=1;p<n.length&&n.charCodeAt(p)===47;++p);for(var w=n.length,m=w-p,E=1;E<l.length&&l.charCodeAt(E)===47;++E);for(var b=l.length,x=b-E,N=m<x?m:x,v=-1,_=0;_<=N;++_){if(_===N){if(x>N){if(l.charCodeAt(E+_)===47)return l.slice(E+_+1);if(_===0)return l.slice(E+_)}else m>N&&(n.charCodeAt(p+_)===47?v=_:_===0&&(v=0));break}var F=n.charCodeAt(p+_),C=l.charCodeAt(E+_);if(F!==C)break;F===47&&(v=_)}var $="";for(_=p+v+1;_<=w;++_)(_===w||n.charCodeAt(_)===47)&&($.length===0?$+="..":$+="/..");return $.length>0?$+l.slice(E+v):(E+=v,l.charCodeAt(E)===47&&++E,l.slice(E))},"relative"),_makeLong:h(function(n){return n},"_makeLong"),dirname:h(function(n){if(t(n),n.length===0)return".";for(var l=n.charCodeAt(0),p=l===47,w=-1,m=!0,E=n.length-1;E>=1;--E)if(l=n.charCodeAt(E),l===47){if(!m){w=E;break}}else m=!1;return w===-1?p?"/":".":p&&w===1?"//":n.slice(0,w)},"dirname"),basename:h(function(n,l){if(l!==void 0&&typeof l!="string")throw new TypeError('"ext" argument must be a string');t(n);var p=0,w=-1,m=!0,E;if(l!==void 0&&l.length>0&&l.length<=n.length){if(l.length===n.length&&l===n)return"";var b=l.length-1,x=-1;for(E=n.length-1;E>=0;--E){var N=n.charCodeAt(E);if(N===47){if(!m){p=E+1;break}}else x===-1&&(m=!1,x=E+1),b>=0&&(N===l.charCodeAt(b)?--b===-1&&(w=E):(b=-1,w=x))}return p===w?w=x:w===-1&&(w=n.length),n.slice(p,w)}else{for(E=n.length-1;E>=0;--E)if(n.charCodeAt(E)===47){if(!m){p=E+1;break}}else w===-1&&(m=!1,w=E+1);return w===-1?"":n.slice(p,w)}},"basename"),extname:h(function(n){t(n);for(var l=-1,p=0,w=-1,m=!0,E=0,b=n.length-1;b>=0;--b){var x=n.charCodeAt(b);if(x===47){if(!m){p=b+1;break}continue}w===-1&&(m=!1,w=b+1),x===46?l===-1?l=b:E!==1&&(E=1):l!==-1&&(E=-1)}return l===-1||w===-1||E===0||E===1&&l===w-1&&l===p+1?"":n.slice(l,w)},"extname"),format:h(function(n){if(n===null||typeof n!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof n);return o("/",n)},"format"),parse:h(function(n){t(n);var l={root:"",dir:"",base:"",ext:"",name:""};if(n.length===0)return l;var p=n.charCodeAt(0),w=p===47,m;w?(l.root="/",m=1):m=0;for(var E=-1,b=0,x=-1,N=!0,v=n.length-1,_=0;v>=m;--v){if(p=n.charCodeAt(v),p===47){if(!N){b=v+1;break}continue}x===-1&&(N=!1,x=v+1),p===46?E===-1?E=v:_!==1&&(_=1):E!==-1&&(_=-1)}return E===-1||x===-1||_===0||_===1&&E===x-1&&E===b+1?x!==-1&&(b===0&&w?l.base=l.name=n.slice(1,x):l.base=l.name=n.slice(b,x)):(b===0&&w?(l.name=n.slice(1,E),l.base=n.slice(1,x)):(l.name=n.slice(b,E),l.base=n.slice(b,x)),l.ext=n.slice(E,x)),b>0?l.dir=n.slice(0,b-1):w&&(l.dir="/"),l},"parse"),sep:"/",delimiter:":",win32:null,posix:null};return s.posix=s,Ee=s,Ee}h(Br,"dew");var J=Br();var si=J._makeLong,X=J.basename,ai=J.delimiter,A=J.dirname,ci=J.extname,ui=J.format,li=J.isAbsolute,dt=J.join,hi=J.normalize,di=J.parse,Rt=J.posix,fi=J.relative,$t=J.resolve,Et=J.sep,pi=J.win32;var I;(function(d){d[d.EPERM=1]="EPERM",d[d.ENOENT=2]="ENOENT",d[d.EIO=5]="EIO",d[d.EBADF=9]="EBADF",d[d.EACCES=13]="EACCES",d[d.EBUSY=16]="EBUSY",d[d.EEXIST=17]="EEXIST",d[d.ENOTDIR=20]="ENOTDIR",d[d.EISDIR=21]="EISDIR",d[d.EINVAL=22]="EINVAL",d[d.EFBIG=27]="EFBIG",d[d.ENOSPC=28]="ENOSPC",d[d.EROFS=30]="EROFS",d[d.ENOTEMPTY=39]="ENOTEMPTY",d[d.ENOTSUP=95]="ENOTSUP"})(I=I||(I={}));var G={};G[I.EPERM]="Operation not permitted.";G[I.ENOENT]="No such file or directory.";G[I.EIO]="Input/output error.";G[I.EBADF]="Bad file descriptor.";G[I.EACCES]="Permission denied.";G[I.EBUSY]="Resource busy or locked.";G[I.EEXIST]="File exists.";G[I.ENOTDIR]="File is not a directory.";G[I.EISDIR]="File is a directory.";G[I.EINVAL]="Invalid argument.";G[I.EFBIG]="File is too big.";G[I.ENOSPC]="No space left on disk.";G[I.EROFS]="Cannot modify a read-only file system.";G[I.ENOTEMPTY]="Directory is not empty.";G[I.ENOTSUP]="Operation is not supported.";var y=class extends Error{static fromJSON(t){let e=new y(t.errno,t.message,t.path);return e.code=t.code,e.stack=t.stack,e}static fromBuffer(t,e=0){return y.fromJSON(JSON.parse(t.toString("utf8",e+4,e+4+t.readUInt32LE(e))))}static FileError(t,e){return new y(t,G[t],e)}static EACCES(t){return this.FileError(I.EACCES,t)}static ENOENT(t){return this.FileError(I.ENOENT,t)}static EEXIST(t){return this.FileError(I.EEXIST,t)}static EISDIR(t){return this.FileError(I.EISDIR,t)}static ENOTDIR(t){return this.FileError(I.ENOTDIR,t)}static EPERM(t){return this.FileError(I.EPERM,t)}static ENOTEMPTY(t){return this.FileError(I.ENOTEMPTY,t)}constructor(t,e=G[t],o){super(e),this.syscall="",this.errno=t,this.code=I[t],this.path=o,this.message=`Error: ${this.code}: ${e}${this.path?`, '${this.path}'`:""}`}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message}}writeToBuffer(t=T.alloc(this.bufferSize()),e=0){let o=t.write(JSON.stringify(this.toJSON()),e+4);return t.writeUInt32LE(o,e),t}bufferSize(){return 4+T.byteLength(JSON.stringify(this.toJSON()))}};h(y,"ApiError");var ot=class{constructor(t,e,o,s,c,n){this.uid=t,this.gid=e,this.suid=o,this.sgid=s,this.euid=c,this.egid=n}};h(ot,"Cred");ot.Root=new ot(0,0,0,0,0,0);var D;(function(d){d[d.FILE=32768]="FILE",d[d.DIRECTORY=16384]="DIRECTORY",d[d.SYMLINK=40960]="SYMLINK"})(D=D||(D={}));var q=class{static fromBuffer(t){let e=t.readUInt32LE(0),o=t.readUInt32LE(4),s=t.readDoubleLE(8),c=t.readDoubleLE(16),n=t.readDoubleLE(24),l=t.readUInt32LE(32),p=t.readUInt32LE(36);return new q(o&61440,e,o&-61441,s,c,n,l,p)}static clone(t){return new q(t.mode&61440,t.size,t.mode&-61441,t.atimeMs,t.mtimeMs,t.ctimeMs,t.uid,t.gid,t.birthtimeMs)}get atime(){return new Date(this.atimeMs)}get mtime(){return new Date(this.mtimeMs)}get ctime(){return new Date(this.ctimeMs)}get birthtime(){return new Date(this.birthtimeMs)}constructor(t,e,o,s,c,n,l,p,w){this.dev=0,this.ino=0,this.rdev=0,this.nlink=1,this.blksize=4096,this.uid=0,this.gid=0,this.fileData=null,this.size=e;let m=0;if(typeof s!="number"&&(m=Date.now(),s=m),typeof c!="number"&&(m||(m=Date.now()),c=m),typeof n!="number"&&(m||(m=Date.now()),n=m),typeof w!="number"&&(m||(m=Date.now()),w=m),typeof l!="number"&&(l=0),typeof p!="number"&&(p=0),this.atimeMs=s,this.ctimeMs=n,this.mtimeMs=c,this.birthtimeMs=w,o)this.mode=o;else switch(t){case D.FILE:this.mode=420;break;case D.DIRECTORY:default:this.mode=511}this.blocks=Math.ceil(e/512),this.mode&61440||(this.mode|=t)}toBuffer(){let t=T.alloc(32);return t.writeUInt32LE(this.size,0),t.writeUInt32LE(this.mode,4),t.writeDoubleLE(this.atime.getTime(),8),t.writeDoubleLE(this.mtime.getTime(),16),t.writeDoubleLE(this.ctime.getTime(),24),t.writeUInt32LE(this.uid,32),t.writeUInt32LE(this.gid,36),t}isFile(){return(this.mode&61440)===32768}isDirectory(){return(this.mode&61440)===16384}isSymbolicLink(){return(this.mode&61440)===40960}hasAccess(t,e){if(e.euid===0||e.egid===0)return!0;let o=this.mode&-61441,s=15,c=15,n=15;if(e.euid==this.uid){let w=(3840&o)>>8;s=(t^w)&t}if(e.egid==this.gid){let w=(240&o)>>4;c=(t^w)&t}let l=15&o;return n=(t^l)&t,!(s&c&n)}getCred(t=this.uid,e=this.gid){return new ot(t,e,this.uid,this.gid,t,e)}chmod(t){this.mode=this.mode&61440|t}chown(t,e){!isNaN(+t)&&0<=+t&&+t<Math.pow(2,32)&&(this.uid=t),!isNaN(+e)&&0<=+e&&+e<Math.pow(2,32)&&(this.gid=e)}isSocket(){return!1}isBlockDevice(){return!1}isCharacterDevice(){return!1}isFIFO(){return!1}};h(q,"Stats");var B=function(d,t,e,o){function s(c){return c instanceof e?c:new e(function(n){n(c)})}return h(s,"adopt"),new(e||(e=Promise))(function(c,n){function l(m){try{w(o.next(m))}catch(E){n(E)}}h(l,"fulfilled");function p(m){try{w(o.throw(m))}catch(E){n(E)}}h(p,"rejected");function w(m){m.done?c(m.value):s(m.value).then(l,p)}h(w,"step"),w((o=o.apply(d,t||[])).next())})},Ve,ie=class{constructor(t){}};h(ie,"FileSystem");var tt=class extends ie{constructor(t){super(),this._ready=Promise.resolve(this)}get metadata(){return{name:this.constructor.name,readonly:!1,synchronous:!1,supportsProperties:!1,supportsLinks:!1,totalSpace:0,freeSpace:0}}whenReady(){return this._ready}openFile(t,e,o){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}createFile(t,e,o,s){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}open(t,e,o,s){return B(this,void 0,void 0,function*(){try{let c=yield this.stat(t,s);switch(e.pathExistsAction()){case H.THROW_EXCEPTION:throw y.EEXIST(t);case H.TRUNCATE_FILE:let n=yield this.openFile(t,e,s);if(!n)throw new Error("BFS has reached an impossible code path; please file a bug.");return yield n.truncate(0),yield n.sync(),n;case H.NOP:return this.openFile(t,e,s);default:throw new y(I.EINVAL,"Invalid FileFlag object.")}}catch(c){switch(e.pathNotExistsAction()){case H.CREATE_FILE:let n=yield this.stat(A(t),s);if(n&&!n.isDirectory())throw y.ENOTDIR(A(t));return this.createFile(t,e,o,s);case H.THROW_EXCEPTION:throw y.ENOENT(t);default:throw new y(I.EINVAL,"Invalid FileFlag object.")}}})}access(t,e,o){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}accessSync(t,e,o){throw new y(I.ENOTSUP)}rename(t,e,o){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}renameSync(t,e,o){throw new y(I.ENOTSUP)}stat(t,e){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}statSync(t,e){throw new y(I.ENOTSUP)}openFileSync(t,e,o){throw new y(I.ENOTSUP)}createFileSync(t,e,o,s){throw new y(I.ENOTSUP)}openSync(t,e,o,s){let c;try{c=this.statSync(t,s)}catch(n){switch(e.pathNotExistsAction()){case H.CREATE_FILE:if(!this.statSync(A(t),s).isDirectory())throw y.ENOTDIR(A(t));return this.createFileSync(t,e,o,s);case H.THROW_EXCEPTION:throw y.ENOENT(t);default:throw new y(I.EINVAL,"Invalid FileFlag object.")}}if(!c.hasAccess(o,s))throw y.EACCES(t);switch(e.pathExistsAction()){case H.THROW_EXCEPTION:throw y.EEXIST(t);case H.TRUNCATE_FILE:return this.unlinkSync(t,s),this.createFileSync(t,e,c.mode,s);case H.NOP:return this.openFileSync(t,e,s);default:throw new y(I.EINVAL,"Invalid FileFlag object.")}}unlink(t,e){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}unlinkSync(t,e){throw new y(I.ENOTSUP)}rmdir(t,e){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}rmdirSync(t,e){throw new y(I.ENOTSUP)}mkdir(t,e,o){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}mkdirSync(t,e,o){throw new y(I.ENOTSUP)}readdir(t,e){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}readdirSync(t,e){throw new y(I.ENOTSUP)}exists(t,e){return B(this,void 0,void 0,function*(){try{return yield this.stat(t,e),!0}catch(o){return!1}})}existsSync(t,e){try{return this.statSync(t,e),!0}catch(o){return!1}}realpath(t,e){return B(this,void 0,void 0,function*(){if(this.metadata.supportsLinks){let o=t.split(Et);for(let s=0;s<o.length;s++){let c=o.slice(0,s+1);o[s]=dt(...c)}return o.join(Et)}else{if(!(yield this.exists(t,e)))throw y.ENOENT(t);return t}})}realpathSync(t,e){if(this.metadata.supportsLinks){let o=t.split(Et);for(let s=0;s<o.length;s++){let c=o.slice(0,s+1);o[s]=dt(...c)}return o.join(Et)}else{if(this.existsSync(t,e))return t;throw y.ENOENT(t)}}truncate(t,e,o){return B(this,void 0,void 0,function*(){let s=yield this.open(t,V.getFileFlag("r+"),420,o);try{yield s.truncate(e)}finally{yield s.close()}})}truncateSync(t,e,o){let s=this.openSync(t,V.getFileFlag("r+"),420,o);try{s.truncateSync(e)}finally{s.closeSync()}}readFile(t,e,o,s){return B(this,void 0,void 0,function*(){let c=yield this.open(t,o,420,s);try{let n=yield c.stat(),l=T.alloc(n.size);return yield c.read(l,0,n.size,0),yield c.close(),e===null?l:l.toString(e)}finally{yield c.close()}})}readFileSync(t,e,o,s){let c=this.openSync(t,o,420,s);try{let n=c.statSync(),l=T.alloc(n.size);return c.readSync(l,0,n.size,0),c.closeSync(),e===null?l:l.toString(e)}finally{c.closeSync()}}writeFile(t,e,o,s,c,n){return B(this,void 0,void 0,function*(){let l=yield this.open(t,s,c,n);try{typeof e=="string"&&(e=T.from(e,o)),yield l.write(e,0,e.length,0)}finally{yield l.close()}})}writeFileSync(t,e,o,s,c,n){let l=this.openSync(t,s,c,n);try{typeof e=="string"&&(e=T.from(e,o)),l.writeSync(e,0,e.length,0)}finally{l.closeSync()}}appendFile(t,e,o,s,c,n){return B(this,void 0,void 0,function*(){let l=yield this.open(t,s,c,n);try{typeof e=="string"&&(e=T.from(e,o)),yield l.write(e,0,e.length,null)}finally{yield l.close()}})}appendFileSync(t,e,o,s,c,n){let l=this.openSync(t,s,c,n);try{typeof e=="string"&&(e=T.from(e,o)),l.writeSync(e,0,e.length,null)}finally{l.closeSync()}}chmod(t,e,o){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}chmodSync(t,e,o){throw new y(I.ENOTSUP)}chown(t,e,o,s){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}chownSync(t,e,o,s){throw new y(I.ENOTSUP)}utimes(t,e,o,s){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}utimesSync(t,e,o,s){throw new y(I.ENOTSUP)}link(t,e,o){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}linkSync(t,e,o){throw new y(I.ENOTSUP)}symlink(t,e,o,s){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}symlinkSync(t,e,o,s){throw new y(I.ENOTSUP)}readlink(t,e){return B(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}readlinkSync(t,e){throw new y(I.ENOTSUP)}};h(tt,"BaseFileSystem");Ve=tt;tt.Name=Ve.name;var jt=class extends tt{get metadata(){return Object.assign(Object.assign({},super.metadata),{synchronous:!0})}access(t,e,o){return B(this,void 0,void 0,function*(){return this.accessSync(t,e,o)})}rename(t,e,o){return B(this,void 0,void 0,function*(){return this.renameSync(t,e,o)})}stat(t,e){return B(this,void 0,void 0,function*(){return this.statSync(t,e)})}open(t,e,o,s){return B(this,void 0,void 0,function*(){return this.openSync(t,e,o,s)})}unlink(t,e){return B(this,void 0,void 0,function*(){return this.unlinkSync(t,e)})}rmdir(t,e){return B(this,void 0,void 0,function*(){return this.rmdirSync(t,e)})}mkdir(t,e,o){return B(this,void 0,void 0,function*(){return this.mkdirSync(t,e,o)})}readdir(t,e){return B(this,void 0,void 0,function*(){return this.readdirSync(t,e)})}chmod(t,e,o){return B(this,void 0,void 0,function*(){return this.chmodSync(t,e,o)})}chown(t,e,o,s){return B(this,void 0,void 0,function*(){return this.chownSync(t,e,o,s)})}utimes(t,e,o,s){return B(this,void 0,void 0,function*(){return this.utimesSync(t,e,o,s)})}link(t,e,o){return B(this,void 0,void 0,function*(){return this.linkSync(t,e,o)})}symlink(t,e,o,s){return B(this,void 0,void 0,function*(){return this.symlinkSync(t,e,o,s)})}readlink(t,e){return B(this,void 0,void 0,function*(){return this.readlinkSync(t,e)})}};h(jt,"SynchronousFileSystem");var et=class{static fromBuffer(t){if(t===void 0)throw new Error("NO");return new et(t.toString("ascii",38),t.readUInt32LE(0),t.readUInt16LE(4),t.readDoubleLE(6),t.readDoubleLE(14),t.readDoubleLE(22),t.readUInt32LE(30),t.readUInt32LE(34))}constructor(t,e,o,s,c,n,l,p){this.id=t,this.size=e,this.mode=o,this.atime=s,this.mtime=c,this.ctime=n,this.uid=l,this.gid=p}toStats(){return new q((this.mode&61440)===D.DIRECTORY?D.DIRECTORY:D.FILE,this.size,this.mode,this.atime,this.mtime,this.ctime,this.uid,this.gid)}getSize(){return 38+this.id.length}toBuffer(t=T.alloc(this.getSize())){return t.writeUInt32LE(this.size,0),t.writeUInt16LE(this.mode,4),t.writeDoubleLE(this.atime,6),t.writeDoubleLE(this.mtime,14),t.writeDoubleLE(this.ctime,22),t.writeUInt32LE(this.uid,30),t.writeUInt32LE(this.gid,34),t.write(this.id,38,this.id.length,"ascii"),t}update(t){let e=!1;this.size!==t.size&&(this.size=t.size,e=!0),this.mode!==t.mode&&(this.mode=t.mode,e=!0);let o=t.atime.getTime();this.atime!==o&&(this.atime=o,e=!0);let s=t.mtime.getTime();this.mtime!==s&&(this.mtime=s,e=!0);let c=t.ctime.getTime();return this.ctime!==c&&(this.ctime=c,e=!0),this.uid!==t.uid&&(this.uid=t.uid,e=!0),this.uid!==t.uid&&(this.uid=t.uid,e=!0),e}isFile(){return(this.mode&61440)===D.FILE}isDirectory(){return(this.mode&61440)===D.DIRECTORY}};h(et,"Inode");var Fr=function(d,t,e,o){function s(c){return c instanceof e?c:new e(function(n){n(c)})}return h(s,"adopt"),new(e||(e=Promise))(function(c,n){function l(m){try{w(o.next(m))}catch(E){n(E)}}h(l,"fulfilled");function p(m){try{w(o.throw(m))}catch(E){n(E)}}h(p,"rejected");function w(m){m.done?c(m.value):s(m.value).then(l,p)}h(w,"step"),w((o=o.apply(d,t||[])).next())})};function Xe(d,t=0,e=d.length){if(t<0||e<0||e>d.length||t>e)throw new TypeError(`Invalid slice bounds on buffer of length ${d.length}: [${t}, ${e}]`);return d.length===0?T.alloc(0):d.subarray(t,e)}h(Xe,"copyingSlice");function ne(d,t,e,o,s){return Math.min(d+1,t+1,e+1,o===s?t:t+1)}h(ne,"_min");function Ar(d,t){if(d===t)return 0;d.length>t.length&&([d,t]=[t,d]);let e=d.length,o=t.length;for(;e>0&&d.charCodeAt(e-1)===t.charCodeAt(o-1);)e--,o--;let s=0;for(;s<e&&d.charCodeAt(s)===t.charCodeAt(s);)s++;if(e-=s,o-=s,e===0||o===1)return o;let c=new Array(e<<1);for(let b=0;b<e;)c[e+b]=d.charCodeAt(s+b),c[b]=++b;let n,l,p,w,m;for(n=0;n+3<o;){let b=t.charCodeAt(s+(l=n)),x=t.charCodeAt(s+(p=n+1)),N=t.charCodeAt(s+(w=n+2)),v=t.charCodeAt(s+(m=n+3)),_=n+=4;for(let F=0;F<e;){let C=c[e+F],$=c[F];l=ne($,l,p,b,C),p=ne(l,p,w,x,C),w=ne(p,w,m,N,C),_=ne(w,m,_,v,C),c[F++]=_,m=w,w=p,p=l,l=$}}let E=0;for(;n<o;){let b=t.charCodeAt(s+(l=n));E=++n;for(let x=0;x<e;x++){let N=c[x];c[x]=E=N<l||E<l?N>E?E+1:N+1:b===c[e+x]?l:l+1,l=N}}return E}h(Ar,"levenshtein");function Ke(d,t){return Fr(this,void 0,void 0,function*(){let e=d.Options,o=d.Name,s=0,c=!1,n=!1;for(let l in e)if(Object.prototype.hasOwnProperty.call(e,l)){let p=e[l],w=t&&t[l];if(w==null){if(!p.optional){let m=Object.keys(t).filter(E=>!(E in e)).map(E=>({str:E,distance:Ar(l,E)})).filter(E=>E.distance<5).sort((E,b)=>E.distance-b.distance);if(c)return;throw c=!0,new y(I.EINVAL,`[${o}] Required option '${l}' not provided.${m.length>0?` You provided unrecognized option '${m[0].str}'; perhaps you meant to type '${l}'.`:""}
|
|
2
|
-
Option description: ${
|
|
3
|
-
Option description: ${p.description}`)}}}n=!0})}h(Ke,"checkOptions");var sn=typeof globalThis.setImmediate=="function"?globalThis.setImmediate:d=>setTimeout(d,0),st="/";function oe(){return T.from("{}")}h(oe,"getEmptyDirNode");function Pt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(d){let t=Math.random()*16|0;return(d==="x"?t:t&3|8).toString(16)})}h(Pt,"randomUUID");var St=class{constructor(t){this.store=t,this.originalData={},this.modifiedKeys=[]}get(t){let e=this.store.get(t);return this.stashOldValue(t,e),e}put(t,e,o){return this.markModified(t),this.store.put(t,e,o)}del(t){this.markModified(t),this.store.del(t)}commit(){}abort(){for(let t of this.modifiedKeys){let e=this.originalData[t];e?this.store.put(t,e,!0):this.store.del(t)}}_has(t){return Object.prototype.hasOwnProperty.call(this.originalData,t)}stashOldValue(t,e){this._has(t)||(this.originalData[t]=e)}markModified(t){this.modifiedKeys.indexOf(t)===-1&&(this.modifiedKeys.push(t),this._has(t)||(this.originalData[t]=this.store.get(t)))}};h(St,"SimpleSyncRWTransaction");var Yt=class extends ut{constructor(t,e,o,s,c){super(t,e,o,s,c)}syncSync(){this.isDirty()&&(this._fs._syncSync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())}closeSync(){this.syncSync()}};h(Yt,"SyncKeyValueFile");var It=class extends jt{static isAvailable(){return!0}constructor(t){super(),this.store=t.store,this.makeRootDirectory()}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!0}empty(){this.store.clear(),this.makeRootDirectory()}accessSync(t,e,o){let s=this.store.beginTransaction("readonly");if(!this.findINode(s,t).toStats().hasAccess(e,o))throw y.EACCES(t)}renameSync(t,e,o){let s=this.store.beginTransaction("readwrite"),c=A(t),n=X(t),l=A(e),p=X(e),w=this.findINode(s,c),m=this.getDirListing(s,c,w);if(!w.toStats().hasAccess(2,o))throw y.EACCES(t);if(!m[n])throw y.ENOENT(t);let E=m[n];if(delete m[n],(l+"/").indexOf(t+"/")===0)throw new y(I.EBUSY,c);let b,x;if(l===c?(b=w,x=m):(b=this.findINode(s,l),x=this.getDirListing(s,l,b)),x[p]){let N=this.getINode(s,e,x[p]);if(N.isFile())try{s.del(N.id),s.del(x[p])}catch(v){throw s.abort(),v}else throw y.EPERM(e)}x[p]=E;try{s.put(w.id,T.from(JSON.stringify(m)),!0),s.put(b.id,T.from(JSON.stringify(x)),!0)}catch(N){throw s.abort(),N}s.commit()}statSync(t,e){let o=this.findINode(this.store.beginTransaction("readonly"),t).toStats();if(!o.hasAccess(4,e))throw y.EACCES(t);return o}createFileSync(t,e,o,s){let c=this.store.beginTransaction("readwrite"),n=T.alloc(0),l=this.commitNewFile(c,t,D.FILE,o,s,n);return new Yt(this,t,e,l.toStats(),n)}openFileSync(t,e,o){let s=this.store.beginTransaction("readonly"),c=this.findINode(s,t),n=s.get(c.id);if(!c.toStats().hasAccess(e.getMode(),o))throw y.EACCES(t);if(n===void 0)throw y.ENOENT(t);return new Yt(this,t,e,c.toStats(),n)}unlinkSync(t,e){this.removeEntry(t,!1,e)}rmdirSync(t,e){if(this.readdirSync(t,e).length>0)throw y.ENOTEMPTY(t);this.removeEntry(t,!0,e)}mkdirSync(t,e,o){let s=this.store.beginTransaction("readwrite"),c=T.from("{}");this.commitNewFile(s,t,D.DIRECTORY,e,o,c)}readdirSync(t,e){let o=this.store.beginTransaction("readonly"),s=this.findINode(o,t);if(!s.toStats().hasAccess(4,e))throw y.EACCES(t);return Object.keys(this.getDirListing(o,t,s))}chmodSync(t,e,o){this.openFileSync(t,V.getFileFlag("r+"),o).chmodSync(e)}chownSync(t,e,o,s){this.openFileSync(t,V.getFileFlag("r+"),s).chownSync(e,o)}_syncSync(t,e,o){let s=this.store.beginTransaction("readwrite"),c=this._findINode(s,A(t),X(t)),n=this.getINode(s,t,c),l=n.update(o);try{s.put(n.id,e,!0),l&&s.put(c,n.toBuffer(),!0)}catch(p){throw s.abort(),p}s.commit()}makeRootDirectory(){let t=this.store.beginTransaction("readwrite");if(t.get(st)===void 0){let e=new Date().getTime(),o=new et(Pt(),4096,511|D.DIRECTORY,e,e,e,0,0);t.put(o.id,oe(),!1),t.put(st,o.toBuffer(),!1),t.commit()}}_findINode(t,e,o,s=new Set){let c=Rt.join(e,o);if(s.has(c))throw new y(I.EIO,"Infinite loop detected while finding inode",c);s.add(c);let n=h(l=>{let p=this.getDirListing(t,e,l);if(p[o])return p[o];throw y.ENOENT($t(e,o))},"readDirectory");return e==="/"?o===""?st:n(this.getINode(t,e,st)):n(this.getINode(t,e+Et+o,this._findINode(t,A(e),X(e),s)))}findINode(t,e){return this.getINode(t,e,this._findINode(t,A(e),X(e)))}getINode(t,e,o){let s=t.get(o);if(s===void 0)throw y.ENOENT(e);return et.fromBuffer(s)}getDirListing(t,e,o){if(!o.isDirectory())throw y.ENOTDIR(e);let s=t.get(o.id);if(s===void 0)throw y.ENOENT(e);return JSON.parse(s.toString())}addNewNode(t,e){let s;for(;0<5;)try{return s=Pt(),t.put(s,e,!1),s}catch(c){}throw new y(I.EIO,"Unable to commit data to key-value store.")}commitNewFile(t,e,o,s,c,n){let l=A(e),p=X(e),w=this.findINode(t,l),m=this.getDirListing(t,l,w),E=new Date().getTime();if(!w.toStats().hasAccess(4,c))throw y.EACCES(e);if(e==="/")throw y.EEXIST(e);if(m[p])throw y.EEXIST(e);let b;try{let x=this.addNewNode(t,n);b=new et(x,n.length,s|o,E,E,E,c.uid,c.gid);let N=this.addNewNode(t,b.toBuffer());m[p]=N,t.put(w.id,T.from(JSON.stringify(m)),!0)}catch(x){throw t.abort(),x}return t.commit(),b}removeEntry(t,e,o){let s=this.store.beginTransaction("readwrite"),c=A(t),n=this.findINode(s,c),l=this.getDirListing(s,c,n),p=X(t);if(!l[p])throw y.ENOENT(t);let w=l[p],m=this.getINode(s,t,w);if(!m.toStats().hasAccess(2,o))throw y.EACCES(t);if(delete l[p],!e&&m.isDirectory())throw y.EISDIR(t);if(e&&!m.isDirectory())throw y.ENOTDIR(t);try{s.del(m.id),s.del(w),s.put(n.id,T.from(JSON.stringify(l)),!0)}catch(E){throw s.abort(),E}s.commit()}};h(It,"SyncKeyValueFileSystem");function nt(d,t){t=typeof d=="function"?d:t,Ke(this,d);let e=new this(typeof d=="function"?{}:d);if(typeof t!="function")return e.whenReady();e.whenReady().then(o=>t(null,o)).catch(o=>t(o))}h(nt,"CreateBackend");var Je,se=class{constructor(){this.store=new Map}name(){return lt.Name}clear(){this.store.clear()}beginTransaction(t){return new St(this)}get(t){return this.store.get(t)}put(t,e,o){return!o&&this.store.has(t)?!1:(this.store.set(t,e),!0)}del(t){this.store.delete(t)}};h(se,"InMemoryStore");var lt=class extends It{constructor(){super({store:new se})}};h(lt,"InMemoryFileSystem");Je=lt;lt.Name="InMemory";lt.Create=nt.bind(Je);lt.Options={};var $n=ot.Root;var Se=new Map;lt.Create().then(d=>Cr("/",d));function ae(d){return Se.get(d)}h(ae,"getMount");function Cr(d,t){if(d[0]!=="/"&&(d="/"+d),d=Rt.resolve(d),Se.has(d))throw new y(I.EINVAL,"Mount point "+d+" is already in use.");Se.set(d,t)}h(Cr,"mount");var rt=function(d,t,e,o){function s(c){return c instanceof e?c:new e(function(n){n(c)})}return h(s,"adopt"),new(e||(e=Promise))(function(c,n){function l(m){try{w(o.next(m))}catch(E){n(E)}}h(l,"fulfilled");function p(m){try{w(o.throw(m))}catch(E){n(E)}}h(p,"rejected");function w(m){m.done?c(m.value):s(m.value).then(l,p)}h(w,"step"),w((o=o.apply(d,t||[])).next())})},H;(function(d){d[d.NOP=0]="NOP",d[d.THROW_EXCEPTION=1]="THROW_EXCEPTION",d[d.TRUNCATE_FILE=2]="TRUNCATE_FILE",d[d.CREATE_FILE=3]="CREATE_FILE"})(H=H||(H={}));var V=class{static getFileFlag(t){return V.flagCache.has(t)||V.flagCache.set(t,new V(t)),V.flagCache.get(t)}constructor(t){if(this.flagStr=t,V.validFlagStrs.indexOf(t)<0)throw new y(I.EINVAL,"Invalid flag: "+t)}getFlagString(){return this.flagStr}getMode(){let t=0;return t<<=1,t+=+this.isReadable(),t<<=1,t+=+this.isWriteable(),t<<=1,t}isReadable(){return this.flagStr.indexOf("r")!==-1||this.flagStr.indexOf("+")!==-1}isWriteable(){return this.flagStr.indexOf("w")!==-1||this.flagStr.indexOf("a")!==-1||this.flagStr.indexOf("+")!==-1}isTruncating(){return this.flagStr.indexOf("w")!==-1}isAppendable(){return this.flagStr.indexOf("a")!==-1}isSynchronous(){return this.flagStr.indexOf("s")!==-1}isExclusive(){return this.flagStr.indexOf("x")!==-1}pathExistsAction(){return this.isExclusive()?H.THROW_EXCEPTION:this.isTruncating()?H.TRUNCATE_FILE:H.NOP}pathNotExistsAction(){return(this.isWriteable()||this.isAppendable())&&this.flagStr!=="r+"?H.CREATE_FILE:H.THROW_EXCEPTION}};h(V,"FileFlag");V.flagCache=new Map;V.validFlagStrs=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"];var ce=class{sync(){return rt(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}syncSync(){throw new y(I.ENOTSUP)}datasync(){return rt(this,void 0,void 0,function*(){return this.sync()})}datasyncSync(){return this.syncSync()}chown(t,e){return rt(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}chownSync(t,e){throw new y(I.ENOTSUP)}chmod(t){return rt(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}chmodSync(t){throw new y(I.ENOTSUP)}utimes(t,e){return rt(this,void 0,void 0,function*(){throw new y(I.ENOTSUP)})}utimesSync(t,e){throw new y(I.ENOTSUP)}};h(ce,"BaseFile");var ut=class extends ce{constructor(t,e,o,s,c){if(super(),this._pos=0,this._dirty=!1,this._fs=t,this._path=e,this._flag=o,this._stat=s,this._buffer=c||T.alloc(0),this._stat.size!==this._buffer.length&&this._flag.isReadable())throw new Error(`Invalid buffer: Buffer is ${this._buffer.length} long, yet Stats object specifies that file is ${this._stat.size} long.`)}getBuffer(){return this._buffer}getStats(){return this._stat}getFlag(){return this._flag}getPath(){return this._path}getPos(){return this._flag.isAppendable()?this._stat.size:this._pos}advancePos(t){return this._pos+=t}setPos(t){return this._pos=t}sync(){return rt(this,void 0,void 0,function*(){this.syncSync()})}syncSync(){throw new y(I.ENOTSUP)}close(){return rt(this,void 0,void 0,function*(){this.closeSync()})}closeSync(){throw new y(I.ENOTSUP)}stat(){return rt(this,void 0,void 0,function*(){return q.clone(this._stat)})}statSync(){return q.clone(this._stat)}truncate(t){if(this.truncateSync(t),this._flag.isSynchronous()&&!ae("/").metadata.synchronous)return this.sync()}truncateSync(t){if(this._dirty=!0,!this._flag.isWriteable())throw new y(I.EPERM,"File not opened with a writeable mode.");if(this._stat.mtimeMs=Date.now(),t>this._buffer.length){let o=T.alloc(t-this._buffer.length,0);this.writeSync(o,0,o.length,this._buffer.length),this._flag.isSynchronous()&&ae("/").metadata.synchronous&&this.syncSync();return}this._stat.size=t;let e=T.alloc(t);this._buffer.copy(e,0,0,t),this._buffer=e,this._flag.isSynchronous()&&ae("/").metadata.synchronous&&this.syncSync()}write(t,e,o,s){return rt(this,void 0,void 0,function*(){return this.writeSync(t,e,o,s)})}writeSync(t,e,o,s){if(this._dirty=!0,s==null&&(s=this.getPos()),!this._flag.isWriteable())throw new y(I.EPERM,"File not opened with a writeable mode.");let c=s+o;if(c>this._stat.size&&(this._stat.size=c,c>this._buffer.length)){let l=T.alloc(c);this._buffer.copy(l),this._buffer=l}let n=t.copy(this._buffer,s,e,e+o);return this._stat.mtimeMs=Date.now(),this._flag.isSynchronous()?(this.syncSync(),n):(this.setPos(s+n),n)}read(t,e,o,s){return rt(this,void 0,void 0,function*(){return{bytesRead:this.readSync(t,e,o,s),buffer:t}})}readSync(t,e,o,s){if(!this._flag.isReadable())throw new y(I.EPERM,"File not opened with a readable mode.");s==null&&(s=this.getPos()),s+o>this._stat.size&&(o=this._stat.size-s);let n=this._buffer.copy(t,e,s,s+o);return this._stat.atimeMs=Date.now(),this._pos=s+o,n}chmod(t){return rt(this,void 0,void 0,function*(){this.chmodSync(t)})}chmodSync(t){if(!this._fs.metadata.supportsProperties)throw new y(I.ENOTSUP);this._dirty=!0,this._stat.chmod(t),this.syncSync()}chown(t,e){return rt(this,void 0,void 0,function*(){this.chownSync(t,e)})}chownSync(t,e){if(!this._fs.metadata.supportsProperties)throw new y(I.ENOTSUP);this._dirty=!0,this._stat.chown(t,e),this.syncSync()}isDirty(){return this._dirty}resetDirty(){this._dirty=!1}};h(ut,"PreloadFile");var bt=class extends ut{constructor(t,e,o,s,c){super(t,e,o,s,c)}sync(){return rt(this,void 0,void 0,function*(){})}syncSync(){}close(){return rt(this,void 0,void 0,function*(){})}closeSync(){}};h(bt,"NoSyncFile");var ue=h((d="",t)=>{throw t.name==="NotFoundError"?y.ENOENT(d):t},"handleError"),Wt=class extends ut{constructor(t,e,o,s,c){super(t,e,o,s,c)}sync(){return P(this,null,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),ot.Root),this.resetDirty())})}close(){return P(this,null,function*(){yield this.sync()})}};h(Wt,"FileSystemAccessFile");var le=class extends tt{constructor({handle:e}){super();this._handles=new Map;this._handles.set("/",e)}static isAvailable(){return typeof FileSystemHandle=="function"}get metadata(){return At(yt({},super.metadata),{name:le.Name})}_sync(e,o,s,c){return P(this,null,function*(){let n=yield this.stat(e,c);s.mtime!==n.mtime&&(yield this.writeFile(e,o,null,V.getFileFlag("w"),n.mode,c))})}rename(e,o,s){return P(this,null,function*(){try{let c=yield this.getHandle(e);if(c instanceof FileSystemDirectoryHandle){let n=yield this.readdir(e,s);if(yield this.mkdir(o,"wx",s),n.length===0)yield this.unlink(e,s);else for(let l of n)yield this.rename(dt(e,l),dt(o,l),s),yield this.unlink(e,s)}if(c instanceof FileSystemFileHandle){let n=yield c.getFile(),l=yield this.getHandle(A(o));if(l instanceof FileSystemDirectoryHandle){let w=yield(yield l.getFileHandle(X(o),{create:!0})).createWritable(),m=yield n.arrayBuffer();yield w.write(m),w.close(),yield this.unlink(e,s)}}}catch(c){ue(e,c)}})}writeFile(e,o,s,c,n,l,p){return P(this,null,function*(){let w=yield this.getHandle(A(e));if(w instanceof FileSystemDirectoryHandle){let E=yield(yield w.getFileHandle(X(e),{create:!0})).createWritable();yield E.write(o),yield E.close()}})}createFile(e,o,s,c){return P(this,null,function*(){return yield this.writeFile(e,T.alloc(0),null,o,s,c,!0),this.openFile(e,o,c)})}stat(e,o){return P(this,null,function*(){let s=yield this.getHandle(e);if(!s)throw y.FileError(I.EINVAL,e);if(s instanceof FileSystemDirectoryHandle)return new q(D.DIRECTORY,4096);if(s instanceof FileSystemFileHandle){let{lastModified:c,size:n}=yield s.getFile();return new q(D.FILE,n,void 0,void 0,c)}})}exists(e,o){return P(this,null,function*(){try{return yield this.getHandle(e),!0}catch(s){return!1}})}openFile(e,o,s){return P(this,null,function*(){let c=yield this.getHandle(e);if(c instanceof FileSystemFileHandle){let n=yield c.getFile(),l=yield n.arrayBuffer();return this.newFile(e,o,l,n.size,n.lastModified)}})}unlink(e,o){return P(this,null,function*(){let s=yield this.getHandle(A(e));if(s instanceof FileSystemDirectoryHandle)try{yield s.removeEntry(X(e),{recursive:!0})}catch(c){ue(e,c)}})}rmdir(e,o){return P(this,null,function*(){return this.unlink(e,o)})}mkdir(e,o,s){return P(this,null,function*(){let c=o&&o.flag&&o.flag.includes("w")&&!o.flag.includes("x");if((yield this.getHandle(e))&&!c)throw y.EEXIST(e);let l=yield this.getHandle(A(e));l instanceof FileSystemDirectoryHandle&&(yield l.getDirectoryHandle(X(e),{create:!0}))})}readdir(e,o){return P(this,null,function*(){let s=yield this.getHandle(e);if(!(s instanceof FileSystemDirectoryHandle))throw y.ENOTDIR(e);let c=[];try{for(var n=ke(s.keys()),l,p,w;l=!(p=yield n.next()).done;l=!1){let m=p.value;c.push(dt(e,m))}}catch(p){w=[p]}finally{try{l&&(p=n.return)&&(yield p.call(n))}finally{if(w)throw w[0]}}return c})}newFile(e,o,s,c,n){return new Wt(this,e,o,new q(D.FILE,c||0,void 0,void 0,n||new Date().getTime()),T.from(s))}getHandle(e){return P(this,null,function*(){if(this._handles.has(e))return this._handles.get(e);let o="/",[,...s]=e.split("/"),c=h(p=>P(this,[p],function*([n,...l]){let w=dt(o,n),m=h(b=>{if(o=w,this._handles.set(o,b),l.length===0)return this._handles.get(e);c(l)},"continueWalk"),E=this._handles.get(o);try{return yield m(yield E.getDirectoryHandle(n))}catch(b){if(b.name==="TypeMismatchError")try{return yield m(yield E.getFileHandle(n))}catch(x){ue(w,x)}else{if(b.message==="Name is not allowed.")throw new y(I.ENOENT,b.message,w);ue(w,b)}}}),"getHandleParts");yield c(s)})}},Nt=le;h(Nt,"FileSystemAccessFileSystem"),Nt.Name="FileSystemAccess",Nt.Create=nt.bind(le),Nt.Options={};var Ge=typeof fetch!="undefined"&&fetch!==null;function he(d){throw new y(I.EIO,d.message)}h(he,"convertError");function Ie(d,t){return P(this,null,function*(){let e=yield fetch(d).catch(he);if(!e.ok)throw new y(I.EIO,`fetch error: response returned code ${e.status}`);switch(t){case"buffer":let o=yield e.arrayBuffer().catch(he);return T.from(o);case"json":return yield e.json().catch(he);default:throw new y(I.EINVAL,"Invalid download type: "+t)}})}h(Ie,"fetchFile");function Qe(d){return P(this,null,function*(){let t=yield fetch(d,{method:"HEAD"}).catch(he);if(!t.ok)throw new y(I.EIO,`fetch HEAD error: response returned code ${t.status}`);return parseInt(t.headers.get("Content-Length")||"-1",10)})}h(Qe,"fetchFileSize");var vt=class{static fromListing(t){let e=new vt,o=new ft;e._index["/"]=o;let s=[["",t,o]];for(;s.length>0;){let c,n=s.pop(),l=n[0],p=n[1],w=n[2];for(let m in p)if(Object.prototype.hasOwnProperty.call(p,m)){let E=p[m],b=`${l}/${m}`;E?(e._index[b]=c=new ft,s.push([b,E,c])):c=new de(new q(D.FILE,-1,365)),w&&(w._ls[m]=c)}}return e}constructor(){this._index={},this.addPath("/",new ft)}fileIterator(t){for(let e in this._index)if(Object.prototype.hasOwnProperty.call(this._index,e)){let o=this._index[e],s=o.getListing();for(let c of s){let n=o.getItem(c);qt(n)&&t(n.getData())}}}addPath(t,e){if(!e)throw new Error("Inode must be specified");if(t[0]!=="/")throw new Error("Path must be absolute, got: "+t);if(Object.prototype.hasOwnProperty.call(this._index,t))return this._index[t]===e;let o=this._split_path(t),s=o[0],c=o[1],n=this._index[s];return n===void 0&&t!=="/"&&(n=new ft,!this.addPath(s,n))||t!=="/"&&!n.addItem(c,e)?!1:(Ut(e)&&(this._index[t]=e),!0)}addPathFast(t,e){let o=t.lastIndexOf("/"),s=o===0?"/":t.substring(0,o),c=t.substring(o+1),n=this._index[s];return n===void 0&&(n=new ft,this.addPathFast(s,n)),n.addItem(c,e)?(e.isDir()&&(this._index[t]=e),!0):!1}removePath(t){let e=this._split_path(t),o=e[0],s=e[1],c=this._index[o];if(c===void 0)return null;let n=c.remItem(s);if(n===null)return null;if(Ut(n)){let l=n.getListing();for(let p of l)this.removePath(t+"/"+p);t!=="/"&&delete this._index[t]}return n}ls(t){let e=this._index[t];return e===void 0?null:e.getListing()}getInode(t){let e=this._split_path(t),o=e[0],s=e[1],c=this._index[o];return c===void 0?null:o===t?c:c.getItem(s)}_split_path(t){let e=A(t),o=t.substr(e.length+(e==="/"?0:1));return[e,o]}};h(vt,"FileIndex");var de=class{constructor(t){this.data=t}isFile(){return!0}isDir(){return!1}getData(){return this.data}setData(t){this.data=t}toStats(){return new q(D.FILE,4096,438)}};h(de,"IndexFileInode");var ft=class{constructor(t=null){this.data=t,this._ls={}}isFile(){return!1}isDir(){return!0}getData(){return this.data}getStats(){return new q(D.DIRECTORY,4096,365)}toStats(){return this.getStats()}getListing(){return Object.keys(this._ls)}getItem(t){let e=this._ls[t];return e||null}addItem(t,e){return t in this._ls?!1:(this._ls[t]=e,!0)}remItem(t){let e=this._ls[t];return e===void 0?null:(delete this._ls[t],e)}};h(ft,"IndexDirInode");function qt(d){return!!d&&d.isFile()}h(qt,"isIndexFileInode");function Ut(d){return!!d&&d.isDir()}h(Ut,"isIndexDirInode");var fe=class extends tt{constructor({index:e,baseUrl:o=""}){super();e||(e="index.json");let s=typeof e=="string"?Ie(e,"json"):Promise.resolve(e);this._ready=s.then(c=>(this._index=vt.fromListing(c),this)),o.length>0&&o.charAt(o.length-1)!=="/"&&(o=o+"/"),this.prefixUrl=o,this._requestFileInternal=Ie,this._requestFileSizeInternal=Qe}static isAvailable(){return Ge}get metadata(){return At(yt({},super.metadata),{name:fe.Name,readonly:!0})}empty(){this._index.fileIterator(function(e){e.fileData=null})}preloadFile(e,o){let s=this._index.getInode(e);if(qt(s)){if(s===null)throw y.ENOENT(e);let c=s.getData();c.size=o.length,c.fileData=o}else throw y.EISDIR(e)}stat(e,o){return P(this,null,function*(){let s=this._index.getInode(e);if(s===null)throw y.ENOENT(e);if(!s.toStats().hasAccess(4,o))throw y.EACCES(e);let c;if(qt(s))c=s.getData(),c.size<0&&(c.size=yield this._requestFileSize(e));else if(Ut(s))c=s.getStats();else throw y.FileError(I.EINVAL,e);return c})}open(e,o,s,c){return P(this,null,function*(){if(o.isWriteable())throw new y(I.EPERM,e);let n=this._index.getInode(e);if(n===null)throw y.ENOENT(e);if(!n.toStats().hasAccess(o.getMode(),c))throw y.EACCES(e);if(qt(n)||Ut(n))switch(o.pathExistsAction()){case H.THROW_EXCEPTION:case H.TRUNCATE_FILE:throw y.EEXIST(e);case H.NOP:if(Ut(n)){let w=n.getStats();return new bt(this,e,o,w,w.fileData||void 0)}let l=n.getData();if(l.fileData)return new bt(this,e,o,q.clone(l),l.fileData);let p=yield this._requestFile(e,"buffer");return l.size=p.length,l.fileData=p,new bt(this,e,o,q.clone(l),p);default:throw new y(I.EINVAL,"Invalid FileMode object.")}else throw y.EPERM(e)})}readdir(e,o){return P(this,null,function*(){return this.readdirSync(e,o)})}readFile(e,o,s,c){return P(this,null,function*(){let n=yield this.open(e,s,420,c);try{let p=n.getBuffer();return o===null?Xe(p):p.toString(o)}finally{yield n.close()}})}_getHTTPPath(e){return e.charAt(0)==="/"&&(e=e.slice(1)),this.prefixUrl+e}_requestFile(e,o){return this._requestFileInternal(this._getHTTPPath(e),o)}_requestFileSize(e){return this._requestFileSizeInternal(this._getHTTPPath(e))}},_t=fe;h(_t,"HTTPRequest"),_t.Name="HTTPRequest",_t.Create=nt.bind(fe),_t.Options={index:{type:["string","object"],optional:!0,description:"URL to a file index as a JSON file or the file index object itself, generated with the make_http_index script. Defaults to `index.json`."},baseUrl:{type:"string",optional:!0,description:"Used as the URL prefix for fetched files. Default: Fetch files relative to the index."}};var L=function(d,t,e,o){function s(c){return c instanceof e?c:new e(function(n){n(c)})}return h(s,"adopt"),new(e||(e=Promise))(function(c,n){function l(m){try{w(o.next(m))}catch(E){n(E)}}h(l,"fulfilled");function p(m){try{w(o.throw(m))}catch(E){n(E)}}h(p,"rejected");function w(m){m.done?c(m.value):s(m.value).then(l,p)}h(w,"step"),w((o=o.apply(d,t||[])).next())})},Vt=class{constructor(t,e){this.key=t,this.value=e,this.prev=null,this.next=null}};h(Vt,"LRUNode");var pe=class{constructor(t){this.limit=t,this.size=0,this.map={},this.head=null,this.tail=null}set(t,e){let o=new Vt(t,e);this.map[t]?(this.map[t].value=o.value,this.remove(o.key)):this.size>=this.limit&&(delete this.map[this.tail.key],this.size--,this.tail=this.tail.prev,this.tail.next=null),this.setHead(o)}get(t){if(this.map[t]){let e=this.map[t].value,o=new Vt(t,e);return this.remove(t),this.setHead(o),e}else return null}remove(t){let e=this.map[t];e&&(e.prev!==null?e.prev.next=e.next:this.head=e.next,e.next!==null?e.next.prev=e.prev:this.tail=e.prev,delete this.map[t],this.size--)}removeAll(){this.size=0,this.map={},this.head=null,this.tail=null}setHead(t){t.next=this.head,t.prev=null,this.head!==null&&(this.head.prev=t),this.head=t,this.tail===null&&(this.tail=t),this.size++,this.map[t.key]=t}};h(pe,"LRUCache");var Xt=class extends ut{constructor(t,e,o,s,c){super(t,e,o,s,c)}sync(){return L(this,void 0,void 0,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())})}close(){return L(this,void 0,void 0,function*(){this.sync()})}};h(Xt,"AsyncKeyValueFile");var Kt=class extends tt{static isAvailable(){return!0}constructor(t){super(),this._cache=null,t>0&&(this._cache=new pe(t))}init(t){return L(this,void 0,void 0,function*(){this.store=t,yield this.makeRootDirectory()})}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!1}empty(){return L(this,void 0,void 0,function*(){this._cache&&this._cache.removeAll(),yield this.store.clear(),yield this.makeRootDirectory()})}access(t,e,o){return L(this,void 0,void 0,function*(){let s=this.store.beginTransaction("readonly"),c=yield this.findINode(s,t);if(!c)throw y.ENOENT(t);if(!c.toStats().hasAccess(e,o))throw y.EACCES(t)})}rename(t,e,o){return L(this,void 0,void 0,function*(){let s=this._cache;this._cache&&(this._cache=null,s.removeAll());try{let c=this.store.beginTransaction("readwrite"),n=A(t),l=X(t),p=A(e),w=X(e),m=yield this.findINode(c,n),E=yield this.getDirListing(c,n,m);if(!m.toStats().hasAccess(2,o))throw y.EACCES(t);if(!E[l])throw y.ENOENT(t);let b=E[l];if(delete E[l],(p+"/").indexOf(t+"/")===0)throw new y(I.EBUSY,n);let x,N;if(p===n?(x=m,N=E):(x=yield this.findINode(c,p),N=yield this.getDirListing(c,p,x)),N[w]){let v=yield this.getINode(c,e,N[w]);if(v.isFile())try{yield c.del(v.id),yield c.del(N[w])}catch(_){throw yield c.abort(),_}else throw y.EPERM(e)}N[w]=b;try{yield c.put(m.id,T.from(JSON.stringify(E)),!0),yield c.put(x.id,T.from(JSON.stringify(N)),!0)}catch(v){throw yield c.abort(),v}yield c.commit()}finally{s&&(this._cache=s)}})}stat(t,e){return L(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readonly"),c=(yield this.findINode(o,t)).toStats();if(!c.hasAccess(4,e))throw y.EACCES(t);return c})}createFile(t,e,o,s){return L(this,void 0,void 0,function*(){let c=this.store.beginTransaction("readwrite"),n=T.alloc(0),l=yield this.commitNewFile(c,t,D.FILE,o,s,n);return new Xt(this,t,e,l.toStats(),n)})}openFile(t,e,o){return L(this,void 0,void 0,function*(){let s=this.store.beginTransaction("readonly"),c=yield this.findINode(s,t),n=yield s.get(c.id);if(!c.toStats().hasAccess(e.getMode(),o))throw y.EACCES(t);if(n===void 0)throw y.ENOENT(t);return new Xt(this,t,e,c.toStats(),n)})}unlink(t,e){return L(this,void 0,void 0,function*(){return this.removeEntry(t,!1,e)})}rmdir(t,e){return L(this,void 0,void 0,function*(){if((yield this.readdir(t,e)).length>0)throw y.ENOTEMPTY(t);yield this.removeEntry(t,!0,e)})}mkdir(t,e,o){return L(this,void 0,void 0,function*(){let s=this.store.beginTransaction("readwrite"),c=T.from("{}");yield this.commitNewFile(s,t,D.DIRECTORY,e,o,c)})}readdir(t,e){return L(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readonly"),s=yield this.findINode(o,t);if(!s.toStats().hasAccess(4,e))throw y.EACCES(t);return Object.keys(yield this.getDirListing(o,t,s))})}chmod(t,e,o){return L(this,void 0,void 0,function*(){yield(yield this.openFile(t,V.getFileFlag("r+"),o)).chmod(e)})}chown(t,e,o,s){return L(this,void 0,void 0,function*(){yield(yield this.openFile(t,V.getFileFlag("r+"),s)).chown(e,o)})}_sync(t,e,o){return L(this,void 0,void 0,function*(){let s=this.store.beginTransaction("readwrite"),c=yield this._findINode(s,A(t),X(t)),n=yield this.getINode(s,t,c),l=n.update(o);try{yield s.put(n.id,e,!0),l&&(yield s.put(c,n.toBuffer(),!0))}catch(p){throw yield s.abort(),p}yield s.commit()})}makeRootDirectory(){return L(this,void 0,void 0,function*(){let t=this.store.beginTransaction("readwrite");if((yield t.get(st))===void 0){let e=new Date().getTime(),o=new et(Pt(),4096,511|D.DIRECTORY,e,e,e,0,0);yield t.put(o.id,oe(),!1),yield t.put(st,o.toBuffer(),!1),yield t.commit()}})}_findINode(t,e,o,s=new Set){return L(this,void 0,void 0,function*(){let c=Rt.join(e,o);if(s.has(c))throw new y(I.EIO,"Infinite loop detected while finding inode",c);if(s.add(c),this._cache){let n=this._cache.get(c);if(n)return n}if(e==="/"){if(o==="")return this._cache&&this._cache.set(c,st),st;{let n=yield this.getINode(t,e,st),l=yield this.getDirListing(t,e,n);if(l[o]){let p=l[o];return this._cache&&this._cache.set(c,p),p}else throw y.ENOENT($t(e,o))}}else{let n=yield this.findINode(t,e,s),l=yield this.getDirListing(t,e,n);if(l[o]){let p=l[o];return this._cache&&this._cache.set(c,p),p}else throw y.ENOENT($t(e,o))}})}findINode(t,e,o=new Set){return L(this,void 0,void 0,function*(){let s=yield this._findINode(t,A(e),X(e),o);return this.getINode(t,e,s)})}getINode(t,e,o){return L(this,void 0,void 0,function*(){let s=yield t.get(o);if(!s)throw y.ENOENT(e);return et.fromBuffer(s)})}getDirListing(t,e,o){return L(this,void 0,void 0,function*(){if(!o.isDirectory())throw y.ENOTDIR(e);let s=yield t.get(o.id);try{return JSON.parse(s.toString())}catch(c){throw y.ENOENT(e)}})}addNewNode(t,e){return L(this,void 0,void 0,function*(){let o=0,s=h(()=>L(this,void 0,void 0,function*(){if(++o===5)throw new y(I.EIO,"Unable to commit data to key-value store.");{let c=Pt();return(yield t.put(c,e,!1))?c:s()}}),"reroll");return s()})}commitNewFile(t,e,o,s,c,n){return L(this,void 0,void 0,function*(){let l=A(e),p=X(e),w=yield this.findINode(t,l),m=yield this.getDirListing(t,l,w),E=new Date().getTime();if(!w.toStats().hasAccess(2,c))throw y.EACCES(e);if(e==="/")throw y.EEXIST(e);if(m[p])throw yield t.abort(),y.EEXIST(e);try{let b=yield this.addNewNode(t,n),x=new et(b,n.length,s|o,E,E,E,c.uid,c.gid),N=yield this.addNewNode(t,x.toBuffer());return m[p]=N,yield t.put(w.id,T.from(JSON.stringify(m)),!0),yield t.commit(),x}catch(b){throw t.abort(),b}})}removeEntry(t,e,o){return L(this,void 0,void 0,function*(){this._cache&&this._cache.remove(t);let s=this.store.beginTransaction("readwrite"),c=A(t),n=yield this.findINode(s,c),l=yield this.getDirListing(s,c,n),p=X(t);if(!l[p])throw y.ENOENT(t);let w=l[p],m=yield this.getINode(s,t,w);if(!m.toStats().hasAccess(2,o))throw y.EACCES(t);if(delete l[p],!e&&m.isDirectory())throw y.EISDIR(t);if(e&&!m.isDirectory())throw y.ENOTDIR(t);try{yield s.del(m.id),yield s.del(w),yield s.put(n.id,T.from(JSON.stringify(l)),!0)}catch(E){throw yield s.abort(),E}yield s.commit()})}};h(Kt,"AsyncKeyValueFileSystem");var Rr=(()=>{try{return globalThis.indexedDB||globalThis.mozIndexedDB||globalThis.webkitIndexedDB||globalThis.msIndexedDB}catch(d){return null}})();function Jt(d,t=d.toString()){switch(d.name){case"NotFoundError":return new y(I.ENOENT,t);case"QuotaExceededError":return new y(I.ENOSPC,t);default:return new y(I.EIO,t)}}h(Jt,"convertError");function Qt(d,t=I.EIO,e=null){return function(o){o.preventDefault(),d(new y(t,e!==null?e:void 0))}}h(Qt,"onErrorHandler");var Lt=class{constructor(t,e){this.tx=t;this.store=e}get(t){return new Promise((e,o)=>{try{let s=this.store.get(t);s.onerror=Qt(o),s.onsuccess=c=>{let n=c.target.result;e(n===void 0?n:T.from(n))}}catch(s){o(Jt(s))}})}};h(Lt,"IndexedDBROTransaction");var Gt=class extends Lt{constructor(t,e){super(t,e)}put(t,e,o){return new Promise((s,c)=>{try{let n=o?this.store.put(e,t):this.store.add(e,t);n.onerror=Qt(c),n.onsuccess=()=>{s(!0)}}catch(n){c(Jt(n))}})}del(t){return new Promise((e,o)=>{try{let s=this.store.delete(t);s.onerror=Qt(o),s.onsuccess=()=>{e()}}catch(s){o(Jt(s))}})}commit(){return new Promise(t=>{setTimeout(t,0)})}abort(){return new Promise((t,e)=>{try{this.tx.abort(),t()}catch(o){e(Jt(o))}})}};h(Gt,"IndexedDBRWTransaction");var Tt=class{constructor(t,e){this.db=t;this.storeName=e}static Create(t,e){return new Promise((o,s)=>{let c=e.open(t,1);c.onupgradeneeded=n=>{let l=n.target.result;l.objectStoreNames.contains(t)&&l.deleteObjectStore(t),l.createObjectStore(t)},c.onsuccess=n=>{o(new Tt(n.target.result,t))},c.onerror=Qt(s,I.EACCES)})}name(){return pt.Name+" - "+this.storeName}clear(){return new Promise((t,e)=>{try{let o=this.db.transaction(this.storeName,"readwrite"),s=o.objectStore(this.storeName),c=s.clear();c.onsuccess=()=>{setTimeout(t,0)},c.onerror=Qt(e)}catch(o){e(Jt(o))}})}beginTransaction(t="readonly"){let e=this.db.transaction(this.storeName,t),o=e.objectStore(this.storeName);if(t==="readwrite")return new Gt(e,o);if(t==="readonly")return new Lt(e,o);throw new y(I.EINVAL,"Invalid transaction type.")}};h(Tt,"IndexedDBStore");var xe=class extends Kt{static isAvailable(t=globalThis.indexedDB){try{if(!(t instanceof IDBFactory)||!Rr.open("__zenfs_test__"))return!1}catch(e){return!1}}constructor({cacheSize:t=100,storeName:e="zenfs",idbFactory:o=globalThis.indexedDB}){super(t),this._ready=Tt.Create(e,o).then(s=>(this.init(s),this))}},pt=xe;h(pt,"IndexedDBFileSystem"),pt.Name="IndexedDB",pt.Create=nt.bind(xe),pt.Options={storeName:{type:"string",optional:!0,description:"The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name."},cacheSize:{type:"number",optional:!0,description:"The size of the inode cache. Defaults to 100. A size of 0 or below disables caching."},idbFactory:{type:"object",optional:!0,description:"The IDBFactory to use. Defaults to globalThis.indexedDB."}};var Zt=class{constructor(t){this._storage=t}name(){return mt.Name}clear(){this._storage.clear()}beginTransaction(t){return new St(this)}get(t){let e=this._storage.getItem(t);if(typeof e=="string")return T.from(e)}put(t,e,o){try{return!o&&this._storage.getItem(t)!==null?!1:(this._storage.setItem(t,e.toString()),!0)}catch(s){throw new y(I.ENOSPC,"Storage is full.")}}del(t){try{this._storage.removeItem(t)}catch(e){throw new y(I.EIO,"Unable to delete key "+t+": "+e)}}};h(Zt,"StorageStore");var be=class extends It{static isAvailable(t=globalThis.localStorage){return t instanceof Storage}constructor({storage:t=globalThis.localStorage}){super({store:new Zt(t)})}},mt=be;h(mt,"StorageFileSystem"),mt.Name="Storage",mt.Create=nt.bind(be),mt.Options={storage:{type:"object",optional:!0,description:"The Storage to use. Defaults to globalThis.localStorage."}};function Pr(d){return typeof d=="object"&&"isBFS"in d&&!!d.isBFS}h(Pr,"isRPCMessage");var te=class extends tt{constructor({worker:e}){super();this._currentID=0;this._requests=new Map;this._isInitialized=!1;this._worker=e,this._worker.onmessage=o=>{if(!Pr(o.data))return;let{id:s,method:c,value:n}=o.data;if(c==="metadata"){this._metadata=n,this._isInitialized=!0;return}let{resolve:l,reject:p}=this._requests.get(s);if(this._requests.delete(s),n instanceof Error||n instanceof y){p(n);return}l(n)}}static isAvailable(){return typeof importScripts!="undefined"||typeof Worker!="undefined"}get metadata(){return At(yt(yt({},super.metadata),this._metadata),{name:te.Name,synchronous:!1})}_rpc(e,...o){return P(this,null,function*(){return new Promise((s,c)=>{let n=this._currentID++;this._requests.set(n,{resolve:s,reject:c}),this._worker.postMessage({isBFS:!0,id:n,method:e,args:o})})})}rename(e,o,s){return this._rpc("rename",e,o,s)}stat(e,o){return this._rpc("stat",e,o)}open(e,o,s,c){return this._rpc("open",e,o,s,c)}unlink(e,o){return this._rpc("unlink",e,o)}rmdir(e,o){return this._rpc("rmdir",e,o)}mkdir(e,o,s){return this._rpc("mkdir",e,o,s)}readdir(e,o){return this._rpc("readdir",e,o)}exists(e,o){return this._rpc("exists",e,o)}realpath(e,o){return this._rpc("realpath",e,o)}truncate(e,o,s){return this._rpc("truncate",e,o,s)}readFile(e,o,s,c){return this._rpc("readFile",e,o,s,c)}writeFile(e,o,s,c,n,l){return this._rpc("writeFile",e,o,s,c,n,l)}appendFile(e,o,s,c,n,l){return this._rpc("appendFile",e,o,s,c,n,l)}chmod(e,o,s){return this._rpc("chmod",e,o,s)}chown(e,o,s,c){return this._rpc("chown",e,o,s,c)}utimes(e,o,s,c){return this._rpc("utimes",e,o,s,c)}link(e,o,s){return this._rpc("link",e,o,s)}symlink(e,o,s,c){return this._rpc("symlink",e,o,s,c)}readlink(e,o){return this._rpc("readlink",e,o)}syncClose(e,o){return this._rpc("syncClose",e,o)}},Ot=te;h(Ot,"WorkerFS"),Ot.Name="WorkerFS",Ot.Create=nt.bind(te),Ot.Options={worker:{type:"object",description:"The target worker that you want to connect to, or the current worker if in a worker context.",validator:e=>P(te,null,function*(){if(typeof(e==null?void 0:e.postMessage)!="function")throw new y(I.EINVAL,"option must be a Web Worker instance.")})}};return Nr(Dr);})();
|
|
1
|
+
var ZenFS_DOM=(()=>{var Lt=Object.defineProperty,li=Object.defineProperties,hi=Object.getOwnPropertyDescriptor,di=Object.getOwnPropertyDescriptors,fi=Object.getOwnPropertyNames,Ae=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,pi=Object.prototype.propertyIsEnumerable;var C=Math.pow,ve=(l,t,e)=>t in l?Lt(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,pt=(l,t)=>{for(var e in t||(t={}))Re.call(t,e)&&ve(l,e,t[e]);if(Ae)for(var e of Ae(t))pi.call(t,e)&&ve(l,e,t[e]);return l},At=(l,t)=>li(l,di(t)),h=(l,t)=>Lt(l,"name",{value:t,configurable:!0});var mi=(l,t)=>{for(var e in t)Lt(l,e,{get:t[e],enumerable:!0})},yi=(l,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fi(t))!Re.call(l,o)&&o!==e&&Lt(l,o,{get:()=>t[o],enumerable:!(n=hi(t,o))||n.enumerable});return l};var wi=l=>yi(Lt({},"__esModule",{value:!0}),l);var v=(l,t,e)=>new Promise((n,o)=>{var a=w=>{try{f(e.next(w))}catch(S){o(S)}},s=w=>{try{f(e.throw(w))}catch(S){o(S)}},f=w=>w.done?n(w.value):Promise.resolve(w.value).then(a,s);f((e=e.apply(l,t)).next())}),Ce=(l,t,e)=>(t=l[Symbol.asyncIterator],e=(n,o)=>(o=l[n])&&(t[n]=a=>new Promise((s,f,w)=>(a=o.call(l,a),w=a.done,Promise.resolve(a.value).then(S=>s({value:S,done:w}),f)))),t?t.call(l):(l=l[Symbol.iterator](),t={},e("next"),e("return"),t));var Ti={};mi(Ti,{FileSystemAccessFile:()=>zt,FileSystemAccessFileSystem:()=>Nt,HTTPRequest:()=>bt,IndexedDBFileSystem:()=>dt,IndexedDBROTransaction:()=>Dt,IndexedDBRWTransaction:()=>Vt,IndexedDBStore:()=>Ot,StorageFileSystem:()=>ft,StorageStore:()=>Kt,WorkerFS:()=>Tt});var kt={},Pe=!1;function gi(){if(Pe)return kt;Pe=!0,kt.byteLength=f,kt.toByteArray=S,kt.fromByteArray=b;for(var l=[],t=[],e=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=n.length;o<a;++o)l[o]=n[o],t[n.charCodeAt(o)]=o;t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63;function s(x){var N=x.length;if(N%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=x.indexOf("=");B===-1&&(B=N);var P=B===N?0:4-B%4;return[B,P]}h(s,"getLens");function f(x){var N=s(x),B=N[0],P=N[1];return(B+P)*3/4-P}h(f,"byteLength");function w(x,N,B){return(N+B)*3/4-B}h(w,"_byteLength");function S(x){var N,B=s(x),P=B[0],q=B[1],D=new e(w(x,P,q)),X=0,et=q>0?P-4:P,J;for(J=0;J<et;J+=4)N=t[x.charCodeAt(J)]<<18|t[x.charCodeAt(J+1)]<<12|t[x.charCodeAt(J+2)]<<6|t[x.charCodeAt(J+3)],D[X++]=N>>16&255,D[X++]=N>>8&255,D[X++]=N&255;return q===2&&(N=t[x.charCodeAt(J)]<<2|t[x.charCodeAt(J+1)]>>4,D[X++]=N&255),q===1&&(N=t[x.charCodeAt(J)]<<10|t[x.charCodeAt(J+1)]<<4|t[x.charCodeAt(J+2)]>>2,D[X++]=N>>8&255,D[X++]=N&255),D}h(S,"toByteArray");function y(x){return l[x>>18&63]+l[x>>12&63]+l[x>>6&63]+l[x&63]}h(y,"tripletToBase64");function I(x,N,B){for(var P,q=[],D=N;D<B;D+=3)P=(x[D]<<16&16711680)+(x[D+1]<<8&65280)+(x[D+2]&255),q.push(y(P));return q.join("")}h(I,"encodeChunk");function b(x){for(var N,B=x.length,P=B%3,q=[],D=16383,X=0,et=B-P;X<et;X+=D)q.push(I(x,X,X+D>et?et:X+D));return P===1?(N=x[B-1],q.push(l[N>>2]+l[N<<4&63]+"==")):P===2&&(N=(x[B-2]<<8)+x[B-1],q.push(l[N>>10]+l[N>>4&63]+l[N<<2&63]+"=")),q.join("")}return h(b,"fromByteArray"),kt}h(gi,"dew$2");var Qt={},De=!1;function Ei(){if(De)return Qt;De=!0;return Qt.read=function(l,t,e,n,o){var a,s,f=o*8-n-1,w=(1<<f)-1,S=w>>1,y=-7,I=e?o-1:0,b=e?-1:1,x=l[t+I];for(I+=b,a=x&(1<<-y)-1,x>>=-y,y+=f;y>0;a=a*256+l[t+I],I+=b,y-=8);for(s=a&(1<<-y)-1,a>>=-y,y+=n;y>0;s=s*256+l[t+I],I+=b,y-=8);if(a===0)a=1-S;else{if(a===w)return s?NaN:(x?-1:1)*(1/0);s=s+Math.pow(2,n),a=a-S}return(x?-1:1)*s*Math.pow(2,a-n)},Qt.write=function(l,t,e,n,o,a){var s,f,w,S=a*8-o-1,y=(1<<S)-1,I=y>>1,b=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:a-1,N=n?1:-1,B=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,s=y):(s=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-s))<1&&(s--,w*=2),s+I>=1?t+=b/w:t+=b*Math.pow(2,1-I),t*w>=2&&(s++,w/=2),s+I>=y?(f=0,s=y):s+I>=1?(f=(t*w-1)*Math.pow(2,o),s=s+I):(f=t*Math.pow(2,I-1)*Math.pow(2,o),s=0));o>=8;l[e+x]=f&255,x+=N,f/=256,o-=8);for(s=s<<o|f,S+=o;S>0;l[e+x]=s&255,x+=N,s/=256,S-=8);l[e+x-N]|=B*128},Qt}h(Ei,"dew$1");var mt={},Ue=!1;function Si(){if(Ue)return mt;Ue=!0;let l=gi(),t=Ei(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;mt.Buffer=s,mt.SlowBuffer=q,mt.INSPECT_MAX_BYTES=50;let n=2147483647;mt.kMaxLength=n,s.TYPED_ARRAY_SUPPORT=o(),!s.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{let c=new Uint8Array(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,Uint8Array.prototype),Object.setPrototypeOf(c,i),c.foo()===42}catch(c){return!1}}h(o,"typedArraySupport"),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function a(c){if(c>n)throw new RangeError('The value "'+c+'" is invalid for option "size"');let i=new Uint8Array(c);return Object.setPrototypeOf(i,s.prototype),i}h(a,"createBuffer");function s(c,i,r){if(typeof c=="number"){if(typeof i=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return y(c)}return f(c,i,r)}h(s,"Buffer"),s.poolSize=8192;function f(c,i,r){if(typeof c=="string")return I(c,i);if(ArrayBuffer.isView(c))return x(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(st(c,ArrayBuffer)||c&&st(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(st(c,SharedArrayBuffer)||c&&st(c.buffer,SharedArrayBuffer)))return N(c,i,r);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=c.valueOf&&c.valueOf();if(u!=null&&u!==c)return s.from(u,i,r);let d=B(c);if(d)return d;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return s.from(c[Symbol.toPrimitive]("string"),i,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}h(f,"from"),s.from=function(c,i,r){return f(c,i,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function w(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}h(w,"assertSize");function S(c,i,r){return w(c),c<=0?a(c):i!==void 0?typeof r=="string"?a(c).fill(i,r):a(c).fill(i):a(c)}h(S,"alloc"),s.alloc=function(c,i,r){return S(c,i,r)};function y(c){return w(c),a(c<0?0:P(c)|0)}h(y,"allocUnsafe"),s.allocUnsafe=function(c){return y(c)},s.allocUnsafeSlow=function(c){return y(c)};function I(c,i){if((typeof i!="string"||i==="")&&(i="utf8"),!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);let r=D(c,i)|0,u=a(r),d=u.write(c,i);return d!==r&&(u=u.slice(0,d)),u}h(I,"fromString");function b(c){let i=c.length<0?0:P(c.length)|0,r=a(i);for(let u=0;u<i;u+=1)r[u]=c[u]&255;return r}h(b,"fromArrayLike");function x(c){if(st(c,Uint8Array)){let i=new Uint8Array(c);return N(i.buffer,i.byteOffset,i.byteLength)}return b(c)}h(x,"fromArrayView");function N(c,i,r){if(i<0||c.byteLength<i)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<i+(r||0))throw new RangeError('"length" is outside of buffer bounds');let u;return i===void 0&&r===void 0?u=new Uint8Array(c):r===void 0?u=new Uint8Array(c,i):u=new Uint8Array(c,i,r),Object.setPrototypeOf(u,s.prototype),u}h(N,"fromArrayBuffer");function B(c){if(s.isBuffer(c)){let i=P(c.length)|0,r=a(i);return r.length===0||c.copy(r,0,0,i),r}if(c.length!==void 0)return typeof c.length!="number"||fe(c.length)?a(0):b(c);if(c.type==="Buffer"&&Array.isArray(c.data))return b(c.data)}h(B,"fromObject");function P(c){if(c>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return c|0}h(P,"checked");function q(c){return+c!=c&&(c=0),s.alloc(+c)}h(q,"SlowBuffer"),s.isBuffer=h(function(i){return i!=null&&i._isBuffer===!0&&i!==s.prototype},"isBuffer"),s.compare=h(function(i,r){if(st(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),st(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(i)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===r)return 0;let u=i.length,d=r.length;for(let m=0,g=Math.min(u,d);m<g;++m)if(i[m]!==r[m]){u=i[m],d=r[m];break}return u<d?-1:d<u?1:0},"compare"),s.isEncoding=h(function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},"isEncoding"),s.concat=h(function(i,r){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return s.alloc(0);let u;if(r===void 0)for(r=0,u=0;u<i.length;++u)r+=i[u].length;let d=s.allocUnsafe(r),m=0;for(u=0;u<i.length;++u){let g=i[u];if(st(g,Uint8Array))m+g.length>d.length?(s.isBuffer(g)||(g=s.from(g)),g.copy(d,m)):Uint8Array.prototype.set.call(d,g,m);else if(s.isBuffer(g))g.copy(d,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=g.length}return d},"concat");function D(c,i){if(s.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||st(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);let r=c.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&r===0)return 0;let d=!1;for(;;)switch(i){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return de(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Fe(c).length;default:if(d)return u?-1:de(c).length;i=(""+i).toLowerCase(),d=!0}}h(D,"byteLength"),s.byteLength=D;function X(c,i,r){let u=!1;if((i===void 0||i<0)&&(i=0),i>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,i>>>=0,r<=i))return"";for(c||(c="utf8");;)switch(c){case"hex":return ei(this,i,r);case"utf8":case"utf-8":return Se(this,i,r);case"ascii":return Ze(this,i,r);case"latin1":case"binary":return ti(this,i,r);case"base64":return Ge(this,i,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ii(this,i,r);default:if(u)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),u=!0}}h(X,"slowToString"),s.prototype._isBuffer=!0;function et(c,i,r){let u=c[i];c[i]=c[r],c[r]=u}h(et,"swap"),s.prototype.swap16=h(function(){let i=this.length;if(i%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<i;r+=2)et(this,r,r+1);return this},"swap16"),s.prototype.swap32=h(function(){let i=this.length;if(i%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<i;r+=4)et(this,r,r+3),et(this,r+1,r+2);return this},"swap32"),s.prototype.swap64=h(function(){let i=this.length;if(i%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<i;r+=8)et(this,r,r+7),et(this,r+1,r+6),et(this,r+2,r+5),et(this,r+3,r+4);return this},"swap64"),s.prototype.toString=h(function(){let i=this.length;return i===0?"":arguments.length===0?Se(this,0,i):X.apply(this,arguments)},"toString"),s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=h(function(i){if(!s.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i?!0:s.compare(this,i)===0},"equals"),s.prototype.inspect=h(function(){let i="",r=mt.INSPECT_MAX_BYTES;return i=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(i+=" ... "),"<Buffer "+i+">"},"inspect"),e&&(s.prototype[e]=s.prototype.inspect),s.prototype.compare=h(function(i,r,u,d,m){if(st(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),!s.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(r===void 0&&(r=0),u===void 0&&(u=i?i.length:0),d===void 0&&(d=0),m===void 0&&(m=this.length),r<0||u>i.length||d<0||m>this.length)throw new RangeError("out of range index");if(d>=m&&r>=u)return 0;if(d>=m)return-1;if(r>=u)return 1;if(r>>>=0,u>>>=0,d>>>=0,m>>>=0,this===i)return 0;let g=m-d,O=u-r,M=Math.min(g,O),L=this.slice(d,m),$=i.slice(r,u);for(let A=0;A<M;++A)if(L[A]!==$[A]){g=L[A],O=$[A];break}return g<O?-1:O<g?1:0},"compare");function J(c,i,r,u,d){if(c.length===0)return-1;if(typeof r=="string"?(u=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,fe(r)&&(r=d?0:c.length-1),r<0&&(r=c.length+r),r>=c.length){if(d)return-1;r=c.length-1}else if(r<0)if(d)r=0;else return-1;if(typeof i=="string"&&(i=s.from(i,u)),s.isBuffer(i))return i.length===0?-1:Ee(c,i,r,u,d);if(typeof i=="number")return i=i&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(c,i,r):Uint8Array.prototype.lastIndexOf.call(c,i,r):Ee(c,[i],r,u,d);throw new TypeError("val must be string, number or Buffer")}h(J,"bidirectionalIndexOf");function Ee(c,i,r,u,d){let m=1,g=c.length,O=i.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(c.length<2||i.length<2)return-1;m=2,g/=2,O/=2,r/=2}function M($,A){return m===1?$[A]:$.readUInt16BE(A*m)}h(M,"read");let L;if(d){let $=-1;for(L=r;L<g;L++)if(M(c,L)===M(i,$===-1?0:L-$)){if($===-1&&($=L),L-$+1===O)return $*m}else $!==-1&&(L-=L-$),$=-1}else for(r+O>g&&(r=g-O),L=r;L>=0;L--){let $=!0;for(let A=0;A<O;A++)if(M(c,L+A)!==M(i,A)){$=!1;break}if($)return L}return-1}h(Ee,"arrayIndexOf"),s.prototype.includes=h(function(i,r,u){return this.indexOf(i,r,u)!==-1},"includes"),s.prototype.indexOf=h(function(i,r,u){return J(this,i,r,u,!0)},"indexOf"),s.prototype.lastIndexOf=h(function(i,r,u){return J(this,i,r,u,!1)},"lastIndexOf");function qe(c,i,r,u){r=Number(r)||0;let d=c.length-r;u?(u=Number(u),u>d&&(u=d)):u=d;let m=i.length;u>m/2&&(u=m/2);let g;for(g=0;g<u;++g){let O=parseInt(i.substr(g*2,2),16);if(fe(O))return g;c[r+g]=O}return g}h(qe,"hexWrite");function Ve(c,i,r,u){return Gt(de(i,c.length-r),c,r,u)}h(Ve,"utf8Write");function Xe(c,i,r,u){return Gt(si(i),c,r,u)}h(Xe,"asciiWrite");function Ke(c,i,r,u){return Gt(Fe(i),c,r,u)}h(Ke,"base64Write");function Je(c,i,r,u){return Gt(ci(i,c.length-r),c,r,u)}h(Je,"ucs2Write"),s.prototype.write=h(function(i,r,u,d){if(r===void 0)d="utf8",u=this.length,r=0;else if(u===void 0&&typeof r=="string")d=r,u=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(u)?(u=u>>>0,d===void 0&&(d="utf8")):(d=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let m=this.length-r;if((u===void 0||u>m)&&(u=m),i.length>0&&(u<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let g=!1;for(;;)switch(d){case"hex":return qe(this,i,r,u);case"utf8":case"utf-8":return Ve(this,i,r,u);case"ascii":case"latin1":case"binary":return Xe(this,i,r,u);case"base64":return Ke(this,i,r,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Je(this,i,r,u);default:if(g)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),g=!0}},"write"),s.prototype.toJSON=h(function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},"toJSON");function Ge(c,i,r){return i===0&&r===c.length?l.fromByteArray(c):l.fromByteArray(c.slice(i,r))}h(Ge,"base64Slice");function Se(c,i,r){r=Math.min(c.length,r);let u=[],d=i;for(;d<r;){let m=c[d],g=null,O=m>239?4:m>223?3:m>191?2:1;if(d+O<=r){let M,L,$,A;switch(O){case 1:m<128&&(g=m);break;case 2:M=c[d+1],(M&192)===128&&(A=(m&31)<<6|M&63,A>127&&(g=A));break;case 3:M=c[d+1],L=c[d+2],(M&192)===128&&(L&192)===128&&(A=(m&15)<<12|(M&63)<<6|L&63,A>2047&&(A<55296||A>57343)&&(g=A));break;case 4:M=c[d+1],L=c[d+2],$=c[d+3],(M&192)===128&&(L&192)===128&&($&192)===128&&(A=(m&15)<<18|(M&63)<<12|(L&63)<<6|$&63,A>65535&&A<1114112&&(g=A))}}g===null?(g=65533,O=1):g>65535&&(g-=65536,u.push(g>>>10&1023|55296),g=56320|g&1023),u.push(g),d+=O}return Qe(u)}h(Se,"utf8Slice");let Ie=4096;function Qe(c){let i=c.length;if(i<=Ie)return String.fromCharCode.apply(String,c);let r="",u=0;for(;u<i;)r+=String.fromCharCode.apply(String,c.slice(u,u+=Ie));return r}h(Qe,"decodeCodePointsArray");function Ze(c,i,r){let u="";r=Math.min(c.length,r);for(let d=i;d<r;++d)u+=String.fromCharCode(c[d]&127);return u}h(Ze,"asciiSlice");function ti(c,i,r){let u="";r=Math.min(c.length,r);for(let d=i;d<r;++d)u+=String.fromCharCode(c[d]);return u}h(ti,"latin1Slice");function ei(c,i,r){let u=c.length;(!i||i<0)&&(i=0),(!r||r<0||r>u)&&(r=u);let d="";for(let m=i;m<r;++m)d+=ai[c[m]];return d}h(ei,"hexSlice");function ii(c,i,r){let u=c.slice(i,r),d="";for(let m=0;m<u.length-1;m+=2)d+=String.fromCharCode(u[m]+u[m+1]*256);return d}h(ii,"utf16leSlice"),s.prototype.slice=h(function(i,r){let u=this.length;i=~~i,r=r===void 0?u:~~r,i<0?(i+=u,i<0&&(i=0)):i>u&&(i=u),r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),r<i&&(r=i);let d=this.subarray(i,r);return Object.setPrototypeOf(d,s.prototype),d},"slice");function V(c,i,r){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+i>r)throw new RangeError("Trying to access beyond buffer length")}h(V,"checkOffset"),s.prototype.readUintLE=s.prototype.readUIntLE=h(function(i,r,u){i=i>>>0,r=r>>>0,u||V(i,r,this.length);let d=this[i],m=1,g=0;for(;++g<r&&(m*=256);)d+=this[i+g]*m;return d},"readUIntLE"),s.prototype.readUintBE=s.prototype.readUIntBE=h(function(i,r,u){i=i>>>0,r=r>>>0,u||V(i,r,this.length);let d=this[i+--r],m=1;for(;r>0&&(m*=256);)d+=this[i+--r]*m;return d},"readUIntBE"),s.prototype.readUint8=s.prototype.readUInt8=h(function(i,r){return i=i>>>0,r||V(i,1,this.length),this[i]},"readUInt8"),s.prototype.readUint16LE=s.prototype.readUInt16LE=h(function(i,r){return i=i>>>0,r||V(i,2,this.length),this[i]|this[i+1]<<8},"readUInt16LE"),s.prototype.readUint16BE=s.prototype.readUInt16BE=h(function(i,r){return i=i>>>0,r||V(i,2,this.length),this[i]<<8|this[i+1]},"readUInt16BE"),s.prototype.readUint32LE=s.prototype.readUInt32LE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+this[i+3]*16777216},"readUInt32LE"),s.prototype.readUint32BE=s.prototype.readUInt32BE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),this[i]*16777216+(this[i+1]<<16|this[i+2]<<8|this[i+3])},"readUInt32BE"),s.prototype.readBigUInt64LE=lt(h(function(i){i=i>>>0,Ft(i,"offset");let r=this[i],u=this[i+7];(r===void 0||u===void 0)&&Ut(i,this.length-8);let d=r+this[++i]*C(2,8)+this[++i]*C(2,16)+this[++i]*C(2,24),m=this[++i]+this[++i]*C(2,8)+this[++i]*C(2,16)+u*C(2,24);return BigInt(d)+(BigInt(m)<<BigInt(32))},"readBigUInt64LE")),s.prototype.readBigUInt64BE=lt(h(function(i){i=i>>>0,Ft(i,"offset");let r=this[i],u=this[i+7];(r===void 0||u===void 0)&&Ut(i,this.length-8);let d=r*C(2,24)+this[++i]*C(2,16)+this[++i]*C(2,8)+this[++i],m=this[++i]*C(2,24)+this[++i]*C(2,16)+this[++i]*C(2,8)+u;return(BigInt(d)<<BigInt(32))+BigInt(m)},"readBigUInt64BE")),s.prototype.readIntLE=h(function(i,r,u){i=i>>>0,r=r>>>0,u||V(i,r,this.length);let d=this[i],m=1,g=0;for(;++g<r&&(m*=256);)d+=this[i+g]*m;return m*=128,d>=m&&(d-=Math.pow(2,8*r)),d},"readIntLE"),s.prototype.readIntBE=h(function(i,r,u){i=i>>>0,r=r>>>0,u||V(i,r,this.length);let d=r,m=1,g=this[i+--d];for(;d>0&&(m*=256);)g+=this[i+--d]*m;return m*=128,g>=m&&(g-=Math.pow(2,8*r)),g},"readIntBE"),s.prototype.readInt8=h(function(i,r){return i=i>>>0,r||V(i,1,this.length),this[i]&128?(255-this[i]+1)*-1:this[i]},"readInt8"),s.prototype.readInt16LE=h(function(i,r){i=i>>>0,r||V(i,2,this.length);let u=this[i]|this[i+1]<<8;return u&32768?u|4294901760:u},"readInt16LE"),s.prototype.readInt16BE=h(function(i,r){i=i>>>0,r||V(i,2,this.length);let u=this[i+1]|this[i]<<8;return u&32768?u|4294901760:u},"readInt16BE"),s.prototype.readInt32LE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},"readInt32LE"),s.prototype.readInt32BE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},"readInt32BE"),s.prototype.readBigInt64LE=lt(h(function(i){i=i>>>0,Ft(i,"offset");let r=this[i],u=this[i+7];(r===void 0||u===void 0)&&Ut(i,this.length-8);let d=this[i+4]+this[i+5]*C(2,8)+this[i+6]*C(2,16)+(u<<24);return(BigInt(d)<<BigInt(32))+BigInt(r+this[++i]*C(2,8)+this[++i]*C(2,16)+this[++i]*C(2,24))},"readBigInt64LE")),s.prototype.readBigInt64BE=lt(h(function(i){i=i>>>0,Ft(i,"offset");let r=this[i],u=this[i+7];(r===void 0||u===void 0)&&Ut(i,this.length-8);let d=(r<<24)+this[++i]*C(2,16)+this[++i]*C(2,8)+this[++i];return(BigInt(d)<<BigInt(32))+BigInt(this[++i]*C(2,24)+this[++i]*C(2,16)+this[++i]*C(2,8)+u)},"readBigInt64BE")),s.prototype.readFloatLE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),t.read(this,i,!0,23,4)},"readFloatLE"),s.prototype.readFloatBE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),t.read(this,i,!1,23,4)},"readFloatBE"),s.prototype.readDoubleLE=h(function(i,r){return i=i>>>0,r||V(i,8,this.length),t.read(this,i,!0,52,8)},"readDoubleLE"),s.prototype.readDoubleBE=h(function(i,r){return i=i>>>0,r||V(i,8,this.length),t.read(this,i,!1,52,8)},"readDoubleBE");function G(c,i,r,u,d,m){if(!s.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>d||i<m)throw new RangeError('"value" argument is out of bounds');if(r+u>c.length)throw new RangeError("Index out of range")}h(G,"checkInt"),s.prototype.writeUintLE=s.prototype.writeUIntLE=h(function(i,r,u,d){if(i=+i,r=r>>>0,u=u>>>0,!d){let O=Math.pow(2,8*u)-1;G(this,i,r,u,O,0)}let m=1,g=0;for(this[r]=i&255;++g<u&&(m*=256);)this[r+g]=i/m&255;return r+u},"writeUIntLE"),s.prototype.writeUintBE=s.prototype.writeUIntBE=h(function(i,r,u,d){if(i=+i,r=r>>>0,u=u>>>0,!d){let O=Math.pow(2,8*u)-1;G(this,i,r,u,O,0)}let m=u-1,g=1;for(this[r+m]=i&255;--m>=0&&(g*=256);)this[r+m]=i/g&255;return r+u},"writeUIntBE"),s.prototype.writeUint8=s.prototype.writeUInt8=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,1,255,0),this[r]=i&255,r+1},"writeUInt8"),s.prototype.writeUint16LE=s.prototype.writeUInt16LE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,2,65535,0),this[r]=i&255,this[r+1]=i>>>8,r+2},"writeUInt16LE"),s.prototype.writeUint16BE=s.prototype.writeUInt16BE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,2,65535,0),this[r]=i>>>8,this[r+1]=i&255,r+2},"writeUInt16BE"),s.prototype.writeUint32LE=s.prototype.writeUInt32LE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,4,4294967295,0),this[r+3]=i>>>24,this[r+2]=i>>>16,this[r+1]=i>>>8,this[r]=i&255,r+4},"writeUInt32LE"),s.prototype.writeUint32BE=s.prototype.writeUInt32BE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,4,4294967295,0),this[r]=i>>>24,this[r+1]=i>>>16,this[r+2]=i>>>8,this[r+3]=i&255,r+4},"writeUInt32BE");function xe(c,i,r,u,d){Be(i,u,d,c,r,7);let m=Number(i&BigInt(4294967295));c[r++]=m,m=m>>8,c[r++]=m,m=m>>8,c[r++]=m,m=m>>8,c[r++]=m;let g=Number(i>>BigInt(32)&BigInt(4294967295));return c[r++]=g,g=g>>8,c[r++]=g,g=g>>8,c[r++]=g,g=g>>8,c[r++]=g,r}h(xe,"wrtBigUInt64LE");function Ne(c,i,r,u,d){Be(i,u,d,c,r,7);let m=Number(i&BigInt(4294967295));c[r+7]=m,m=m>>8,c[r+6]=m,m=m>>8,c[r+5]=m,m=m>>8,c[r+4]=m;let g=Number(i>>BigInt(32)&BigInt(4294967295));return c[r+3]=g,g=g>>8,c[r+2]=g,g=g>>8,c[r+1]=g,g=g>>8,c[r]=g,r+8}h(Ne,"wrtBigUInt64BE"),s.prototype.writeBigUInt64LE=lt(h(function(i,r=0){return xe(this,i,r,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64LE")),s.prototype.writeBigUInt64BE=lt(h(function(i,r=0){return Ne(this,i,r,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64BE")),s.prototype.writeIntLE=h(function(i,r,u,d){if(i=+i,r=r>>>0,!d){let M=Math.pow(2,8*u-1);G(this,i,r,u,M-1,-M)}let m=0,g=1,O=0;for(this[r]=i&255;++m<u&&(g*=256);)i<0&&O===0&&this[r+m-1]!==0&&(O=1),this[r+m]=(i/g>>0)-O&255;return r+u},"writeIntLE"),s.prototype.writeIntBE=h(function(i,r,u,d){if(i=+i,r=r>>>0,!d){let M=Math.pow(2,8*u-1);G(this,i,r,u,M-1,-M)}let m=u-1,g=1,O=0;for(this[r+m]=i&255;--m>=0&&(g*=256);)i<0&&O===0&&this[r+m+1]!==0&&(O=1),this[r+m]=(i/g>>0)-O&255;return r+u},"writeIntBE"),s.prototype.writeInt8=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,1,127,-128),i<0&&(i=255+i+1),this[r]=i&255,r+1},"writeInt8"),s.prototype.writeInt16LE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,2,32767,-32768),this[r]=i&255,this[r+1]=i>>>8,r+2},"writeInt16LE"),s.prototype.writeInt16BE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,2,32767,-32768),this[r]=i>>>8,this[r+1]=i&255,r+2},"writeInt16BE"),s.prototype.writeInt32LE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,4,2147483647,-2147483648),this[r]=i&255,this[r+1]=i>>>8,this[r+2]=i>>>16,this[r+3]=i>>>24,r+4},"writeInt32LE"),s.prototype.writeInt32BE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[r]=i>>>24,this[r+1]=i>>>16,this[r+2]=i>>>8,this[r+3]=i&255,r+4},"writeInt32BE"),s.prototype.writeBigInt64LE=lt(h(function(i,r=0){return xe(this,i,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64LE")),s.prototype.writeBigInt64BE=lt(h(function(i,r=0){return Ne(this,i,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64BE"));function _e(c,i,r,u,d,m){if(r+u>c.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}h(_e,"checkIEEE754");function be(c,i,r,u,d){return i=+i,r=r>>>0,d||_e(c,i,r,4),t.write(c,i,r,u,23,4),r+4}h(be,"writeFloat"),s.prototype.writeFloatLE=h(function(i,r,u){return be(this,i,r,!0,u)},"writeFloatLE"),s.prototype.writeFloatBE=h(function(i,r,u){return be(this,i,r,!1,u)},"writeFloatBE");function Oe(c,i,r,u,d){return i=+i,r=r>>>0,d||_e(c,i,r,8),t.write(c,i,r,u,52,8),r+8}h(Oe,"writeDouble"),s.prototype.writeDoubleLE=h(function(i,r,u){return Oe(this,i,r,!0,u)},"writeDoubleLE"),s.prototype.writeDoubleBE=h(function(i,r,u){return Oe(this,i,r,!1,u)},"writeDoubleBE"),s.prototype.copy=h(function(i,r,u,d){if(!s.isBuffer(i))throw new TypeError("argument should be a Buffer");if(u||(u=0),!d&&d!==0&&(d=this.length),r>=i.length&&(r=i.length),r||(r=0),d>0&&d<u&&(d=u),d===u||i.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),i.length-r<d-u&&(d=i.length-r+u);let m=d-u;return this===i&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,u,d):Uint8Array.prototype.set.call(i,this.subarray(u,d),r),m},"copy"),s.prototype.fill=h(function(i,r,u,d){if(typeof i=="string"){if(typeof r=="string"?(d=r,r=0,u=this.length):typeof u=="string"&&(d=u,u=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!s.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(i.length===1){let g=i.charCodeAt(0);(d==="utf8"&&g<128||d==="latin1")&&(i=g)}}else typeof i=="number"?i=i&255:typeof i=="boolean"&&(i=Number(i));if(r<0||this.length<r||this.length<u)throw new RangeError("Out of range index");if(u<=r)return this;r=r>>>0,u=u===void 0?this.length:u>>>0,i||(i=0);let m;if(typeof i=="number")for(m=r;m<u;++m)this[m]=i;else{let g=s.isBuffer(i)?i:s.from(i,d),O=g.length;if(O===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(m=0;m<u-r;++m)this[m+r]=g[m%O]}return this},"fill");let Bt={};function he(c,i,r){Bt[c]=h(class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:i.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}},"NodeError")}h(he,"E"),he("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),he("ERR_INVALID_ARG_TYPE",function(c,i){return`The "${c}" argument must be of type number. Received type ${typeof i}`},TypeError),he("ERR_OUT_OF_RANGE",function(c,i,r){let u=`The value of "${c}" is out of range.`,d=r;return Number.isInteger(r)&&Math.abs(r)>C(2,32)?d=Te(String(r)):typeof r=="bigint"&&(d=String(r),(r>C(BigInt(2),BigInt(32))||r<-C(BigInt(2),BigInt(32)))&&(d=Te(d)),d+="n"),u+=` It must be ${i}. Received ${d}`,u},RangeError);function Te(c){let i="",r=c.length,u=c[0]==="-"?1:0;for(;r>=u+4;r-=3)i=`_${c.slice(r-3,r)}${i}`;return`${c.slice(0,r)}${i}`}h(Te,"addNumericalSeparator");function ri(c,i,r){Ft(i,"offset"),(c[i]===void 0||c[i+r]===void 0)&&Ut(i,c.length-(r+1))}h(ri,"checkBounds");function Be(c,i,r,u,d,m){if(c>r||c<i){let g=typeof i=="bigint"?"n":"",O;throw m>3?i===0||i===BigInt(0)?O=`>= 0${g} and < 2${g} ** ${(m+1)*8}${g}`:O=`>= -(2${g} ** ${(m+1)*8-1}${g}) and < 2 ** ${(m+1)*8-1}${g}`:O=`>= ${i}${g} and <= ${r}${g}`,new Bt.ERR_OUT_OF_RANGE("value",O,c)}ri(u,d,m)}h(Be,"checkIntBI");function Ft(c,i){if(typeof c!="number")throw new Bt.ERR_INVALID_ARG_TYPE(i,"number",c)}h(Ft,"validateNumber");function Ut(c,i,r){throw Math.floor(c)!==c?(Ft(c,r),new Bt.ERR_OUT_OF_RANGE(r||"offset","an integer",c)):i<0?new Bt.ERR_BUFFER_OUT_OF_BOUNDS:new Bt.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${i}`,c)}h(Ut,"boundsError");let ni=/[^+/0-9A-Za-z-_]/g;function oi(c){if(c=c.split("=")[0],c=c.trim().replace(ni,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}h(oi,"base64clean");function de(c,i){i=i||1/0;let r,u=c.length,d=null,m=[];for(let g=0;g<u;++g){if(r=c.charCodeAt(g),r>55295&&r<57344){if(!d){if(r>56319){(i-=3)>-1&&m.push(239,191,189);continue}else if(g+1===u){(i-=3)>-1&&m.push(239,191,189);continue}d=r;continue}if(r<56320){(i-=3)>-1&&m.push(239,191,189),d=r;continue}r=(d-55296<<10|r-56320)+65536}else d&&(i-=3)>-1&&m.push(239,191,189);if(d=null,r<128){if((i-=1)<0)break;m.push(r)}else if(r<2048){if((i-=2)<0)break;m.push(r>>6|192,r&63|128)}else if(r<65536){if((i-=3)<0)break;m.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((i-=4)<0)break;m.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return m}h(de,"utf8ToBytes");function si(c){let i=[];for(let r=0;r<c.length;++r)i.push(c.charCodeAt(r)&255);return i}h(si,"asciiToBytes");function ci(c,i){let r,u,d,m=[];for(let g=0;g<c.length&&!((i-=2)<0);++g)r=c.charCodeAt(g),u=r>>8,d=r%256,m.push(d),m.push(u);return m}h(ci,"utf16leToBytes");function Fe(c){return l.toByteArray(oi(c))}h(Fe,"base64ToBytes");function Gt(c,i,r,u){let d;for(d=0;d<u&&!(d+r>=i.length||d>=c.length);++d)i[d+r]=c[d];return d}h(Gt,"blitBuffer");function st(c,i){return c instanceof i||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===i.name}h(st,"isInstance");function fe(c){return c!==c}h(fe,"numberIsNaN");let ai=function(){let c="0123456789abcdef",i=new Array(256);for(let r=0;r<16;++r){let u=r*16;for(let d=0;d<16;++d)i[u+d]=c[r]+c[d]}return i}();function lt(c){return typeof BigInt=="undefined"?ui:c}h(lt,"defineBigIntMethod");function ui(){throw new Error("BigInt not supported")}return h(ui,"BufferBigIntNotDefined"),mt}h(Si,"dew");var yt=Si();yt.Buffer;yt.SlowBuffer;yt.INSPECT_MAX_BYTES;yt.kMaxLength;var _=yt.Buffer,Ai=yt.INSPECT_MAX_BYTES,vi=yt.kMaxLength;var Ii="/",wt="/";function vt(l,t){if(typeof l!="string")throw new TypeError(`"${t}" is not a string`)}h(vt,"validateString");function Le(l,t){let e="",n=0,o=-1,a=0,s="\0";for(let f=0;f<=l.length;++f){if(f<l.length)s=l[f];else{if(s=="/")break;s="/"}if(s=="/"){if(!(o===f-1||a===1))if(a===2){if(e.length<2||n!==2||e.at(-1)!=="."||e.at(-2)!=="."){if(e.length>2){let w=e.lastIndexOf("/");w===-1?(e="",n=0):(e=e.slice(0,w),n=e.length-1-e.lastIndexOf("/")),o=f,a=0;continue}else if(e.length!==0){e="",n=0,o=f,a=0;continue}}t&&(e+=e.length>0?"/..":"..",n=2)}else e.length>0?e+="/"+l.slice(o+1,f):e=l.slice(o+1,f),n=f-o-1;o=f,a=0}else s==="."&&a!==-1?++a:a=-1}return e}h(Le,"normalizeString");function gt(...l){let t="",e=!1;for(let n=l.length-1;n>=-1&&!e;n--){let o=n>=0?l[n]:Ii;vt(o,`paths[${n}]`),o.length!==0&&(t=`${o}/${t}`,e=o[0]==="/")}return t=Le(t,!e),e?`/${t}`:t.length>0?t:"."}h(gt,"resolve");function xi(l){if(vt(l,"path"),l.length===0)return".";let t=l[0]==="/",e=l.at(-1)==="/";return l=Le(l,!t),l.length===0?t?"/":e?"./":".":(e&&(l+="/"),t?`/${l}`:l)}h(xi,"normalize");function it(...l){if(l.length===0)return".";let t;for(let e=0;e<l.length;++e){let n=l[e];vt(n,"path"),n.length>0&&(t===void 0?t=n:t+=`/${n}`)}return t===void 0?".":xi(t)}h(it,"join");function F(l){if(vt(l,"path"),l.length===0)return".";let t=l[0]==="/",e=-1,n=!0;for(let o=l.length-1;o>=1;--o)if(l[o]==="/"){if(!n){e=o;break}}else n=!1;return e===-1?t?"/":".":t&&e===1?"//":l.slice(0,e)}h(F,"dirname");function W(l,t){t!==void 0&&vt(t,"ext"),vt(l,"path");let e=0,n=-1,o=!0;if(t!==void 0&&t.length>0&&t.length<=l.length){if(t===l)return"";let a=t.length-1,s=-1;for(let f=l.length-1;f>=0;--f)if(l[f]==="/"){if(!o){e=f+1;break}}else s===-1&&(o=!1,s=f+1),a>=0&&(l[f]===t[a]?--a===-1&&(n=f):(a=-1,n=s));return e===n?n=s:n===-1&&(n=l.length),l.slice(e,n)}for(let a=l.length-1;a>=0;--a)if(l[a]==="/"){if(!o){e=a+1;break}}else n===-1&&(o=!1,n=a+1);return n===-1?"":l.slice(e,n)}h(W,"basename");var E;(function(l){l[l.EPERM=1]="EPERM",l[l.ENOENT=2]="ENOENT",l[l.EIO=5]="EIO",l[l.EBADF=9]="EBADF",l[l.EACCES=13]="EACCES",l[l.EBUSY=16]="EBUSY",l[l.EEXIST=17]="EEXIST",l[l.ENOTDIR=20]="ENOTDIR",l[l.EISDIR=21]="EISDIR",l[l.EINVAL=22]="EINVAL",l[l.EFBIG=27]="EFBIG",l[l.ENOSPC=28]="ENOSPC",l[l.EROFS=30]="EROFS",l[l.ENOTEMPTY=39]="ENOTEMPTY",l[l.ENOTSUP=95]="ENOTSUP"})(E=E||(E={}));var K={};K[E.EPERM]="Operation not permitted.";K[E.ENOENT]="No such file or directory.";K[E.EIO]="Input/output error.";K[E.EBADF]="Bad file descriptor.";K[E.EACCES]="Permission denied.";K[E.EBUSY]="Resource busy or locked.";K[E.EEXIST]="File exists.";K[E.ENOTDIR]="File is not a directory.";K[E.EISDIR]="File is a directory.";K[E.EINVAL]="Invalid argument.";K[E.EFBIG]="File is too big.";K[E.ENOSPC]="No space left on disk.";K[E.EROFS]="Cannot modify a read-only file system.";K[E.ENOTEMPTY]="Directory is not empty.";K[E.ENOTSUP]="Operation is not supported.";var p=class extends Error{static fromJSON(t){let e=new p(t.errno,t.message,t.path);return e.code=t.code,e.stack=t.stack,e}static fromBuffer(t,e=0){return p.fromJSON(JSON.parse(t.toString("utf8",e+4,e+4+t.readUInt32LE(e))))}static FileError(t,e){return new p(t,K[t],e)}static EACCES(t){return this.FileError(E.EACCES,t)}static ENOENT(t){return this.FileError(E.ENOENT,t)}static EEXIST(t){return this.FileError(E.EEXIST,t)}static EISDIR(t){return this.FileError(E.EISDIR,t)}static ENOTDIR(t){return this.FileError(E.ENOTDIR,t)}static EPERM(t){return this.FileError(E.EPERM,t)}static ENOTEMPTY(t){return this.FileError(E.ENOTEMPTY,t)}constructor(t,e=K[t],n){super(e),this.syscall="",this.errno=t,this.code=E[t],this.path=n,this.message=`Error: ${this.code}: ${e}${this.path?`, '${this.path}'`:""}`}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message}}writeToBuffer(t=_.alloc(this.bufferSize()),e=0){let n=t.write(JSON.stringify(this.toJSON()),e+4);return t.writeUInt32LE(n,e),t}bufferSize(){return 4+_.byteLength(JSON.stringify(this.toJSON()))}};h(p,"ApiError");var nt=class{constructor(t,e,n,o,a,s){this.uid=t,this.gid=e,this.suid=n,this.sgid=o,this.euid=a,this.egid=s}};h(nt,"Cred");nt.Root=new nt(0,0,0,0,0,0);var R;(function(l){l[l.FILE=32768]="FILE",l[l.DIRECTORY=16384]="DIRECTORY",l[l.SYMLINK=40960]="SYMLINK"})(R=R||(R={}));var j=class{static fromBuffer(t){let e=t.readUInt32LE(0),n=t.readUInt32LE(4),o=t.readDoubleLE(8),a=t.readDoubleLE(16),s=t.readDoubleLE(24),f=t.readUInt32LE(32),w=t.readUInt32LE(36);return new j(n&61440,e,n&-61441,o,a,s,f,w)}static clone(t){return new j(t.mode&61440,t.size,t.mode&-61441,t.atimeMs,t.mtimeMs,t.ctimeMs,t.uid,t.gid,t.birthtimeMs)}get atime(){return new Date(this.atimeMs)}get mtime(){return new Date(this.mtimeMs)}get ctime(){return new Date(this.ctimeMs)}get birthtime(){return new Date(this.birthtimeMs)}constructor(t,e,n,o,a,s,f,w,S){this.dev=0,this.ino=0,this.rdev=0,this.nlink=1,this.blksize=4096,this.uid=0,this.gid=0,this.fileData=null,this.size=e;let y=0;if(typeof o!="number"&&(y=Date.now(),o=y),typeof a!="number"&&(y||(y=Date.now()),a=y),typeof s!="number"&&(y||(y=Date.now()),s=y),typeof S!="number"&&(y||(y=Date.now()),S=y),typeof f!="number"&&(f=0),typeof w!="number"&&(w=0),this.atimeMs=o,this.ctimeMs=s,this.mtimeMs=a,this.birthtimeMs=S,n)this.mode=n;else switch(t){case R.FILE:this.mode=420;break;case R.DIRECTORY:default:this.mode=511}this.blocks=Math.ceil(e/512),this.mode&61440||(this.mode|=t)}toBuffer(){let t=_.alloc(32);return t.writeUInt32LE(this.size,0),t.writeUInt32LE(this.mode,4),t.writeDoubleLE(this.atime.getTime(),8),t.writeDoubleLE(this.mtime.getTime(),16),t.writeDoubleLE(this.ctime.getTime(),24),t.writeUInt32LE(this.uid,32),t.writeUInt32LE(this.gid,36),t}isFile(){return(this.mode&61440)===32768}isDirectory(){return(this.mode&61440)===16384}isSymbolicLink(){return(this.mode&61440)===40960}hasAccess(t,e){if(e.euid===0||e.egid===0)return!0;let n=this.mode&-61441,o=15,a=15,s=15;if(e.euid==this.uid){let S=(3840&n)>>8;o=(t^S)&t}if(e.egid==this.gid){let S=(240&n)>>4;a=(t^S)&t}let f=15&n;return s=(t^f)&t,!(o&a&s)}getCred(t=this.uid,e=this.gid){return new nt(t,e,this.uid,this.gid,t,e)}chmod(t){this.mode=this.mode&61440|t}chown(t,e){!isNaN(+t)&&0<=+t&&+t<Math.pow(2,32)&&(this.uid=t),!isNaN(+e)&&0<=+e&&+e<Math.pow(2,32)&&(this.gid=e)}isSocket(){return!1}isBlockDevice(){return!1}isCharacterDevice(){return!1}isFIFO(){return!1}};h(j,"Stats");var T=function(l,t,e,n){function o(a){return a instanceof e?a:new e(function(s){s(a)})}return h(o,"adopt"),new(e||(e=Promise))(function(a,s){function f(y){try{S(n.next(y))}catch(I){s(I)}}h(f,"fulfilled");function w(y){try{S(n.throw(y))}catch(I){s(I)}}h(w,"rejected");function S(y){y.done?a(y.value):o(y.value).then(f,w)}h(S,"step"),S((n=n.apply(l,t||[])).next())})},ze,Zt=class{constructor(t){}};h(Zt,"FileSystem");var Q=class extends Zt{constructor(t){super(),this._ready=Promise.resolve(this)}get metadata(){return{name:this.constructor.name,readonly:!1,synchronous:!1,supportsProperties:!1,supportsLinks:!1,totalSpace:0,freeSpace:0}}whenReady(){return this._ready}openFile(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}createFile(t,e,n,o){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}open(t,e,n,o){return T(this,void 0,void 0,function*(){try{let a=yield this.stat(t,o);switch(e.pathExistsAction()){case k.THROW_EXCEPTION:throw p.EEXIST(t);case k.TRUNCATE_FILE:let s=yield this.openFile(t,e,o);if(!s)throw new Error("BFS has reached an impossible code path; please file a bug.");return yield s.truncate(0),yield s.sync(),s;case k.NOP:return this.openFile(t,e,o);default:throw new p(E.EINVAL,"Invalid FileFlag object.")}}catch(a){switch(e.pathNotExistsAction()){case k.CREATE_FILE:let s=yield this.stat(F(t),o);if(s&&!s.isDirectory())throw p.ENOTDIR(F(t));return this.createFile(t,e,n,o);case k.THROW_EXCEPTION:throw p.ENOENT(t);default:throw new p(E.EINVAL,"Invalid FileFlag object.")}}})}access(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}accessSync(t,e,n){throw new p(E.ENOTSUP)}rename(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}renameSync(t,e,n){throw new p(E.ENOTSUP)}stat(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}statSync(t,e){throw new p(E.ENOTSUP)}openFileSync(t,e,n){throw new p(E.ENOTSUP)}createFileSync(t,e,n,o){throw new p(E.ENOTSUP)}openSync(t,e,n,o){let a;try{a=this.statSync(t,o)}catch(s){switch(e.pathNotExistsAction()){case k.CREATE_FILE:if(!this.statSync(F(t),o).isDirectory())throw p.ENOTDIR(F(t));return this.createFileSync(t,e,n,o);case k.THROW_EXCEPTION:throw p.ENOENT(t);default:throw new p(E.EINVAL,"Invalid FileFlag object.")}}if(!a.hasAccess(n,o))throw p.EACCES(t);switch(e.pathExistsAction()){case k.THROW_EXCEPTION:throw p.EEXIST(t);case k.TRUNCATE_FILE:return this.unlinkSync(t,o),this.createFileSync(t,e,a.mode,o);case k.NOP:return this.openFileSync(t,e,o);default:throw new p(E.EINVAL,"Invalid FileFlag object.")}}unlink(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}unlinkSync(t,e){throw new p(E.ENOTSUP)}rmdir(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}rmdirSync(t,e){throw new p(E.ENOTSUP)}mkdir(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}mkdirSync(t,e,n){throw new p(E.ENOTSUP)}readdir(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}readdirSync(t,e){throw new p(E.ENOTSUP)}exists(t,e){return T(this,void 0,void 0,function*(){try{return yield this.stat(t,e),!0}catch(n){return!1}})}existsSync(t,e){try{return this.statSync(t,e),!0}catch(n){return!1}}realpath(t,e){return T(this,void 0,void 0,function*(){if(this.metadata.supportsLinks){let n=t.split(wt);for(let o=0;o<n.length;o++){let a=n.slice(0,o+1);n[o]=it(...a)}return n.join(wt)}else{if(!(yield this.exists(t,e)))throw p.ENOENT(t);return t}})}realpathSync(t,e){if(this.metadata.supportsLinks){let n=t.split(wt);for(let o=0;o<n.length;o++){let a=n.slice(0,o+1);n[o]=it(...a)}return n.join(wt)}else{if(this.existsSync(t,e))return t;throw p.ENOENT(t)}}truncate(t,e,n){return T(this,void 0,void 0,function*(){let o=yield this.open(t,Y.getFileFlag("r+"),420,n);try{yield o.truncate(e)}finally{yield o.close()}})}truncateSync(t,e,n){let o=this.openSync(t,Y.getFileFlag("r+"),420,n);try{o.truncateSync(e)}finally{o.closeSync()}}readFile(t,e,n,o){return T(this,void 0,void 0,function*(){let a=yield this.open(t,n,420,o);try{let s=yield a.stat(),f=_.alloc(s.size);return yield a.read(f,0,s.size,0),yield a.close(),e===null?f:f.toString(e)}finally{yield a.close()}})}readFileSync(t,e,n,o){let a=this.openSync(t,n,420,o);try{let s=a.statSync(),f=_.alloc(s.size);return a.readSync(f,0,s.size,0),a.closeSync(),e===null?f:f.toString(e)}finally{a.closeSync()}}writeFile(t,e,n,o,a,s){return T(this,void 0,void 0,function*(){let f=yield this.open(t,o,a,s);try{typeof e=="string"&&(e=_.from(e,n)),yield f.write(e,0,e.length,0)}finally{yield f.close()}})}writeFileSync(t,e,n,o,a,s){let f=this.openSync(t,o,a,s);try{typeof e=="string"&&(e=_.from(e,n)),f.writeSync(e,0,e.length,0)}finally{f.closeSync()}}appendFile(t,e,n,o,a,s){return T(this,void 0,void 0,function*(){let f=yield this.open(t,o,a,s);try{typeof e=="string"&&(e=_.from(e,n)),yield f.write(e,0,e.length,null)}finally{yield f.close()}})}appendFileSync(t,e,n,o,a,s){let f=this.openSync(t,o,a,s);try{typeof e=="string"&&(e=_.from(e,n)),f.writeSync(e,0,e.length,null)}finally{f.closeSync()}}chmod(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}chmodSync(t,e,n){throw new p(E.ENOTSUP)}chown(t,e,n,o){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}chownSync(t,e,n,o){throw new p(E.ENOTSUP)}utimes(t,e,n,o){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}utimesSync(t,e,n,o){throw new p(E.ENOTSUP)}link(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}linkSync(t,e,n){throw new p(E.ENOTSUP)}symlink(t,e,n,o){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}symlinkSync(t,e,n,o){throw new p(E.ENOTSUP)}readlink(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}readlinkSync(t,e){throw new p(E.ENOTSUP)}};h(Q,"BaseFileSystem");ze=Q;Q.Name=ze.name;var Mt=class extends Q{get metadata(){return Object.assign(Object.assign({},super.metadata),{synchronous:!0})}access(t,e,n){return T(this,void 0,void 0,function*(){return this.accessSync(t,e,n)})}rename(t,e,n){return T(this,void 0,void 0,function*(){return this.renameSync(t,e,n)})}stat(t,e){return T(this,void 0,void 0,function*(){return this.statSync(t,e)})}open(t,e,n,o){return T(this,void 0,void 0,function*(){return this.openSync(t,e,n,o)})}unlink(t,e){return T(this,void 0,void 0,function*(){return this.unlinkSync(t,e)})}rmdir(t,e){return T(this,void 0,void 0,function*(){return this.rmdirSync(t,e)})}mkdir(t,e,n){return T(this,void 0,void 0,function*(){return this.mkdirSync(t,e,n)})}readdir(t,e){return T(this,void 0,void 0,function*(){return this.readdirSync(t,e)})}chmod(t,e,n){return T(this,void 0,void 0,function*(){return this.chmodSync(t,e,n)})}chown(t,e,n,o){return T(this,void 0,void 0,function*(){return this.chownSync(t,e,n,o)})}utimes(t,e,n,o){return T(this,void 0,void 0,function*(){return this.utimesSync(t,e,n,o)})}link(t,e,n){return T(this,void 0,void 0,function*(){return this.linkSync(t,e,n)})}symlink(t,e,n,o){return T(this,void 0,void 0,function*(){return this.symlinkSync(t,e,n,o)})}readlink(t,e){return T(this,void 0,void 0,function*(){return this.readlinkSync(t,e)})}};h(Mt,"SynchronousFileSystem");var Z=class{static fromBuffer(t){if(t===void 0)throw new Error("NO");return new Z(t.toString("ascii",38),t.readUInt32LE(0),t.readUInt16LE(4),t.readDoubleLE(6),t.readDoubleLE(14),t.readDoubleLE(22),t.readUInt32LE(30),t.readUInt32LE(34))}constructor(t,e,n,o,a,s,f,w){this.id=t,this.size=e,this.mode=n,this.atime=o,this.mtime=a,this.ctime=s,this.uid=f,this.gid=w}toStats(){return new j((this.mode&61440)===R.DIRECTORY?R.DIRECTORY:R.FILE,this.size,this.mode,this.atime,this.mtime,this.ctime,this.uid,this.gid)}getSize(){return 38+this.id.length}toBuffer(t=_.alloc(this.getSize())){return t.writeUInt32LE(this.size,0),t.writeUInt16LE(this.mode,4),t.writeDoubleLE(this.atime,6),t.writeDoubleLE(this.mtime,14),t.writeDoubleLE(this.ctime,22),t.writeUInt32LE(this.uid,30),t.writeUInt32LE(this.gid,34),t.write(this.id,38,this.id.length,"ascii"),t}update(t){let e=!1;this.size!==t.size&&(this.size=t.size,e=!0),this.mode!==t.mode&&(this.mode=t.mode,e=!0);let n=t.atime.getTime();this.atime!==n&&(this.atime=n,e=!0);let o=t.mtime.getTime();this.mtime!==o&&(this.mtime=o,e=!0);let a=t.ctime.getTime();return this.ctime!==a&&(this.ctime=a,e=!0),this.uid!==t.uid&&(this.uid=t.uid,e=!0),this.uid!==t.uid&&(this.uid=t.uid,e=!0),e}isFile(){return(this.mode&61440)===R.FILE}isDirectory(){return(this.mode&61440)===R.DIRECTORY}};h(Z,"Inode");var Ni=function(l,t,e,n){function o(a){return a instanceof e?a:new e(function(s){s(a)})}return h(o,"adopt"),new(e||(e=Promise))(function(a,s){function f(y){try{S(n.next(y))}catch(I){s(I)}}h(f,"fulfilled");function w(y){try{S(n.throw(y))}catch(I){s(I)}}h(w,"rejected");function S(y){y.done?a(y.value):o(y.value).then(f,w)}h(S,"step"),S((n=n.apply(l,t||[])).next())})};function te(l,t,e,n,o){return Math.min(l+1,t+1,e+1,n===o?t:t+1)}h(te,"_min");function _i(l,t){if(l===t)return 0;l.length>t.length&&([l,t]=[t,l]);let e=l.length,n=t.length;for(;e>0&&l.charCodeAt(e-1)===t.charCodeAt(n-1);)e--,n--;let o=0;for(;o<e&&l.charCodeAt(o)===t.charCodeAt(o);)o++;if(e-=o,n-=o,e===0||n===1)return n;let a=new Array(e<<1);for(let b=0;b<e;)a[e+b]=l.charCodeAt(o+b),a[b]=++b;let s,f,w,S,y;for(s=0;s+3<n;){let b=t.charCodeAt(o+(f=s)),x=t.charCodeAt(o+(w=s+1)),N=t.charCodeAt(o+(S=s+2)),B=t.charCodeAt(o+(y=s+3)),P=s+=4;for(let q=0;q<e;){let D=a[e+q],X=a[q];f=te(X,f,w,b,D),w=te(f,w,S,x,D),S=te(w,S,y,N,D),P=te(S,y,P,B,D),a[q++]=P,y=S,S=w,w=f,f=X}}let I=0;for(;s<n;){let b=t.charCodeAt(o+(f=s));I=++s;for(let x=0;x<e;x++){let N=a[x];a[x]=I=N<f||I<f?N>I?I+1:N+1:b===a[e+x]?f:f+1,f=N}}return I}h(_i,"levenshtein");function He(l,t){return Ni(this,void 0,void 0,function*(){let e=l.Options,n=l.Name,o=0,a=!1,s=!1;for(let f in e)if(Object.prototype.hasOwnProperty.call(e,f)){let w=e[f],S=t&&t[f];if(S==null){if(!w.optional){let y=Object.keys(t).filter(I=>!(I in e)).map(I=>({str:I,distance:_i(f,I)})).filter(I=>I.distance<5).sort((I,b)=>I.distance-b.distance);if(a)return;throw a=!0,new p(E.EINVAL,`[${n}] Required option '${f}' not provided.${y.length>0?` You provided unrecognized option '${y[0].str}'; perhaps you meant to type '${f}'.`:""}
|
|
2
|
+
Option description: ${w.description}`)}}else{let y=!1;if(Array.isArray(w.type)?y=w.type.indexOf(typeof S)!==-1:y=typeof S===w.type,y){if(w.validator){o++;try{yield w.validator(S)}catch(I){if(!a){if(I)throw a=!0,I;if(o--,o===0&&s)return}}}}else{if(a)return;throw a=!0,new p(E.EINVAL,`[${n}] Value provided for option ${f} is not the proper type. Expected ${Array.isArray(w.type)?`one of {${w.type.join(", ")}}`:w.type}, but received ${typeof S}
|
|
3
|
+
Option description: ${w.description}`)}}}s=!0})}h(He,"checkOptions");var Fr=typeof globalThis.setImmediate=="function"?globalThis.setImmediate:l=>setTimeout(l,0),ot="/";function ee(){return _.from("{}")}h(ee,"getEmptyDirNode");function Rt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(l){let t=Math.random()*16|0;return(l==="x"?t:t&3|8).toString(16)})}h(Rt,"randomUUID");var Et=class{constructor(t){this.store=t,this.originalData={},this.modifiedKeys=[]}get(t){let e=this.store.get(t);return this.stashOldValue(t,e),e}put(t,e,n){return this.markModified(t),this.store.put(t,e,n)}del(t){this.markModified(t),this.store.del(t)}commit(){}abort(){for(let t of this.modifiedKeys){let e=this.originalData[t];e?this.store.put(t,e,!0):this.store.del(t)}}_has(t){return Object.prototype.hasOwnProperty.call(this.originalData,t)}stashOldValue(t,e){this._has(t)||(this.originalData[t]=e)}markModified(t){this.modifiedKeys.indexOf(t)===-1&&(this.modifiedKeys.push(t),this._has(t)||(this.originalData[t]=this.store.get(t)))}};h(Et,"SimpleSyncRWTransaction");var $t=class extends at{constructor(t,e,n,o,a){super(t,e,n,o,a)}syncSync(){this.isDirty()&&(this._fs._syncSync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())}closeSync(){this.syncSync()}};h($t,"SyncKeyValueFile");var St=class extends Mt{static isAvailable(){return!0}constructor(t){super(),this.store=t.store,this.makeRootDirectory()}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!0}empty(){this.store.clear(),this.makeRootDirectory()}accessSync(t,e,n){let o=this.store.beginTransaction("readonly");if(!this.findINode(o,t).toStats().hasAccess(e,n))throw p.EACCES(t)}renameSync(t,e,n){let o=this.store.beginTransaction("readwrite"),a=F(t),s=W(t),f=F(e),w=W(e),S=this.findINode(o,a),y=this.getDirListing(o,a,S);if(!S.toStats().hasAccess(2,n))throw p.EACCES(t);if(!y[s])throw p.ENOENT(t);let I=y[s];if(delete y[s],(f+"/").indexOf(t+"/")===0)throw new p(E.EBUSY,a);let b,x;if(f===a?(b=S,x=y):(b=this.findINode(o,f),x=this.getDirListing(o,f,b)),x[w]){let N=this.getINode(o,e,x[w]);if(N.isFile())try{o.del(N.id),o.del(x[w])}catch(B){throw o.abort(),B}else throw p.EPERM(e)}x[w]=I;try{o.put(S.id,_.from(JSON.stringify(y)),!0),o.put(b.id,_.from(JSON.stringify(x)),!0)}catch(N){throw o.abort(),N}o.commit()}statSync(t,e){let n=this.findINode(this.store.beginTransaction("readonly"),t).toStats();if(!n.hasAccess(4,e))throw p.EACCES(t);return n}createFileSync(t,e,n,o){let a=this.store.beginTransaction("readwrite"),s=_.alloc(0),f=this.commitNewFile(a,t,R.FILE,n,o,s);return new $t(this,t,e,f.toStats(),s)}openFileSync(t,e,n){let o=this.store.beginTransaction("readonly"),a=this.findINode(o,t),s=o.get(a.id);if(!a.toStats().hasAccess(e.getMode(),n))throw p.EACCES(t);if(s===void 0)throw p.ENOENT(t);return new $t(this,t,e,a.toStats(),s)}unlinkSync(t,e){this.removeEntry(t,!1,e)}rmdirSync(t,e){if(this.readdirSync(t,e).length>0)throw p.ENOTEMPTY(t);this.removeEntry(t,!0,e)}mkdirSync(t,e,n){let o=this.store.beginTransaction("readwrite"),a=_.from("{}");this.commitNewFile(o,t,R.DIRECTORY,e,n,a)}readdirSync(t,e){let n=this.store.beginTransaction("readonly"),o=this.findINode(n,t);if(!o.toStats().hasAccess(4,e))throw p.EACCES(t);return Object.keys(this.getDirListing(n,t,o))}chmodSync(t,e,n){this.openFileSync(t,Y.getFileFlag("r+"),n).chmodSync(e)}chownSync(t,e,n,o){this.openFileSync(t,Y.getFileFlag("r+"),o).chownSync(e,n)}_syncSync(t,e,n){let o=this.store.beginTransaction("readwrite"),a=this._findINode(o,F(t),W(t)),s=this.getINode(o,t,a),f=s.update(n);try{o.put(s.id,e,!0),f&&o.put(a,s.toBuffer(),!0)}catch(w){throw o.abort(),w}o.commit()}makeRootDirectory(){let t=this.store.beginTransaction("readwrite");if(t.get(ot)===void 0){let e=new Date().getTime(),n=new Z(Rt(),4096,511|R.DIRECTORY,e,e,e,0,0);t.put(n.id,ee(),!1),t.put(ot,n.toBuffer(),!1),t.commit()}}_findINode(t,e,n,o=new Set){let a=it(e,n);if(o.has(a))throw new p(E.EIO,"Infinite loop detected while finding inode",a);o.add(a);let s=h(f=>{let w=this.getDirListing(t,e,f);if(w[n])return w[n];throw p.ENOENT(gt(e,n))},"readDirectory");return e==="/"?n===""?ot:s(this.getINode(t,e,ot)):s(this.getINode(t,e+wt+n,this._findINode(t,F(e),W(e),o)))}findINode(t,e){return this.getINode(t,e,this._findINode(t,F(e),W(e)))}getINode(t,e,n){let o=t.get(n);if(o===void 0)throw p.ENOENT(e);return Z.fromBuffer(o)}getDirListing(t,e,n){if(!n.isDirectory())throw p.ENOTDIR(e);let o=t.get(n.id);if(o===void 0)throw p.ENOENT(e);return JSON.parse(o.toString())}addNewNode(t,e){let o;for(;0<5;)try{return o=Rt(),t.put(o,e,!1),o}catch(a){}throw new p(E.EIO,"Unable to commit data to key-value store.")}commitNewFile(t,e,n,o,a,s){let f=F(e),w=W(e),S=this.findINode(t,f),y=this.getDirListing(t,f,S),I=new Date().getTime();if(!S.toStats().hasAccess(4,a))throw p.EACCES(e);if(e==="/")throw p.EEXIST(e);if(y[w])throw p.EEXIST(e);let b;try{let x=this.addNewNode(t,s);b=new Z(x,s.length,o|n,I,I,I,a.uid,a.gid);let N=this.addNewNode(t,b.toBuffer());y[w]=N,t.put(S.id,_.from(JSON.stringify(y)),!0)}catch(x){throw t.abort(),x}return t.commit(),b}removeEntry(t,e,n){let o=this.store.beginTransaction("readwrite"),a=F(t),s=this.findINode(o,a),f=this.getDirListing(o,a,s),w=W(t);if(!f[w])throw p.ENOENT(t);let S=f[w],y=this.getINode(o,t,S);if(!y.toStats().hasAccess(2,n))throw p.EACCES(t);if(delete f[w],!e&&y.isDirectory())throw p.EISDIR(t);if(e&&!y.isDirectory())throw p.ENOTDIR(t);try{o.del(y.id),o.del(S),o.put(s.id,_.from(JSON.stringify(f)),!0)}catch(I){throw o.abort(),I}o.commit()}};h(St,"SyncKeyValueFileSystem");function rt(l,t){t=typeof l=="function"?l:t,He(this,l);let e=new this(typeof l=="function"?{}:l);if(typeof t!="function")return e.whenReady();e.whenReady().then(n=>t(null,n)).catch(n=>t(n))}h(rt,"CreateBackend");var je,ie=class{constructor(){this.store=new Map}name(){return ut.Name}clear(){this.store.clear()}beginTransaction(t){return new Et(this)}get(t){return this.store.get(t)}put(t,e,n){return!n&&this.store.has(t)?!1:(this.store.set(t,e),!0)}del(t){this.store.delete(t)}};h(ie,"InMemoryStore");var ut=class extends St{constructor(){super({store:new ie})}};h(ut,"InMemoryFileSystem");je=ut;ut.Name="InMemory";ut.Create=rt.bind(je);ut.Options={};var dn=nt.Root;var me=new Map;ut.Create().then(l=>bi("/",l));function re(l){return me.get(l)}h(re,"getMount");function bi(l,t){if(l[0]!=="/"&&(l="/"+l),l=gt(l),me.has(l))throw new p(E.EINVAL,"Mount point "+l+" is already in use.");me.set(l,t)}h(bi,"mount");var tt=function(l,t,e,n){function o(a){return a instanceof e?a:new e(function(s){s(a)})}return h(o,"adopt"),new(e||(e=Promise))(function(a,s){function f(y){try{S(n.next(y))}catch(I){s(I)}}h(f,"fulfilled");function w(y){try{S(n.throw(y))}catch(I){s(I)}}h(w,"rejected");function S(y){y.done?a(y.value):o(y.value).then(f,w)}h(S,"step"),S((n=n.apply(l,t||[])).next())})},k;(function(l){l[l.NOP=0]="NOP",l[l.THROW_EXCEPTION=1]="THROW_EXCEPTION",l[l.TRUNCATE_FILE=2]="TRUNCATE_FILE",l[l.CREATE_FILE=3]="CREATE_FILE"})(k=k||(k={}));var Y=class{static getFileFlag(t){return Y.flagCache.has(t)||Y.flagCache.set(t,new Y(t)),Y.flagCache.get(t)}constructor(t){if(this.flagStr=t,Y.validFlagStrs.indexOf(t)<0)throw new p(E.EINVAL,"Invalid flag: "+t)}getFlagString(){return this.flagStr}getMode(){let t=0;return t<<=1,t+=+this.isReadable(),t<<=1,t+=+this.isWriteable(),t<<=1,t}isReadable(){return this.flagStr.indexOf("r")!==-1||this.flagStr.indexOf("+")!==-1}isWriteable(){return this.flagStr.indexOf("w")!==-1||this.flagStr.indexOf("a")!==-1||this.flagStr.indexOf("+")!==-1}isTruncating(){return this.flagStr.indexOf("w")!==-1}isAppendable(){return this.flagStr.indexOf("a")!==-1}isSynchronous(){return this.flagStr.indexOf("s")!==-1}isExclusive(){return this.flagStr.indexOf("x")!==-1}pathExistsAction(){return this.isExclusive()?k.THROW_EXCEPTION:this.isTruncating()?k.TRUNCATE_FILE:k.NOP}pathNotExistsAction(){return(this.isWriteable()||this.isAppendable())&&this.flagStr!=="r+"?k.CREATE_FILE:k.THROW_EXCEPTION}};h(Y,"FileFlag");Y.flagCache=new Map;Y.validFlagStrs=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"];var ne=class{sync(){return tt(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}syncSync(){throw new p(E.ENOTSUP)}datasync(){return tt(this,void 0,void 0,function*(){return this.sync()})}datasyncSync(){return this.syncSync()}chown(t,e){return tt(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}chownSync(t,e){throw new p(E.ENOTSUP)}chmod(t){return tt(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}chmodSync(t){throw new p(E.ENOTSUP)}utimes(t,e){return tt(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}utimesSync(t,e){throw new p(E.ENOTSUP)}};h(ne,"BaseFile");var at=class extends ne{constructor(t,e,n,o,a){if(super(),this._pos=0,this._dirty=!1,this._fs=t,this._path=e,this._flag=n,this._stat=o,this._buffer=a||_.alloc(0),this._stat.size!==this._buffer.length&&this._flag.isReadable())throw new Error(`Invalid buffer: Buffer is ${this._buffer.length} long, yet Stats object specifies that file is ${this._stat.size} long.`)}getBuffer(){return this._buffer}getStats(){return this._stat}getFlag(){return this._flag}getPath(){return this._path}getPos(){return this._flag.isAppendable()?this._stat.size:this._pos}advancePos(t){return this._pos+=t}setPos(t){return this._pos=t}sync(){return tt(this,void 0,void 0,function*(){this.syncSync()})}syncSync(){throw new p(E.ENOTSUP)}close(){return tt(this,void 0,void 0,function*(){this.closeSync()})}closeSync(){throw new p(E.ENOTSUP)}stat(){return tt(this,void 0,void 0,function*(){return j.clone(this._stat)})}statSync(){return j.clone(this._stat)}truncate(t){if(this.truncateSync(t),this._flag.isSynchronous()&&!re("/").metadata.synchronous)return this.sync()}truncateSync(t){if(this._dirty=!0,!this._flag.isWriteable())throw new p(E.EPERM,"File not opened with a writeable mode.");if(this._stat.mtimeMs=Date.now(),t>this._buffer.length){let n=_.alloc(t-this._buffer.length,0);this.writeSync(n,0,n.length,this._buffer.length),this._flag.isSynchronous()&&re("/").metadata.synchronous&&this.syncSync();return}this._stat.size=t;let e=_.alloc(t);this._buffer.copy(e,0,0,t),this._buffer=e,this._flag.isSynchronous()&&re("/").metadata.synchronous&&this.syncSync()}write(t,e,n,o){return tt(this,void 0,void 0,function*(){return this.writeSync(t,e,n,o)})}writeSync(t,e,n,o){if(this._dirty=!0,o==null&&(o=this.getPos()),!this._flag.isWriteable())throw new p(E.EPERM,"File not opened with a writeable mode.");let a=o+n;if(a>this._stat.size&&(this._stat.size=a,a>this._buffer.length)){let f=_.alloc(a);this._buffer.copy(f),this._buffer=f}let s=t.copy(this._buffer,o,e,e+n);return this._stat.mtimeMs=Date.now(),this._flag.isSynchronous()?(this.syncSync(),s):(this.setPos(o+s),s)}read(t,e,n,o){return tt(this,void 0,void 0,function*(){return{bytesRead:this.readSync(t,e,n,o),buffer:t}})}readSync(t,e,n,o){if(!this._flag.isReadable())throw new p(E.EPERM,"File not opened with a readable mode.");o==null&&(o=this.getPos()),o+n>this._stat.size&&(n=this._stat.size-o);let s=this._buffer.copy(t,e,o,o+n);return this._stat.atimeMs=Date.now(),this._pos=o+n,s}chmod(t){return tt(this,void 0,void 0,function*(){this.chmodSync(t)})}chmodSync(t){if(!this._fs.metadata.supportsProperties)throw new p(E.ENOTSUP);this._dirty=!0,this._stat.chmod(t),this.syncSync()}chown(t,e){return tt(this,void 0,void 0,function*(){this.chownSync(t,e)})}chownSync(t,e){if(!this._fs.metadata.supportsProperties)throw new p(E.ENOTSUP);this._dirty=!0,this._stat.chown(t,e),this.syncSync()}isDirty(){return this._dirty}resetDirty(){this._dirty=!1}};h(at,"PreloadFile");var xt=class extends at{constructor(t,e,n,o,a){super(t,e,n,o,a)}sync(){return tt(this,void 0,void 0,function*(){})}syncSync(){}close(){return tt(this,void 0,void 0,function*(){})}closeSync(){}};h(xt,"NoSyncFile");var oe=h((l="",t)=>{throw t.name==="NotFoundError"?p.ENOENT(l):t},"handleError"),zt=class extends at{constructor(t,e,n,o,a){super(t,e,n,o,a)}sync(){return v(this,null,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),nt.Root),this.resetDirty())})}close(){return v(this,null,function*(){yield this.sync()})}};h(zt,"FileSystemAccessFile");var se=class extends Q{constructor({handle:e}){super();this._handles=new Map;this._handles.set("/",e)}static isAvailable(){return typeof FileSystemHandle=="function"}get metadata(){return At(pt({},super.metadata),{name:se.Name})}_sync(e,n,o,a){return v(this,null,function*(){let s=yield this.stat(e,a);o.mtime!==s.mtime&&(yield this.writeFile(e,n,null,Y.getFileFlag("w"),s.mode,a))})}rename(e,n,o){return v(this,null,function*(){try{let a=yield this.getHandle(e);if(a instanceof FileSystemDirectoryHandle){let s=yield this.readdir(e,o);if(yield this.mkdir(n,"wx",o),s.length===0)yield this.unlink(e,o);else for(let f of s)yield this.rename(it(e,f),it(n,f),o),yield this.unlink(e,o)}if(a instanceof FileSystemFileHandle){let s=yield a.getFile(),f=yield this.getHandle(F(n));if(f instanceof FileSystemDirectoryHandle){let S=yield(yield f.getFileHandle(W(n),{create:!0})).createWritable(),y=yield s.arrayBuffer();yield S.write(y),S.close(),yield this.unlink(e,o)}}}catch(a){oe(e,a)}})}writeFile(e,n,o,a,s,f,w){return v(this,null,function*(){let S=yield this.getHandle(F(e));if(S instanceof FileSystemDirectoryHandle){let I=yield(yield S.getFileHandle(W(e),{create:!0})).createWritable();yield I.write(n),yield I.close()}})}createFile(e,n,o,a){return v(this,null,function*(){return yield this.writeFile(e,_.alloc(0),null,n,o,a,!0),this.openFile(e,n,a)})}stat(e,n){return v(this,null,function*(){let o=yield this.getHandle(e);if(!o)throw p.FileError(E.EINVAL,e);if(o instanceof FileSystemDirectoryHandle)return new j(R.DIRECTORY,4096);if(o instanceof FileSystemFileHandle){let{lastModified:a,size:s}=yield o.getFile();return new j(R.FILE,s,void 0,void 0,a)}})}exists(e,n){return v(this,null,function*(){try{return yield this.getHandle(e),!0}catch(o){return!1}})}openFile(e,n,o){return v(this,null,function*(){let a=yield this.getHandle(e);if(a instanceof FileSystemFileHandle){let s=yield a.getFile(),f=yield s.arrayBuffer();return this.newFile(e,n,f,s.size,s.lastModified)}})}unlink(e,n){return v(this,null,function*(){let o=yield this.getHandle(F(e));if(o instanceof FileSystemDirectoryHandle)try{yield o.removeEntry(W(e),{recursive:!0})}catch(a){oe(e,a)}})}rmdir(e,n){return v(this,null,function*(){return this.unlink(e,n)})}mkdir(e,n,o){return v(this,null,function*(){let a=n&&n.flag&&n.flag.includes("w")&&!n.flag.includes("x");if((yield this.getHandle(e))&&!a)throw p.EEXIST(e);let f=yield this.getHandle(F(e));f instanceof FileSystemDirectoryHandle&&(yield f.getDirectoryHandle(W(e),{create:!0}))})}readdir(e,n){return v(this,null,function*(){let o=yield this.getHandle(e);if(!(o instanceof FileSystemDirectoryHandle))throw p.ENOTDIR(e);let a=[];try{for(var s=Ce(o.keys()),f,w,S;f=!(w=yield s.next()).done;f=!1){let y=w.value;a.push(it(e,y))}}catch(w){S=[w]}finally{try{f&&(w=s.return)&&(yield w.call(s))}finally{if(S)throw S[0]}}return a})}newFile(e,n,o,a,s){return new zt(this,e,n,new j(R.FILE,a||0,void 0,void 0,s||new Date().getTime()),_.from(o))}getHandle(e){return v(this,null,function*(){if(this._handles.has(e))return this._handles.get(e);let n="/",[,...o]=e.split("/"),a=h(w=>v(this,[w],function*([s,...f]){let S=it(n,s),y=h(b=>{if(n=S,this._handles.set(n,b),f.length===0)return this._handles.get(e);a(f)},"continueWalk"),I=this._handles.get(n);try{return yield y(yield I.getDirectoryHandle(s))}catch(b){if(b.name==="TypeMismatchError")try{return yield y(yield I.getFileHandle(s))}catch(x){oe(S,x)}else{if(b.message==="Name is not allowed.")throw new p(E.ENOENT,b.message,S);oe(S,b)}}}),"getHandleParts");yield a(o)})}},Nt=se;h(Nt,"FileSystemAccessFileSystem"),Nt.Name="FileSystemAccess",Nt.Create=rt.bind(se),Nt.Options={};var Ye=typeof fetch!="undefined"&&fetch!==null;function ce(l){throw new p(E.EIO,l.message)}h(ce,"convertError");function ye(l,t){return v(this,null,function*(){let e=yield fetch(l).catch(ce);if(!e.ok)throw new p(E.EIO,`fetch error: response returned code ${e.status}`);switch(t){case"buffer":let n=yield e.arrayBuffer().catch(ce);return _.from(n);case"json":return yield e.json().catch(ce);default:throw new p(E.EINVAL,"Invalid download type: "+t)}})}h(ye,"fetchFile");function We(l){return v(this,null,function*(){let t=yield fetch(l,{method:"HEAD"}).catch(ce);if(!t.ok)throw new p(E.EIO,`fetch HEAD error: response returned code ${t.status}`);return parseInt(t.headers.get("Content-Length")||"-1",10)})}h(We,"fetchFileSize");var _t=class{static fromListing(t){let e=new _t,n=new ht;e._index["/"]=n;let o=[["",t,n]];for(;o.length>0;){let a,s=o.pop(),f=s[0],w=s[1],S=s[2];for(let y in w)if(Object.prototype.hasOwnProperty.call(w,y)){let I=w[y],b=`${f}/${y}`;I?(e._index[b]=a=new ht,o.push([b,I,a])):a=new ae(new j(R.FILE,-1,365)),S&&(S._ls[y]=a)}}return e}constructor(){this._index={},this.addPath("/",new ht)}fileIterator(t){for(let e in this._index)if(Object.prototype.hasOwnProperty.call(this._index,e)){let n=this._index[e],o=n.getListing();for(let a of o){let s=n.getItem(a);Ht(s)&&t(s.getData())}}}addPath(t,e){if(!e)throw new Error("Inode must be specified");if(t[0]!=="/")throw new Error("Path must be absolute, got: "+t);if(Object.prototype.hasOwnProperty.call(this._index,t))return this._index[t]===e;let n=this._split_path(t),o=n[0],a=n[1],s=this._index[o];return s===void 0&&t!=="/"&&(s=new ht,!this.addPath(o,s))||t!=="/"&&!s.addItem(a,e)?!1:(Pt(e)&&(this._index[t]=e),!0)}addPathFast(t,e){let n=t.lastIndexOf("/"),o=n===0?"/":t.substring(0,n),a=t.substring(n+1),s=this._index[o];return s===void 0&&(s=new ht,this.addPathFast(o,s)),s.addItem(a,e)?(e.isDir()&&(this._index[t]=e),!0):!1}removePath(t){let e=this._split_path(t),n=e[0],o=e[1],a=this._index[n];if(a===void 0)return null;let s=a.remItem(o);if(s===null)return null;if(Pt(s)){let f=s.getListing();for(let w of f)this.removePath(t+"/"+w);t!=="/"&&delete this._index[t]}return s}ls(t){let e=this._index[t];return e===void 0?null:e.getListing()}getInode(t){let e=this._split_path(t),n=e[0],o=e[1],a=this._index[n];return a===void 0?null:n===t?a:a.getItem(o)}_split_path(t){let e=F(t),n=t.slice(e.length+(e==="/"?0:1));return[e,n]}};h(_t,"FileIndex");var ae=class{constructor(t){this.data=t}isFile(){return!0}isDir(){return!1}getData(){return this.data}setData(t){this.data=t}toStats(){return new j(R.FILE,4096,438)}};h(ae,"IndexFileInode");var ht=class{constructor(t=null){this.data=t,this._ls={}}isFile(){return!1}isDir(){return!0}getData(){return this.data}getStats(){return new j(R.DIRECTORY,4096,365)}toStats(){return this.getStats()}getListing(){return Object.keys(this._ls)}getItem(t){let e=this._ls[t];return e||null}addItem(t,e){return t in this._ls?!1:(this._ls[t]=e,!0)}remItem(t){let e=this._ls[t];return e===void 0?null:(delete this._ls[t],e)}};h(ht,"IndexDirInode");function Ht(l){return!!l&&l.isFile()}h(Ht,"isIndexFileInode");function Pt(l){return!!l&&l.isDir()}h(Pt,"isIndexDirInode");var ue=class extends Q{constructor({index:e,baseUrl:n=""}){super();e||(e="index.json");let o=typeof e=="string"?ye(e,"json"):Promise.resolve(e);this._ready=o.then(a=>(this._index=_t.fromListing(a),this)),n.length>0&&n.charAt(n.length-1)!=="/"&&(n=n+"/"),this.prefixUrl=n,this._requestFileInternal=ye,this._requestFileSizeInternal=We}static isAvailable(){return Ye}get metadata(){return At(pt({},super.metadata),{name:ue.Name,readonly:!0})}empty(){this._index.fileIterator(function(e){e.fileData=null})}preloadFile(e,n){let o=this._index.getInode(e);if(Ht(o)){if(o===null)throw p.ENOENT(e);let a=o.getData();a.size=n.length,a.fileData=n}else throw p.EISDIR(e)}stat(e,n){return v(this,null,function*(){let o=this._index.getInode(e);if(o===null)throw p.ENOENT(e);if(!o.toStats().hasAccess(4,n))throw p.EACCES(e);let a;if(Ht(o))a=o.getData(),a.size<0&&(a.size=yield this._requestFileSize(e));else if(Pt(o))a=o.getStats();else throw p.FileError(E.EINVAL,e);return a})}open(e,n,o,a){return v(this,null,function*(){if(n.isWriteable())throw new p(E.EPERM,e);let s=this._index.getInode(e);if(s===null)throw p.ENOENT(e);if(!s.toStats().hasAccess(n.getMode(),a))throw p.EACCES(e);if(Ht(s)||Pt(s))switch(n.pathExistsAction()){case k.THROW_EXCEPTION:case k.TRUNCATE_FILE:throw p.EEXIST(e);case k.NOP:if(Pt(s)){let S=s.getStats();return new xt(this,e,n,S,S.fileData||void 0)}let f=s.getData();if(f.fileData)return new xt(this,e,n,j.clone(f),f.fileData);let w=yield this._requestFile(e,"buffer");return f.size=w.length,f.fileData=w,new xt(this,e,n,j.clone(f),w);default:throw new p(E.EINVAL,"Invalid FileMode object.")}else throw p.EPERM(e)})}readdir(e,n){return v(this,null,function*(){return this.readdirSync(e,n)})}readFile(e,n,o,a){return v(this,null,function*(){let s=yield this.open(e,o,420,a);try{let w=s.getBuffer();return n===null?_.from(w):w.toString(n)}finally{yield s.close()}})}_getHTTPPath(e){return e.charAt(0)==="/"&&(e=e.slice(1)),this.prefixUrl+e}_requestFile(e,n){return this._requestFileInternal(this._getHTTPPath(e),n)}_requestFileSize(e){return this._requestFileSizeInternal(this._getHTTPPath(e))}},bt=ue;h(bt,"HTTPRequest"),bt.Name="HTTPRequest",bt.Create=rt.bind(ue),bt.Options={index:{type:["string","object"],optional:!0,description:"URL to a file index as a JSON file or the file index object itself, generated with the make_http_index script. Defaults to `index.json`."},baseUrl:{type:"string",optional:!0,description:"Used as the URL prefix for fetched files. Default: Fetch files relative to the index."}};var U=function(l,t,e,n){function o(a){return a instanceof e?a:new e(function(s){s(a)})}return h(o,"adopt"),new(e||(e=Promise))(function(a,s){function f(y){try{S(n.next(y))}catch(I){s(I)}}h(f,"fulfilled");function w(y){try{S(n.throw(y))}catch(I){s(I)}}h(w,"rejected");function S(y){y.done?a(y.value):o(y.value).then(f,w)}h(S,"step"),S((n=n.apply(l,t||[])).next())})},jt=class{constructor(t,e){this.key=t,this.value=e,this.prev=null,this.next=null}};h(jt,"LRUNode");var le=class{constructor(t){this.limit=t,this.size=0,this.map={},this.head=null,this.tail=null}set(t,e){let n=new jt(t,e);this.map[t]?(this.map[t].value=n.value,this.remove(n.key)):this.size>=this.limit&&(delete this.map[this.tail.key],this.size--,this.tail=this.tail.prev,this.tail.next=null),this.setHead(n)}get(t){if(this.map[t]){let e=this.map[t].value,n=new jt(t,e);return this.remove(t),this.setHead(n),e}else return null}remove(t){let e=this.map[t];e&&(e.prev!==null?e.prev.next=e.next:this.head=e.next,e.next!==null?e.next.prev=e.prev:this.tail=e.prev,delete this.map[t],this.size--)}removeAll(){this.size=0,this.map={},this.head=null,this.tail=null}setHead(t){t.next=this.head,t.prev=null,this.head!==null&&(this.head.prev=t),this.head=t,this.tail===null&&(this.tail=t),this.size++,this.map[t.key]=t}};h(le,"LRUCache");var Yt=class extends at{constructor(t,e,n,o,a){super(t,e,n,o,a)}sync(){return U(this,void 0,void 0,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())})}close(){return U(this,void 0,void 0,function*(){this.sync()})}};h(Yt,"AsyncKeyValueFile");var Wt=class extends Q{static isAvailable(){return!0}constructor(t){super(),this._cache=null,t>0&&(this._cache=new le(t))}init(t){return U(this,void 0,void 0,function*(){this.store=t,yield this.makeRootDirectory()})}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!1}empty(){return U(this,void 0,void 0,function*(){this._cache&&this._cache.removeAll(),yield this.store.clear(),yield this.makeRootDirectory()})}access(t,e,n){return U(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readonly"),a=yield this.findINode(o,t);if(!a)throw p.ENOENT(t);if(!a.toStats().hasAccess(e,n))throw p.EACCES(t)})}rename(t,e,n){return U(this,void 0,void 0,function*(){let o=this._cache;this._cache&&(this._cache=null,o.removeAll());try{let a=this.store.beginTransaction("readwrite"),s=F(t),f=W(t),w=F(e),S=W(e),y=yield this.findINode(a,s),I=yield this.getDirListing(a,s,y);if(!y.toStats().hasAccess(2,n))throw p.EACCES(t);if(!I[f])throw p.ENOENT(t);let b=I[f];if(delete I[f],(w+"/").indexOf(t+"/")===0)throw new p(E.EBUSY,s);let x,N;if(w===s?(x=y,N=I):(x=yield this.findINode(a,w),N=yield this.getDirListing(a,w,x)),N[S]){let B=yield this.getINode(a,e,N[S]);if(B.isFile())try{yield a.del(B.id),yield a.del(N[S])}catch(P){throw yield a.abort(),P}else throw p.EPERM(e)}N[S]=b;try{yield a.put(y.id,_.from(JSON.stringify(I)),!0),yield a.put(x.id,_.from(JSON.stringify(N)),!0)}catch(B){throw yield a.abort(),B}yield a.commit()}finally{o&&(this._cache=o)}})}stat(t,e){return U(this,void 0,void 0,function*(){let n=this.store.beginTransaction("readonly"),a=(yield this.findINode(n,t)).toStats();if(!a.hasAccess(4,e))throw p.EACCES(t);return a})}createFile(t,e,n,o){return U(this,void 0,void 0,function*(){let a=this.store.beginTransaction("readwrite"),s=_.alloc(0),f=yield this.commitNewFile(a,t,R.FILE,n,o,s);return new Yt(this,t,e,f.toStats(),s)})}openFile(t,e,n){return U(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readonly"),a=yield this.findINode(o,t),s=yield o.get(a.id);if(!a.toStats().hasAccess(e.getMode(),n))throw p.EACCES(t);if(s===void 0)throw p.ENOENT(t);return new Yt(this,t,e,a.toStats(),s)})}unlink(t,e){return U(this,void 0,void 0,function*(){return this.removeEntry(t,!1,e)})}rmdir(t,e){return U(this,void 0,void 0,function*(){if((yield this.readdir(t,e)).length>0)throw p.ENOTEMPTY(t);yield this.removeEntry(t,!0,e)})}mkdir(t,e,n){return U(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readwrite"),a=_.from("{}");yield this.commitNewFile(o,t,R.DIRECTORY,e,n,a)})}readdir(t,e){return U(this,void 0,void 0,function*(){let n=this.store.beginTransaction("readonly"),o=yield this.findINode(n,t);if(!o.toStats().hasAccess(4,e))throw p.EACCES(t);return Object.keys(yield this.getDirListing(n,t,o))})}chmod(t,e,n){return U(this,void 0,void 0,function*(){yield(yield this.openFile(t,Y.getFileFlag("r+"),n)).chmod(e)})}chown(t,e,n,o){return U(this,void 0,void 0,function*(){yield(yield this.openFile(t,Y.getFileFlag("r+"),o)).chown(e,n)})}_sync(t,e,n){return U(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readwrite"),a=yield this._findINode(o,F(t),W(t)),s=yield this.getINode(o,t,a),f=s.update(n);try{yield o.put(s.id,e,!0),f&&(yield o.put(a,s.toBuffer(),!0))}catch(w){throw yield o.abort(),w}yield o.commit()})}makeRootDirectory(){return U(this,void 0,void 0,function*(){let t=this.store.beginTransaction("readwrite");if((yield t.get(ot))===void 0){let e=new Date().getTime(),n=new Z(Rt(),4096,511|R.DIRECTORY,e,e,e,0,0);yield t.put(n.id,ee(),!1),yield t.put(ot,n.toBuffer(),!1),yield t.commit()}})}_findINode(t,e,n,o=new Set){return U(this,void 0,void 0,function*(){let a=it(e,n);if(o.has(a))throw new p(E.EIO,"Infinite loop detected while finding inode",a);if(o.add(a),this._cache){let s=this._cache.get(a);if(s)return s}if(e==="/"){if(n==="")return this._cache&&this._cache.set(a,ot),ot;{let s=yield this.getINode(t,e,ot),f=yield this.getDirListing(t,e,s);if(f[n]){let w=f[n];return this._cache&&this._cache.set(a,w),w}else throw p.ENOENT(gt(e,n))}}else{let s=yield this.findINode(t,e,o),f=yield this.getDirListing(t,e,s);if(f[n]){let w=f[n];return this._cache&&this._cache.set(a,w),w}else throw p.ENOENT(gt(e,n))}})}findINode(t,e,n=new Set){return U(this,void 0,void 0,function*(){let o=yield this._findINode(t,F(e),W(e),n);return this.getINode(t,e,o)})}getINode(t,e,n){return U(this,void 0,void 0,function*(){let o=yield t.get(n);if(!o)throw p.ENOENT(e);return Z.fromBuffer(o)})}getDirListing(t,e,n){return U(this,void 0,void 0,function*(){if(!n.isDirectory())throw p.ENOTDIR(e);let o=yield t.get(n.id);try{return JSON.parse(o.toString())}catch(a){throw p.ENOENT(e)}})}addNewNode(t,e){return U(this,void 0,void 0,function*(){let n=0,o=h(()=>U(this,void 0,void 0,function*(){if(++n===5)throw new p(E.EIO,"Unable to commit data to key-value store.");{let a=Rt();return(yield t.put(a,e,!1))?a:o()}}),"reroll");return o()})}commitNewFile(t,e,n,o,a,s){return U(this,void 0,void 0,function*(){let f=F(e),w=W(e),S=yield this.findINode(t,f),y=yield this.getDirListing(t,f,S),I=new Date().getTime();if(!S.toStats().hasAccess(2,a))throw p.EACCES(e);if(e==="/")throw p.EEXIST(e);if(y[w])throw yield t.abort(),p.EEXIST(e);try{let b=yield this.addNewNode(t,s),x=new Z(b,s.length,o|n,I,I,I,a.uid,a.gid),N=yield this.addNewNode(t,x.toBuffer());return y[w]=N,yield t.put(S.id,_.from(JSON.stringify(y)),!0),yield t.commit(),x}catch(b){throw t.abort(),b}})}removeEntry(t,e,n){return U(this,void 0,void 0,function*(){this._cache&&this._cache.remove(t);let o=this.store.beginTransaction("readwrite"),a=F(t),s=yield this.findINode(o,a),f=yield this.getDirListing(o,a,s),w=W(t);if(!f[w])throw p.ENOENT(t);let S=f[w],y=yield this.getINode(o,t,S);if(!y.toStats().hasAccess(2,n))throw p.EACCES(t);if(delete f[w],!e&&y.isDirectory())throw p.EISDIR(t);if(e&&!y.isDirectory())throw p.ENOTDIR(t);try{yield o.del(y.id),yield o.del(S),yield o.put(s.id,_.from(JSON.stringify(f)),!0)}catch(I){throw yield o.abort(),I}yield o.commit()})}};h(Wt,"AsyncKeyValueFileSystem");function qt(l,t=l.toString()){switch(l.name){case"NotFoundError":return new p(E.ENOENT,t);case"QuotaExceededError":return new p(E.ENOSPC,t);default:return new p(E.EIO,t)}}h(qt,"convertError");function Xt(l,t=E.EIO,e=null){return function(n){n.preventDefault(),l(new p(t,e!==null?e:void 0))}}h(Xt,"onErrorHandler");var Dt=class{constructor(t,e){this.tx=t;this.store=e}get(t){return new Promise((e,n)=>{try{let o=this.store.get(t);o.onerror=Xt(n),o.onsuccess=a=>{let s=a.target.result;e(s===void 0?s:_.from(s))}}catch(o){n(qt(o))}})}};h(Dt,"IndexedDBROTransaction");var Vt=class extends Dt{constructor(t,e){super(t,e)}put(t,e,n){return new Promise((o,a)=>{try{let s=n?this.store.put(e,t):this.store.add(e,t);s.onerror=Xt(a),s.onsuccess=()=>{o(!0)}}catch(s){a(qt(s))}})}del(t){return new Promise((e,n)=>{try{let o=this.store.delete(t);o.onerror=Xt(n),o.onsuccess=()=>{e()}}catch(o){n(qt(o))}})}commit(){return new Promise(t=>{setTimeout(t,0)})}abort(){return new Promise((t,e)=>{try{this.tx.abort(),t()}catch(n){e(qt(n))}})}};h(Vt,"IndexedDBRWTransaction");var Ot=class{constructor(t,e){this.db=t;this.storeName=e}static Create(t,e){return new Promise((n,o)=>{let a=e.open(t,1);a.onupgradeneeded=s=>{let f=s.target.result;f.objectStoreNames.contains(t)&&f.deleteObjectStore(t),f.createObjectStore(t)},a.onsuccess=s=>{n(new Ot(s.target.result,t))},a.onerror=Xt(o,E.EACCES)})}name(){return dt.Name+" - "+this.storeName}clear(){return new Promise((t,e)=>{try{let n=this.db.transaction(this.storeName,"readwrite"),o=n.objectStore(this.storeName),a=o.clear();a.onsuccess=()=>{setTimeout(t,0)},a.onerror=Xt(e)}catch(n){e(qt(n))}})}beginTransaction(t="readonly"){let e=this.db.transaction(this.storeName,t),n=e.objectStore(this.storeName);if(t==="readwrite")return new Vt(e,n);if(t==="readonly")return new Dt(e,n);throw new p(E.EINVAL,"Invalid transaction type.")}};h(Ot,"IndexedDBStore");var we=class extends Wt{static isAvailable(t=globalThis.indexedDB){try{if(!(t instanceof IDBFactory)||!t.open("__zenfs_test__"))return!1}catch(e){return!1}}constructor({cacheSize:t=100,storeName:e="zenfs",idbFactory:n=globalThis.indexedDB}){super(t),this._ready=Ot.Create(e,n).then(o=>(this.init(o),this))}},dt=we;h(dt,"IndexedDBFileSystem"),dt.Name="IndexedDB",dt.Create=rt.bind(we),dt.Options={storeName:{type:"string",optional:!0,description:"The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name."},cacheSize:{type:"number",optional:!0,description:"The size of the inode cache. Defaults to 100. A size of 0 or below disables caching."},idbFactory:{type:"object",optional:!0,description:"The IDBFactory to use. Defaults to globalThis.indexedDB."}};var Kt=class{constructor(t){this._storage=t}name(){return ft.Name}clear(){this._storage.clear()}beginTransaction(t){return new Et(this)}get(t){let e=this._storage.getItem(t);if(typeof e=="string")return _.from(e)}put(t,e,n){try{return!n&&this._storage.getItem(t)!==null?!1:(this._storage.setItem(t,e.toString()),!0)}catch(o){throw new p(E.ENOSPC,"Storage is full.")}}del(t){try{this._storage.removeItem(t)}catch(e){throw new p(E.EIO,"Unable to delete key "+t+": "+e)}}};h(Kt,"StorageStore");var ge=class extends St{static isAvailable(t=globalThis.localStorage){return t instanceof Storage}constructor({storage:t=globalThis.localStorage}){super({store:new Kt(t)})}},ft=ge;h(ft,"StorageFileSystem"),ft.Name="Storage",ft.Create=rt.bind(ge),ft.Options={storage:{type:"object",optional:!0,description:"The Storage to use. Defaults to globalThis.localStorage."}};function Oi(l){return typeof l=="object"&&"isBFS"in l&&!!l.isBFS}h(Oi,"isRPCMessage");var Jt=class extends Q{constructor({worker:e}){super();this._currentID=0;this._requests=new Map;this._isInitialized=!1;this._worker=e,this._worker.onmessage=n=>{if(!Oi(n.data))return;let{id:o,method:a,value:s}=n.data;if(a==="metadata"){this._metadata=s,this._isInitialized=!0;return}let{resolve:f,reject:w}=this._requests.get(o);if(this._requests.delete(o),s instanceof Error||s instanceof p){w(s);return}f(s)}}static isAvailable(){return typeof importScripts!="undefined"||typeof Worker!="undefined"}get metadata(){return At(pt(pt({},super.metadata),this._metadata),{name:Jt.Name,synchronous:!1})}_rpc(e,...n){return v(this,null,function*(){return new Promise((o,a)=>{let s=this._currentID++;this._requests.set(s,{resolve:o,reject:a}),this._worker.postMessage({isBFS:!0,id:s,method:e,args:n})})})}rename(e,n,o){return this._rpc("rename",e,n,o)}stat(e,n){return this._rpc("stat",e,n)}open(e,n,o,a){return this._rpc("open",e,n,o,a)}unlink(e,n){return this._rpc("unlink",e,n)}rmdir(e,n){return this._rpc("rmdir",e,n)}mkdir(e,n,o){return this._rpc("mkdir",e,n,o)}readdir(e,n){return this._rpc("readdir",e,n)}exists(e,n){return this._rpc("exists",e,n)}realpath(e,n){return this._rpc("realpath",e,n)}truncate(e,n,o){return this._rpc("truncate",e,n,o)}readFile(e,n,o,a){return this._rpc("readFile",e,n,o,a)}writeFile(e,n,o,a,s,f){return this._rpc("writeFile",e,n,o,a,s,f)}appendFile(e,n,o,a,s,f){return this._rpc("appendFile",e,n,o,a,s,f)}chmod(e,n,o){return this._rpc("chmod",e,n,o)}chown(e,n,o,a){return this._rpc("chown",e,n,o,a)}utimes(e,n,o,a){return this._rpc("utimes",e,n,o,a)}link(e,n,o){return this._rpc("link",e,n,o)}symlink(e,n,o,a){return this._rpc("symlink",e,n,o,a)}readlink(e,n){return this._rpc("readlink",e,n)}syncClose(e,n){return this._rpc("syncClose",e,n)}},Tt=Jt;h(Tt,"WorkerFS"),Tt.Name="WorkerFS",Tt.Create=rt.bind(Jt),Tt.Options={worker:{type:"object",description:"The target worker that you want to connect to, or the current worker if in a worker context.",validator:e=>v(Jt,null,function*(){if(typeof(e==null?void 0:e.postMessage)!="function")throw new p(E.EINVAL,"option must be a Web Worker instance.")})}};return wi(Ti);})();
|
|
4
4
|
/*! Bundled license information:
|
|
5
5
|
|
|
6
6
|
@jspm/core/nodelibs/browser/buffer.js:
|