@zenfs/dom 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backends/FileSystemAccess.d.ts +6 -7
- package/dist/backends/FileSystemAccess.js +2 -3
- package/dist/backends/HTTPRequest.d.ts +4 -6
- package/dist/backends/HTTPRequest.js +5 -10
- package/dist/backends/IndexedDB.d.ts +2 -3
- package/dist/backends/IndexedDB.js +2 -3
- package/dist/backends/Storage.d.ts +2 -3
- package/dist/backends/Storage.js +2 -2
- package/dist/backends/Worker.js +4 -4
- package/dist/browser.min.js +3 -8
- package/dist/browser.min.js.map +4 -4
- package/dist/fetch.d.ts +2 -3
- package/dist/fetch.js +3 -5
- package/package.json +3 -14
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { Cred } from '@zenfs/core/cred.js';
|
|
3
|
-
import {
|
|
2
|
+
import { FileFlag, PreloadFile } from '@zenfs/core/file.js';
|
|
4
3
|
import { BaseFileSystem, FileSystemMetadata } from '@zenfs/core/filesystem.js';
|
|
5
4
|
import { Stats } from '@zenfs/core/stats.js';
|
|
6
5
|
import { type BackendOptions } from '@zenfs/core/backends/backend.js';
|
|
@@ -15,8 +14,8 @@ declare global {
|
|
|
15
14
|
interface FileSystemAccessFileSystemOptions {
|
|
16
15
|
handle: FileSystemDirectoryHandle;
|
|
17
16
|
}
|
|
18
|
-
export declare class FileSystemAccessFile extends PreloadFile<FileSystemAccessFileSystem>
|
|
19
|
-
constructor(_fs: FileSystemAccessFileSystem, _path: string, _flag: FileFlag, _stat: Stats, contents?:
|
|
17
|
+
export declare class FileSystemAccessFile extends PreloadFile<FileSystemAccessFileSystem> {
|
|
18
|
+
constructor(_fs: FileSystemAccessFileSystem, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array);
|
|
20
19
|
sync(): Promise<void>;
|
|
21
20
|
close(): Promise<void>;
|
|
22
21
|
}
|
|
@@ -28,13 +27,13 @@ export declare class FileSystemAccessFileSystem extends BaseFileSystem {
|
|
|
28
27
|
private _handles;
|
|
29
28
|
constructor({ handle }: FileSystemAccessFileSystemOptions);
|
|
30
29
|
get metadata(): FileSystemMetadata;
|
|
31
|
-
_sync(p: string, data:
|
|
30
|
+
_sync(p: string, data: Uint8Array, stats: Stats, cred: Cred): Promise<void>;
|
|
32
31
|
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
33
32
|
writeFile(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number, cred: Cred, createFile?: boolean): Promise<void>;
|
|
34
|
-
createFile(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<
|
|
33
|
+
createFile(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<FileSystemAccessFile>;
|
|
35
34
|
stat(path: string, cred: Cred): Promise<Stats>;
|
|
36
35
|
exists(p: string, cred: Cred): Promise<boolean>;
|
|
37
|
-
openFile(path: string, flags: FileFlag, cred: Cred): Promise<
|
|
36
|
+
openFile(path: string, flags: FileFlag, cred: Cred): Promise<FileSystemAccessFile>;
|
|
38
37
|
unlink(path: string, cred: Cred): Promise<void>;
|
|
39
38
|
rmdir(path: string, cred: Cred): Promise<void>;
|
|
40
39
|
mkdir(p: string, mode: any, cred: Cred): Promise<void>;
|
|
@@ -22,7 +22,6 @@ import { FileFlag, PreloadFile } from '@zenfs/core/file.js';
|
|
|
22
22
|
import { BaseFileSystem } from '@zenfs/core/filesystem.js';
|
|
23
23
|
import { Stats, FileType } from '@zenfs/core/stats.js';
|
|
24
24
|
import { CreateBackend } from '@zenfs/core/backends/backend.js';
|
|
25
|
-
import { Buffer } from 'buffer';
|
|
26
25
|
const handleError = (path = '', error) => {
|
|
27
26
|
if (error.name === 'NotFoundError') {
|
|
28
27
|
throw ApiError.ENOENT(path);
|
|
@@ -115,7 +114,7 @@ export class FileSystemAccessFileSystem extends BaseFileSystem {
|
|
|
115
114
|
}
|
|
116
115
|
createFile(p, flag, mode, cred) {
|
|
117
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
yield this.writeFile(p,
|
|
117
|
+
yield this.writeFile(p, new Uint8Array(), null, flag, mode, cred, true);
|
|
119
118
|
return this.openFile(p, flag, cred);
|
|
120
119
|
});
|
|
121
120
|
}
|
|
@@ -213,7 +212,7 @@ export class FileSystemAccessFileSystem extends BaseFileSystem {
|
|
|
213
212
|
});
|
|
214
213
|
}
|
|
215
214
|
newFile(path, flag, data, size, lastModified) {
|
|
216
|
-
return new FileSystemAccessFile(this, path, flag, new Stats(FileType.FILE, size || 0, undefined, undefined, lastModified || new Date().getTime()),
|
|
215
|
+
return new FileSystemAccessFile(this, path, flag, new Stats(FileType.FILE, size || 0, undefined, undefined, lastModified || new Date().getTime()), new Uint8Array(data));
|
|
217
216
|
}
|
|
218
217
|
getHandle(path) {
|
|
219
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import { BaseFileSystem, FileContents, FileSystemMetadata } from '@zenfs/core/filesystem.js';
|
|
3
|
-
import {
|
|
3
|
+
import { FileFlag, NoSyncFile } from '@zenfs/core/file.js';
|
|
4
4
|
import { Stats } from '@zenfs/core/stats.js';
|
|
5
5
|
import { Cred } from '@zenfs/core/cred.js';
|
|
6
6
|
import { type BackendOptions } from '@zenfs/core/backends/backend.js';
|
|
@@ -58,19 +58,17 @@ export declare class HTTPRequest extends BaseFileSystem {
|
|
|
58
58
|
static isAvailable(): boolean;
|
|
59
59
|
readonly prefixUrl: string;
|
|
60
60
|
private _index;
|
|
61
|
-
private _requestFileInternal;
|
|
62
|
-
private _requestFileSizeInternal;
|
|
63
61
|
constructor({ index, baseUrl }: HTTPRequest.Options);
|
|
64
62
|
get metadata(): FileSystemMetadata;
|
|
65
63
|
empty(): void;
|
|
66
64
|
/**
|
|
67
65
|
* Special HTTPFS function: Preload the given file into the index.
|
|
68
66
|
* @param [String] path
|
|
69
|
-
* @param [ZenFS.
|
|
67
|
+
* @param [ZenFS.Uint8Array] buffer
|
|
70
68
|
*/
|
|
71
|
-
preloadFile(path: string, buffer:
|
|
69
|
+
preloadFile(path: string, buffer: Uint8Array): void;
|
|
72
70
|
stat(path: string, cred: Cred): Promise<Stats>;
|
|
73
|
-
open(path: string, flags: FileFlag, mode: number, cred: Cred): Promise<
|
|
71
|
+
open(path: string, flags: FileFlag, mode: number, cred: Cred): Promise<NoSyncFile<this>>;
|
|
74
72
|
readdir(path: string, cred: Cred): Promise<string[]>;
|
|
75
73
|
/**
|
|
76
74
|
* We have the entire file as a buffer; optimize readFile.
|
|
@@ -16,7 +16,7 @@ import { fetchIsAvailable, fetchFile, fetchFileSize } from '../fetch.js';
|
|
|
16
16
|
import { FileIndex, isIndexFileInode, isIndexDirInode } from '@zenfs/core/FileIndex.js';
|
|
17
17
|
import { CreateBackend } from '@zenfs/core/backends/backend.js';
|
|
18
18
|
import { R_OK } from '@zenfs/core/emulation/constants.js';
|
|
19
|
-
import {
|
|
19
|
+
import { decode } from '@zenfs/core/utils.js';
|
|
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.
|
|
@@ -64,8 +64,6 @@ export class HTTPRequest extends BaseFileSystem {
|
|
|
64
64
|
baseUrl = baseUrl + '/';
|
|
65
65
|
}
|
|
66
66
|
this.prefixUrl = baseUrl;
|
|
67
|
-
this._requestFileInternal = fetchFile;
|
|
68
|
-
this._requestFileSizeInternal = fetchFileSize;
|
|
69
67
|
}
|
|
70
68
|
get metadata() {
|
|
71
69
|
return Object.assign(Object.assign({}, super.metadata), { name: _a.Name, readonly: true });
|
|
@@ -78,7 +76,7 @@ export class HTTPRequest extends BaseFileSystem {
|
|
|
78
76
|
/**
|
|
79
77
|
* Special HTTPFS function: Preload the given file into the index.
|
|
80
78
|
* @param [String] path
|
|
81
|
-
* @param [ZenFS.
|
|
79
|
+
* @param [ZenFS.Uint8Array] buffer
|
|
82
80
|
*/
|
|
83
81
|
preloadFile(path, buffer) {
|
|
84
82
|
const inode = this._index.getInode(path);
|
|
@@ -180,10 +178,7 @@ export class HTTPRequest extends BaseFileSystem {
|
|
|
180
178
|
try {
|
|
181
179
|
const fdCast = fd;
|
|
182
180
|
const fdBuff = fdCast.getBuffer();
|
|
183
|
-
|
|
184
|
-
return Buffer.from(fdBuff);
|
|
185
|
-
}
|
|
186
|
-
return fdBuff.toString(encoding);
|
|
181
|
+
return encoding ? decode(fdBuff) : fdBuff;
|
|
187
182
|
}
|
|
188
183
|
finally {
|
|
189
184
|
yield fd.close();
|
|
@@ -197,13 +192,13 @@ export class HTTPRequest extends BaseFileSystem {
|
|
|
197
192
|
return this.prefixUrl + filePath;
|
|
198
193
|
}
|
|
199
194
|
_requestFile(p, type) {
|
|
200
|
-
return
|
|
195
|
+
return fetchFile(this._getHTTPPath(p), type);
|
|
201
196
|
}
|
|
202
197
|
/**
|
|
203
198
|
* Only requests the HEAD content, for the file size.
|
|
204
199
|
*/
|
|
205
200
|
_requestFileSize(path) {
|
|
206
|
-
return
|
|
201
|
+
return fetchFileSize(this._getHTTPPath(path));
|
|
207
202
|
}
|
|
208
203
|
}
|
|
209
204
|
_a = HTTPRequest;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { AsyncKeyValueROTransaction, AsyncKeyValueRWTransaction, AsyncKeyValueStore, AsyncKeyValueFileSystem } from '@zenfs/core/backends/AsyncStore.js';
|
|
3
2
|
import { type BackendOptions } from '@zenfs/core/backends/backend.js';
|
|
4
3
|
/**
|
|
@@ -8,7 +7,7 @@ export declare class IndexedDBROTransaction implements AsyncKeyValueROTransactio
|
|
|
8
7
|
tx: IDBTransaction;
|
|
9
8
|
store: IDBObjectStore;
|
|
10
9
|
constructor(tx: IDBTransaction, store: IDBObjectStore);
|
|
11
|
-
get(key: string): Promise<
|
|
10
|
+
get(key: string): Promise<Uint8Array>;
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
13
|
* @hidden
|
|
@@ -18,7 +17,7 @@ export declare class IndexedDBRWTransaction extends IndexedDBROTransaction imple
|
|
|
18
17
|
/**
|
|
19
18
|
* @todo return false when add has a key conflict (no error)
|
|
20
19
|
*/
|
|
21
|
-
put(key: string, data:
|
|
20
|
+
put(key: string, data: Uint8Array, overwrite: boolean): Promise<boolean>;
|
|
22
21
|
del(key: string): Promise<void>;
|
|
23
22
|
commit(): Promise<void>;
|
|
24
23
|
abort(): Promise<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { AsyncKeyValueFileSystem } from '@zenfs/core/backends/AsyncStore.js';
|
|
3
3
|
import { ApiError, ErrorCode } from '@zenfs/core/ApiError.js';
|
|
4
|
-
import { Buffer } from 'buffer';
|
|
5
4
|
import { CreateBackend } from '@zenfs/core/backends/backend.js';
|
|
6
5
|
/**
|
|
7
6
|
* Converts a DOMException or a DOMError from an IndexedDB event into a
|
|
@@ -53,8 +52,8 @@ export class IndexedDBROTransaction {
|
|
|
53
52
|
resolve(result);
|
|
54
53
|
}
|
|
55
54
|
else {
|
|
56
|
-
// IDB data is stored as an
|
|
57
|
-
resolve(
|
|
55
|
+
// IDB data is stored as an ArrayUint8Array
|
|
56
|
+
resolve(Uint8Array.from(result));
|
|
58
57
|
}
|
|
59
58
|
};
|
|
60
59
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { SyncKeyValueStore, SimpleSyncStore, SyncKeyValueFileSystem, SyncKeyValueRWTransaction } from '@zenfs/core/backends/SyncStore.js';
|
|
3
2
|
import { type BackendOptions } from '@zenfs/core/backends/backend.js';
|
|
4
3
|
/**
|
|
@@ -10,8 +9,8 @@ export declare class StorageStore implements SyncKeyValueStore, SimpleSyncStore
|
|
|
10
9
|
constructor(_storage: Storage);
|
|
11
10
|
clear(): void;
|
|
12
11
|
beginTransaction(type: string): SyncKeyValueRWTransaction;
|
|
13
|
-
get(key: string):
|
|
14
|
-
put(key: string, data:
|
|
12
|
+
get(key: string): Uint8Array | undefined;
|
|
13
|
+
put(key: string, data: Uint8Array, overwrite: boolean): boolean;
|
|
15
14
|
del(key: string): void;
|
|
16
15
|
}
|
|
17
16
|
export declare namespace StorageFileSystem {
|
package/dist/backends/Storage.js
CHANGED
|
@@ -2,7 +2,7 @@ var _a;
|
|
|
2
2
|
import { SyncKeyValueFileSystem, SimpleSyncRWTransaction } from '@zenfs/core/backends/SyncStore.js';
|
|
3
3
|
import { ApiError, ErrorCode } from '@zenfs/core/ApiError.js';
|
|
4
4
|
import { CreateBackend } from '@zenfs/core/backends/backend.js';
|
|
5
|
-
import {
|
|
5
|
+
import { encode } from '@zenfs/core/utils.js';
|
|
6
6
|
/**
|
|
7
7
|
* A synchronous key-value store backed by Storage.
|
|
8
8
|
*/
|
|
@@ -25,7 +25,7 @@ export class StorageStore {
|
|
|
25
25
|
if (typeof data != 'string') {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return encode(data);
|
|
29
29
|
}
|
|
30
30
|
put(key, data, overwrite) {
|
|
31
31
|
try {
|
package/dist/backends/Worker.js
CHANGED
|
@@ -159,11 +159,11 @@ WorkerFS.Options = {
|
|
|
159
159
|
worker: {
|
|
160
160
|
type: 'object',
|
|
161
161
|
description: 'The target worker that you want to connect to, or the current worker if in a worker context.',
|
|
162
|
-
validator
|
|
162
|
+
validator(worker) {
|
|
163
163
|
// Check for a `postMessage` function.
|
|
164
|
-
if (typeof (
|
|
165
|
-
throw new ApiError(ErrorCode.EINVAL,
|
|
164
|
+
if (typeof (worker === null || worker === void 0 ? void 0 : worker.postMessage) != 'function') {
|
|
165
|
+
throw new ApiError(ErrorCode.EINVAL, 'option must be a Web Worker instance.');
|
|
166
166
|
}
|
|
167
|
-
}
|
|
167
|
+
},
|
|
168
168
|
},
|
|
169
169
|
};
|
package/dist/browser.min.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
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: ${
|
|
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
|
-
/*! Bundled license information:
|
|
5
|
-
|
|
6
|
-
@jspm/core/nodelibs/browser/buffer.js:
|
|
7
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
8
|
-
*/
|
|
1
|
+
var ZenFS_DOM=(()=>{var lt=Object.defineProperty,te=Object.defineProperties,ee=Object.getOwnPropertyDescriptor,ie=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertyNames,Ht=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var jt=(o,e,t)=>e in o?lt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,$=(o,e)=>{for(var t in e||(e={}))Vt.call(e,t)&&jt(o,t,e[t]);if(Ht)for(var t of Ht(e))ne.call(e,t)&&jt(o,t,e[t]);return o},it=(o,e)=>te(o,ie(e)),h=(o,e)=>lt(o,"name",{value:e,configurable:!0});var se=(o,e)=>{for(var t in e)lt(o,t,{get:e[t],enumerable:!0})},oe=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of re(e))!Vt.call(o,r)&&r!==t&<(o,r,{get:()=>e[r],enumerable:!(i=ee(e,r))||i.enumerable});return o};var ae=o=>oe(lt({},"__esModule",{value:!0}),o);var S=(o,e,t)=>new Promise((i,r)=>{var n=d=>{try{a(t.next(d))}catch(f){r(f)}},s=d=>{try{a(t.throw(d))}catch(f){r(f)}},a=d=>d.done?i(d.value):Promise.resolve(d.value).then(n,s);a((t=t.apply(o,e)).next())}),$t=(o,e,t)=>(e=o[Symbol.asyncIterator],t=(i,r)=>(r=o[i])&&(e[i]=n=>new Promise((s,a,d)=>(n=r.call(o,n),d=n.done,Promise.resolve(n.value).then(f=>s({value:f,done:d}),a)))),e?e.call(o):(o=o[Symbol.iterator](),e={},t("next"),t("return"),e));var me={};se(me,{FileSystemAccessFile:()=>ht,FileSystemAccessFileSystem:()=>G,HTTPRequest:()=>Z,IndexedDBFileSystem:()=>j,IndexedDBROTransaction:()=>at,IndexedDBRWTransaction:()=>gt,IndexedDBStore:()=>tt,StorageFileSystem:()=>V,StorageStore:()=>St,WorkerFS:()=>et});var ce="/",W="/";function rt(o,e){if(typeof o!="string")throw new TypeError(`"${e}" is not a string`)}h(rt,"validateString");function Wt(o,e){let t="",i=0,r=-1,n=0,s="\0";for(let a=0;a<=o.length;++a){if(a<o.length)s=o[a];else{if(s=="/")break;s="/"}if(s=="/"){if(!(r===a-1||n===1))if(n===2){if(t.length<2||i!==2||t.at(-1)!=="."||t.at(-2)!=="."){if(t.length>2){let d=t.lastIndexOf("/");d===-1?(t="",i=0):(t=t.slice(0,d),i=t.length-1-t.lastIndexOf("/")),r=a,n=0;continue}else if(t.length!==0){t="",i=0,r=a,n=0;continue}}e&&(t+=t.length>0?"/..":"..",i=2)}else t.length>0?t+="/"+o.slice(r+1,a):t=o.slice(r+1,a),i=a-r-1;r=a,n=0}else s==="."&&n!==-1?++n:n=-1}return t}h(Wt,"normalizeString");function Y(...o){let e="",t=!1;for(let i=o.length-1;i>=-1&&!t;i--){let r=i>=0?o[i]:ce;rt(r,`paths[${i}]`),r.length!==0&&(e=`${r}/${e}`,t=r[0]==="/")}return e=Wt(e,!t),t?`/${e}`:e.length>0?e:"."}h(Y,"resolve");function le(o){if(rt(o,"path"),o.length===0)return".";let e=o[0]==="/",t=o.at(-1)==="/";return o=Wt(o,!e),o.length===0?e?"/":t?"./":".":(t&&(o+="/"),e?`/${o}`:o)}h(le,"normalize");function C(...o){if(o.length===0)return".";let e;for(let t=0;t<o.length;++t){let i=o[t];rt(i,"path"),i.length>0&&(e===void 0?e=i:e+=`/${i}`)}return e===void 0?".":le(e)}h(C,"join");function g(o){if(rt(o,"path"),o.length===0)return".";let e=o[0]==="/",t=-1,i=!0;for(let r=o.length-1;r>=1;--r)if(o[r]==="/"){if(!i){t=r;break}}else i=!1;return t===-1?e?"/":".":e&&t===1?"//":o.slice(0,t)}h(g,"dirname");function I(o,e){e!==void 0&&rt(e,"ext"),rt(o,"path");let t=0,i=-1,r=!0;if(e!==void 0&&e.length>0&&e.length<=o.length){if(e===o)return"";let n=e.length-1,s=-1;for(let a=o.length-1;a>=0;--a)if(o[a]==="/"){if(!r){t=a+1;break}}else s===-1&&(r=!1,s=a+1),n>=0&&(o[a]===e[n]?--n===-1&&(i=a):(n=-1,i=s));return t===i?i=s:i===-1&&(i=o.length),o.slice(t,i)}for(let n=o.length-1;n>=0;--n)if(o[n]==="/"){if(!r){t=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":o.slice(t,i)}h(I,"basename");var de=function(o,e,t,i){function r(n){return n instanceof t?n:new t(function(s){s(n)})}return h(r,"adopt"),new(t||(t=Promise))(function(n,s){function a(u){try{f(i.next(u))}catch(m){s(m)}}h(a,"fulfilled");function d(u){try{f(i.throw(u))}catch(m){s(m)}}h(d,"rejected");function f(u){u.done?n(u.value):r(u.value).then(a,d)}h(f,"step"),f((i=i.apply(o,e||[])).next())})};function xt(o,e,t,i,r){return Math.min(o+1,e+1,t+1,i===r?e:e+1)}h(xt,"_min");function ue(o,e){if(o===e)return 0;o.length>e.length&&([o,e]=[e,o]);let t=o.length,i=e.length;for(;t>0&&o.charCodeAt(t-1)===e.charCodeAt(i-1);)t--,i--;let r=0;for(;r<t&&o.charCodeAt(r)===e.charCodeAt(r);)r++;if(t-=r,i-=r,t===0||i===1)return i;let n=new Array(t<<1);for(let p=0;p<t;)n[t+p]=o.charCodeAt(r+p),n[p]=++p;let s,a,d,f,u;for(s=0;s+3<i;){let p=e.charCodeAt(r+(a=s)),w=e.charCodeAt(r+(d=s+1)),x=e.charCodeAt(r+(f=s+2)),B=e.charCodeAt(r+(u=s+3)),ct=s+=4;for(let bt=0;bt<t;){let Nt=n[t+bt],Bt=n[bt];a=xt(Bt,a,d,p,Nt),d=xt(a,d,f,w,Nt),f=xt(d,f,u,x,Nt),ct=xt(f,u,ct,B,Nt),n[bt++]=ct,u=f,f=d,d=a,a=Bt}}let m=0;for(;s<i;){let p=e.charCodeAt(r+(a=s));m=++s;for(let w=0;w<t;w++){let x=n[w];n[w]=m=x<a||m<a?x>m?m+1:x+1:p===n[t+w]?a:a+1,a=x}}return m}h(ue,"levenshtein");function Yt(o,e){return de(this,void 0,void 0,function*(){let t=o.Options,i=o.Name,r=0,n=!1,s=!1;for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a)){let d=t[a],f=e&&e[a];if(f==null){if(!d.optional){let u=Object.keys(e).filter(m=>!(m in t)).map(m=>({str:m,distance:ue(a,m)})).filter(m=>m.distance<5).sort((m,p)=>m.distance-p.distance);if(n)return;throw n=!0,new c(l.EINVAL,`[${i}] Required option '${a}' not provided.${u.length>0?` You provided unrecognized option '${u[0].str}'; perhaps you meant to type '${a}'.`:""}
|
|
2
|
+
Option description: ${d.description}`)}}else{let u=!1;if(Array.isArray(d.type)?u=d.type.indexOf(typeof f)!==-1:u=typeof f===d.type,u){if(d.validator){r++;try{yield d.validator(f)}catch(m){if(!n){if(m)throw n=!0,m;if(r--,r===0&&s)return}}}}else{if(n)return;throw n=!0,new c(l.EINVAL,`[${i}] Value provided for option ${a} is not the proper type. Expected ${Array.isArray(d.type)?`one of {${d.type.join(", ")}}`:d.type}, but received ${typeof f}
|
|
3
|
+
Option description: ${d.description}`)}}}s=!0})}h(Yt,"checkOptions");var ge=typeof globalThis.setImmediate=="function"?globalThis.setImmediate:o=>setTimeout(o,0),A="/",b=new globalThis.TextEncoder().encode,z=new globalThis.TextDecoder().decode;function nt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){let e=Math.random()*16|0;return(o==="x"?e:e&3|8).toString(16)})}h(nt,"randomUUID");var l;(function(o){o[o.EPERM=1]="EPERM",o[o.ENOENT=2]="ENOENT",o[o.EIO=5]="EIO",o[o.EBADF=9]="EBADF",o[o.EACCES=13]="EACCES",o[o.EBUSY=16]="EBUSY",o[o.EEXIST=17]="EEXIST",o[o.ENOTDIR=20]="ENOTDIR",o[o.EISDIR=21]="EISDIR",o[o.EINVAL=22]="EINVAL",o[o.EFBIG=27]="EFBIG",o[o.ENOSPC=28]="ENOSPC",o[o.EROFS=30]="EROFS",o[o.ENOTEMPTY=39]="ENOTEMPTY",o[o.ENOTSUP=95]="ENOTSUP"})(l=l||(l={}));var F={};F[l.EPERM]="Operation not permitted.";F[l.ENOENT]="No such file or directory.";F[l.EIO]="Input/output error.";F[l.EBADF]="Bad file descriptor.";F[l.EACCES]="Permission denied.";F[l.EBUSY]="Resource busy or locked.";F[l.EEXIST]="File exists.";F[l.ENOTDIR]="File is not a directory.";F[l.EISDIR]="File is a directory.";F[l.EINVAL]="Invalid argument.";F[l.EFBIG]="File is too big.";F[l.ENOSPC]="No space left on disk.";F[l.EROFS]="Cannot modify a read-only file system.";F[l.ENOTEMPTY]="Directory is not empty.";F[l.ENOTSUP]="Operation is not supported.";var c=class extends Error{static fromJSON(e){let t=new c(e.errno,e.message,e.path);return t.code=e.code,t.stack=e.stack,t}static Derserialize(e,t=0){let i=new DataView("buffer"in e?e.buffer:e),r=z(i.buffer.slice(t+4,t+4+i.getUint32(t,!0)));return c.fromJSON(JSON.parse(r))}static FileError(e,t){return new c(e,F[e],t)}static EACCES(e){return this.FileError(l.EACCES,e)}static ENOENT(e){return this.FileError(l.ENOENT,e)}static EEXIST(e){return this.FileError(l.EEXIST,e)}static EISDIR(e){return this.FileError(l.EISDIR,e)}static ENOTDIR(e){return this.FileError(l.ENOTDIR,e)}static EPERM(e){return this.FileError(l.EPERM,e)}static ENOTEMPTY(e){return this.FileError(l.ENOTEMPTY,e)}constructor(e,t=F[e],i){super(t),this.syscall="",this.errno=e,this.code=l[e],this.path=i,this.message=`Error: ${this.code}: ${t}${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}}serialize(e=new Uint8Array(this.bufferSize()),t=0){let i=new DataView("buffer"in e?e.buffer:e),r=new Uint8Array(i.buffer),n=b(JSON.stringify(this.toJSON()));return r.set(n),i.setUint32(t,n.byteLength,!0),r}bufferSize(){return 4+JSON.stringify(this.toJSON()).length}};h(c,"ApiError");var k=class{constructor(e,t,i,r,n,s){this.uid=e,this.gid=t,this.suid=i,this.sgid=r,this.euid=n,this.egid=s}};h(k,"Cred");k.Root=new k(0,0,0,0,0,0);var E;(function(o){o[o.FILE=32768]="FILE",o[o.DIRECTORY=16384]="DIRECTORY",o[o.SYMLINK=40960]="SYMLINK"})(E=E||(E={}));var O=class{static Deserialize(e){let t=new DataView("buffer"in e?e.buffer:e),i=t.getUint32(0,!0),r=t.getUint32(4,!0),n=t.getFloat64(8,!0),s=t.getFloat64(16,!0),a=t.getFloat64(24,!0),d=t.getUint32(32,!0),f=t.getUint32(36,!0);return new O(r&61440,i,r&-61441,n,s,a,d,f)}static clone(e){return new O(e.mode&61440,e.size,e.mode&-61441,e.atimeMs,e.mtimeMs,e.ctimeMs,e.uid,e.gid,e.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(e,t,i,r,n,s,a,d,f){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=t;let u=0;if(typeof r!="number"&&(u=Date.now(),r=u),typeof n!="number"&&(u||(u=Date.now()),n=u),typeof s!="number"&&(u||(u=Date.now()),s=u),typeof f!="number"&&(u||(u=Date.now()),f=u),typeof a!="number"&&(a=0),typeof d!="number"&&(d=0),this.atimeMs=r,this.ctimeMs=s,this.mtimeMs=n,this.birthtimeMs=f,i)this.mode=i;else switch(e){case E.FILE:this.mode=420;break;case E.DIRECTORY:default:this.mode=511}this.blocks=Math.ceil(t/512),this.mode&61440||(this.mode|=e)}serialize(){let e=new Uint8Array(32),t=new DataView(e.buffer);return t.setUint32(0,this.size,!0),t.setUint32(4,this.mode,!0),t.setFloat64(8,this.atime.getTime(),!0),t.setFloat64(16,this.mtime.getTime(),!0),t.setFloat64(24,this.ctime.getTime(),!0),t.setUint32(32,this.uid,!0),t.setUint32(36,this.gid,!0),e}isFile(){return(this.mode&61440)===32768}isDirectory(){return(this.mode&61440)===16384}isSymbolicLink(){return(this.mode&61440)===40960}hasAccess(e,t){if(t.euid===0||t.egid===0)return!0;let i=this.mode&-61441,r=15,n=15,s=15;if(t.euid==this.uid){let f=(3840&i)>>8;r=(e^f)&e}if(t.egid==this.gid){let f=(240&i)>>4;n=(e^f)&e}let a=15&i;return s=(e^a)&e,!(r&n&s)}getCred(e=this.uid,t=this.gid){return new k(e,t,this.uid,this.gid,e,t)}chmod(e){this.mode=this.mode&61440|e}chown(e,t){!isNaN(+e)&&0<=+e&&+e<Math.pow(2,32)&&(this.uid=e),!isNaN(+t)&&0<=+t&&+t<Math.pow(2,32)&&(this.gid=t)}isSocket(){return!1}isBlockDevice(){return!1}isCharacterDevice(){return!1}isFIFO(){return!1}};h(O,"Stats");var y=function(o,e,t,i){function r(n){return n instanceof t?n:new t(function(s){s(n)})}return h(r,"adopt"),new(t||(t=Promise))(function(n,s){function a(u){try{f(i.next(u))}catch(m){s(m)}}h(a,"fulfilled");function d(u){try{f(i.throw(u))}catch(m){s(m)}}h(d,"rejected");function f(u){u.done?n(u.value):r(u.value).then(a,d)}h(f,"step"),f((i=i.apply(o,e||[])).next())})},Jt,vt=class{constructor(e){}};h(vt,"FileSystem");var T=class extends vt{constructor(e){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(e,t,i){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}createFile(e,t,i,r){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}open(e,t,i,r){return y(this,void 0,void 0,function*(){try{let n=yield this.stat(e,r);switch(t.pathExistsAction()){case v.THROW_EXCEPTION:throw c.EEXIST(e);case v.TRUNCATE_FILE:let s=yield this.openFile(e,t,r);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 v.NOP:return this.openFile(e,t,r);default:throw new c(l.EINVAL,"Invalid FileFlag object.")}}catch(n){switch(t.pathNotExistsAction()){case v.CREATE_FILE:let s=yield this.stat(g(e),r);if(s&&!s.isDirectory())throw c.ENOTDIR(g(e));return this.createFile(e,t,i,r);case v.THROW_EXCEPTION:throw c.ENOENT(e);default:throw new c(l.EINVAL,"Invalid FileFlag object.")}}})}access(e,t,i){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}accessSync(e,t,i){throw new c(l.ENOTSUP)}rename(e,t,i){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}renameSync(e,t,i){throw new c(l.ENOTSUP)}stat(e,t){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}statSync(e,t){throw new c(l.ENOTSUP)}openFileSync(e,t,i){throw new c(l.ENOTSUP)}createFileSync(e,t,i,r){throw new c(l.ENOTSUP)}openSync(e,t,i,r){let n;try{n=this.statSync(e,r)}catch(s){switch(t.pathNotExistsAction()){case v.CREATE_FILE:if(!this.statSync(g(e),r).isDirectory())throw c.ENOTDIR(g(e));return this.createFileSync(e,t,i,r);case v.THROW_EXCEPTION:throw c.ENOENT(e);default:throw new c(l.EINVAL,"Invalid FileFlag object.")}}if(!n.hasAccess(i,r))throw c.EACCES(e);switch(t.pathExistsAction()){case v.THROW_EXCEPTION:throw c.EEXIST(e);case v.TRUNCATE_FILE:return this.unlinkSync(e,r),this.createFileSync(e,t,n.mode,r);case v.NOP:return this.openFileSync(e,t,r);default:throw new c(l.EINVAL,"Invalid FileFlag object.")}}unlink(e,t){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}unlinkSync(e,t){throw new c(l.ENOTSUP)}rmdir(e,t){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}rmdirSync(e,t){throw new c(l.ENOTSUP)}mkdir(e,t,i){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}mkdirSync(e,t,i){throw new c(l.ENOTSUP)}readdir(e,t){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}readdirSync(e,t){throw new c(l.ENOTSUP)}exists(e,t){return y(this,void 0,void 0,function*(){try{return yield this.stat(e,t),!0}catch(i){return!1}})}existsSync(e,t){try{return this.statSync(e,t),!0}catch(i){return!1}}realpath(e,t){return y(this,void 0,void 0,function*(){if(this.metadata.supportsLinks){let i=e.split(W);for(let r=0;r<i.length;r++){let n=i.slice(0,r+1);i[r]=C(...n)}return i.join(W)}else{if(!(yield this.exists(e,t)))throw c.ENOENT(e);return e}})}realpathSync(e,t){if(this.metadata.supportsLinks){let i=e.split(W);for(let r=0;r<i.length;r++){let n=i.slice(0,r+1);i[r]=C(...n)}return i.join(W)}else{if(this.existsSync(e,t))return e;throw c.ENOENT(e)}}truncate(e,t,i){return y(this,void 0,void 0,function*(){let r=yield this.open(e,_.getFileFlag("r+"),420,i);try{yield r.truncate(t)}finally{yield r.close()}})}truncateSync(e,t,i){let r=this.openSync(e,_.getFileFlag("r+"),420,i);try{r.truncateSync(t)}finally{r.closeSync()}}readFile(e,t,i,r){return y(this,void 0,void 0,function*(){let n=yield this.open(e,i,420,r);try{let s=yield n.stat(),a=new Uint8Array(s.size);return yield n.read(a,0,s.size,0),yield n.close(),t===null?a:z(a)}finally{yield n.close()}})}readFileSync(e,t,i,r){let n=this.openSync(e,i,420,r);try{let s=n.statSync(),a=new Uint8Array(s.size);return n.readSync(a,0,s.size,0),n.closeSync(),t===null?a:z(a)}finally{n.closeSync()}}writeFile(e,t,i,r,n,s){return y(this,void 0,void 0,function*(){let a=yield this.open(e,r,n,s);try{typeof t=="string"&&(t=b(t)),yield a.write(t,0,t.length,0)}finally{yield a.close()}})}writeFileSync(e,t,i,r,n,s){let a=this.openSync(e,r,n,s);try{typeof t=="string"&&(t=b(t)),a.writeSync(t,0,t.length,0)}finally{a.closeSync()}}appendFile(e,t,i,r,n,s){return y(this,void 0,void 0,function*(){let a=yield this.open(e,r,n,s);try{typeof t=="string"&&(t=b(t)),yield a.write(t,0,t.length,null)}finally{yield a.close()}})}appendFileSync(e,t,i,r,n,s){let a=this.openSync(e,r,n,s);try{typeof t=="string"&&(t=b(t)),a.writeSync(t,0,t.length,null)}finally{a.closeSync()}}chmod(e,t,i){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}chmodSync(e,t,i){throw new c(l.ENOTSUP)}chown(e,t,i,r){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}chownSync(e,t,i,r){throw new c(l.ENOTSUP)}utimes(e,t,i,r){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}utimesSync(e,t,i,r){throw new c(l.ENOTSUP)}link(e,t,i){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}linkSync(e,t,i){throw new c(l.ENOTSUP)}symlink(e,t,i,r){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}symlinkSync(e,t,i,r){throw new c(l.ENOTSUP)}readlink(e,t){return y(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}readlinkSync(e,t){throw new c(l.ENOTSUP)}};h(T,"BaseFileSystem");Jt=T;T.Name=Jt.name;var dt=class extends T{get metadata(){return Object.assign(Object.assign({},super.metadata),{synchronous:!0})}access(e,t,i){return y(this,void 0,void 0,function*(){return this.accessSync(e,t,i)})}rename(e,t,i){return y(this,void 0,void 0,function*(){return this.renameSync(e,t,i)})}stat(e,t){return y(this,void 0,void 0,function*(){return this.statSync(e,t)})}open(e,t,i,r){return y(this,void 0,void 0,function*(){return this.openSync(e,t,i,r)})}unlink(e,t){return y(this,void 0,void 0,function*(){return this.unlinkSync(e,t)})}rmdir(e,t){return y(this,void 0,void 0,function*(){return this.rmdirSync(e,t)})}mkdir(e,t,i){return y(this,void 0,void 0,function*(){return this.mkdirSync(e,t,i)})}readdir(e,t){return y(this,void 0,void 0,function*(){return this.readdirSync(e,t)})}chmod(e,t,i){return y(this,void 0,void 0,function*(){return this.chmodSync(e,t,i)})}chown(e,t,i,r){return y(this,void 0,void 0,function*(){return this.chownSync(e,t,i,r)})}utimes(e,t,i,r){return y(this,void 0,void 0,function*(){return this.utimesSync(e,t,i,r)})}link(e,t,i){return y(this,void 0,void 0,function*(){return this.linkSync(e,t,i)})}symlink(e,t,i,r){return y(this,void 0,void 0,function*(){return this.symlinkSync(e,t,i,r)})}readlink(e,t){return y(this,void 0,void 0,function*(){return this.readlinkSync(e,t)})}};h(dt,"SynchronousFileSystem");var D=class{static Deserialize(e){let t=new DataView("buffer"in e?e.buffer:e);return new D(z(t.buffer.slice(38)),t.getUint32(0,!0),t.getUint16(4,!0),t.getFloat64(6,!0),t.getFloat64(14,!0),t.getFloat64(22,!0),t.getUint32(30,!0),t.getUint32(34,!0))}constructor(e,t,i,r,n,s,a,d){this.id=e,this.size=t,this.mode=i,this.atime=r,this.mtime=n,this.ctime=s,this.uid=a,this.gid=d}toStats(){return new O((this.mode&61440)===E.DIRECTORY?E.DIRECTORY:E.FILE,this.size,this.mode,this.atime,this.mtime,this.ctime,this.uid,this.gid)}getSize(){return 38+this.id.length}serialize(e=new Uint8Array(this.getSize())){let t=new DataView("buffer"in e?e.buffer:e);t.setUint32(0,this.size,!0),t.setUint16(4,this.mode,!0),t.setFloat64(6,this.atime,!0),t.setFloat64(14,this.mtime,!0),t.setFloat64(22,this.ctime,!0),t.setUint32(30,this.uid,!0),t.setUint32(34,this.gid,!0);let i=new Uint8Array(t.buffer);return i.set(b(this.id),38),i}update(e){let t=!1;this.size!==e.size&&(this.size=e.size,t=!0),this.mode!==e.mode&&(this.mode=e.mode,t=!0);let i=e.atime.getTime();this.atime!==i&&(this.atime=i,t=!0);let r=e.mtime.getTime();this.mtime!==r&&(this.mtime=r,t=!0);let n=e.ctime.getTime();return this.ctime!==n&&(this.ctime=n,t=!0),this.uid!==e.uid&&(this.uid=e.uid,t=!0),this.uid!==e.uid&&(this.uid=e.uid,t=!0),t}isFile(){return(this.mode&61440)===E.FILE}isDirectory(){return(this.mode&61440)===E.DIRECTORY}};h(D,"Inode");var q=class{constructor(e){this.store=e,this.originalData={},this.modifiedKeys=[]}get(e){let t=this.store.get(e);return this.stashOldValue(e,t),t}put(e,t,i){return this.markModified(e),this.store.put(e,t,i)}del(e){this.markModified(e),this.store.del(e)}commit(){}abort(){for(let e of this.modifiedKeys){let t=this.originalData[e];t?this.store.put(e,t,!0):this.store.del(e)}}_has(e){return Object.prototype.hasOwnProperty.call(this.originalData,e)}stashOldValue(e,t){this._has(e)||(this.originalData[e]=t)}markModified(e){this.modifiedKeys.indexOf(e)===-1&&(this.modifiedKeys.push(e),this._has(e)||(this.originalData[e]=this.store.get(e)))}};h(q,"SimpleSyncRWTransaction");var ut=class extends L{constructor(e,t,i,r,n){super(e,t,i,r,n)}syncSync(){this.isDirty()&&(this._fs._syncSync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())}closeSync(){this.syncSync()}};h(ut,"SyncKeyValueFile");var X=class extends dt{static isAvailable(){return!0}constructor(e){super(),this.store=e.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(e,t,i){let r=this.store.beginTransaction("readonly");if(!this.findINode(r,e).toStats().hasAccess(t,i))throw c.EACCES(e)}renameSync(e,t,i){let r=this.store.beginTransaction("readwrite"),n=g(e),s=I(e),a=g(t),d=I(t),f=this.findINode(r,n),u=this.getDirListing(r,n,f);if(!f.toStats().hasAccess(2,i))throw c.EACCES(e);if(!u[s])throw c.ENOENT(e);let m=u[s];if(delete u[s],(a+"/").indexOf(e+"/")===0)throw new c(l.EBUSY,n);let p,w;if(a===n?(p=f,w=u):(p=this.findINode(r,a),w=this.getDirListing(r,a,p)),w[d]){let x=this.getINode(r,t,w[d]);if(x.isFile())try{r.del(x.id),r.del(w[d])}catch(B){throw r.abort(),B}else throw c.EPERM(t)}w[d]=m;try{r.put(f.id,b(JSON.stringify(u)),!0),r.put(p.id,b(JSON.stringify(w)),!0)}catch(x){throw r.abort(),x}r.commit()}statSync(e,t){let i=this.findINode(this.store.beginTransaction("readonly"),e).toStats();if(!i.hasAccess(4,t))throw c.EACCES(e);return i}createFileSync(e,t,i,r){let n=this.store.beginTransaction("readwrite"),s=new Uint8Array(0),a=this.commitNewFile(n,e,E.FILE,i,r,s);return new ut(this,e,t,a.toStats(),s)}openFileSync(e,t,i){let r=this.store.beginTransaction("readonly"),n=this.findINode(r,e),s=r.get(n.id);if(!n.toStats().hasAccess(t.getMode(),i))throw c.EACCES(e);if(s===void 0)throw c.ENOENT(e);return new ut(this,e,t,n.toStats(),s)}unlinkSync(e,t){this.removeEntry(e,!1,t)}rmdirSync(e,t){if(this.readdirSync(e,t).length>0)throw c.ENOTEMPTY(e);this.removeEntry(e,!0,t)}mkdirSync(e,t,i){let r=this.store.beginTransaction("readwrite"),n=b("{}");this.commitNewFile(r,e,E.DIRECTORY,t,i,n)}readdirSync(e,t){let i=this.store.beginTransaction("readonly"),r=this.findINode(i,e);if(!r.toStats().hasAccess(4,t))throw c.EACCES(e);return Object.keys(this.getDirListing(i,e,r))}chmodSync(e,t,i){this.openFileSync(e,_.getFileFlag("r+"),i).chmodSync(t)}chownSync(e,t,i,r){this.openFileSync(e,_.getFileFlag("r+"),r).chownSync(t,i)}_syncSync(e,t,i){let r=this.store.beginTransaction("readwrite"),n=this._findINode(r,g(e),I(e)),s=this.getINode(r,e,n),a=s.update(i);try{r.put(s.id,t,!0),a&&r.put(n,s.serialize(),!0)}catch(d){throw r.abort(),d}r.commit()}makeRootDirectory(){let e=this.store.beginTransaction("readwrite");if(e.get(A)===void 0){let t=new Date().getTime(),i=new D(nt(),4096,511|E.DIRECTORY,t,t,t,0,0);e.put(i.id,b("{}"),!1),e.put(A,i.serialize(),!1),e.commit()}}_findINode(e,t,i,r=new Set){let n=C(t,i);if(r.has(n))throw new c(l.EIO,"Infinite loop detected while finding inode",n);r.add(n);let s=h(a=>{let d=this.getDirListing(e,t,a);if(d[i])return d[i];throw c.ENOENT(Y(t,i))},"readDirectory");return t==="/"?i===""?A:s(this.getINode(e,t,A)):s(this.getINode(e,t+W+i,this._findINode(e,g(t),I(t),r)))}findINode(e,t){return this.getINode(e,t,this._findINode(e,g(t),I(t)))}getINode(e,t,i){let r=e.get(i);if(r===void 0)throw c.ENOENT(t);return D.Deserialize(r)}getDirListing(e,t,i){if(!i.isDirectory())throw c.ENOTDIR(t);let r=e.get(i.id);if(r===void 0)throw c.ENOENT(t);return JSON.parse(r.toString())}addNewNode(e,t){let r;for(;0<5;)try{return r=nt(),e.put(r,t,!1),r}catch(n){}throw new c(l.EIO,"Unable to commit data to key-value store.")}commitNewFile(e,t,i,r,n,s){let a=g(t),d=I(t),f=this.findINode(e,a),u=this.getDirListing(e,a,f),m=new Date().getTime();if(!f.toStats().hasAccess(4,n))throw c.EACCES(t);if(t==="/")throw c.EEXIST(t);if(u[d])throw c.EEXIST(t);let p;try{let w=this.addNewNode(e,s);p=new D(w,s.length,r|i,m,m,m,n.uid,n.gid);let x=this.addNewNode(e,p.serialize());u[d]=x,e.put(f.id,b(JSON.stringify(u)),!0)}catch(w){throw e.abort(),w}return e.commit(),p}removeEntry(e,t,i){let r=this.store.beginTransaction("readwrite"),n=g(e),s=this.findINode(r,n),a=this.getDirListing(r,n,s),d=I(e);if(!a[d])throw c.ENOENT(e);let f=a[d],u=this.getINode(r,e,f);if(!u.toStats().hasAccess(2,i))throw c.EACCES(e);if(delete a[d],!t&&u.isDirectory())throw c.EISDIR(e);if(t&&!u.isDirectory())throw c.ENOTDIR(e);try{r.del(u.id),r.del(f),r.put(s.id,b(JSON.stringify(a)),!0)}catch(m){throw r.abort(),m}r.commit()}};h(X,"SyncKeyValueFileSystem");function R(o,e){e=typeof o=="function"?o:e,Yt(this,o);let t=new this(typeof o=="function"?{}:o);if(typeof e!="function")return t.whenReady();t.whenReady().then(i=>e(null,i)).catch(i=>e(i))}h(R,"CreateBackend");var Gt,Ot=class{constructor(){this.store=new Map}name(){return M.Name}clear(){this.store.clear()}beginTransaction(e){return new q(this)}get(e){return this.store.get(e)}put(e,t,i){return!i&&this.store.has(e)?!1:(this.store.set(e,t),!0)}del(e){this.store.delete(e)}};h(Ot,"InMemoryStore");var M=class extends X{constructor(){super({store:new Ot})}};h(M,"InMemoryFileSystem");Gt=M;M.Name="InMemory";M.Create=R.bind(Gt);M.Options={};var ai=k.Root;var Ut=new Map;M.Create().then(o=>he("/",o));function _t(o){return Ut.get(o)}h(_t,"getMount");function he(o,e){if(o[0]!=="/"&&(o="/"+o),o=Y(o),Ut.has(o))throw new c(l.EINVAL,"Mount point "+o+" is already in use.");Ut.set(o,e)}h(he,"mount");var P=function(o,e,t,i){function r(n){return n instanceof t?n:new t(function(s){s(n)})}return h(r,"adopt"),new(t||(t=Promise))(function(n,s){function a(u){try{f(i.next(u))}catch(m){s(m)}}h(a,"fulfilled");function d(u){try{f(i.throw(u))}catch(m){s(m)}}h(d,"rejected");function f(u){u.done?n(u.value):r(u.value).then(a,d)}h(f,"step"),f((i=i.apply(o,e||[])).next())})},v;(function(o){o[o.NOP=0]="NOP",o[o.THROW_EXCEPTION=1]="THROW_EXCEPTION",o[o.TRUNCATE_FILE=2]="TRUNCATE_FILE",o[o.CREATE_FILE=3]="CREATE_FILE"})(v=v||(v={}));var _=class{static getFileFlag(e){return _.flagCache.has(e)||_.flagCache.set(e,new _(e)),_.flagCache.get(e)}constructor(e){if(this.flagStr=e,_.validFlagStrs.indexOf(e)<0)throw new c(l.EINVAL,"Invalid flag: "+e)}getFlagString(){return this.flagStr}getMode(){let e=0;return e<<=1,e+=+this.isReadable(),e<<=1,e+=+this.isWriteable(),e<<=1,e}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()?v.THROW_EXCEPTION:this.isTruncating()?v.TRUNCATE_FILE:v.NOP}pathNotExistsAction(){return(this.isWriteable()||this.isAppendable())&&this.flagStr!=="r+"?v.CREATE_FILE:v.THROW_EXCEPTION}};h(_,"FileFlag");_.flagCache=new Map;_.validFlagStrs=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"];var It=class{sync(){return P(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}syncSync(){throw new c(l.ENOTSUP)}datasync(){return P(this,void 0,void 0,function*(){return this.sync()})}datasyncSync(){return this.syncSync()}chown(e,t){return P(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}chownSync(e,t){throw new c(l.ENOTSUP)}chmod(e){return P(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}chmodSync(e){throw new c(l.ENOTSUP)}utimes(e,t){return P(this,void 0,void 0,function*(){throw new c(l.ENOTSUP)})}utimesSync(e,t){throw new c(l.ENOTSUP)}};h(It,"BaseFile");var L=class extends It{constructor(e,t,i,r,n){if(super(),this._pos=0,this._dirty=!1,this._fs=e,this._path=t,this._flag=i,this._stat=r,this._buffer=n||new Uint8Array(0),this._stat.size!==this._buffer.length&&this._flag.isReadable())throw new Error(`Invalid buffer: Uint8Array 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(e){return this._pos+=e}setPos(e){return this._pos=e}sync(){return P(this,void 0,void 0,function*(){this.syncSync()})}syncSync(){throw new c(l.ENOTSUP)}close(){return P(this,void 0,void 0,function*(){this.closeSync()})}closeSync(){throw new c(l.ENOTSUP)}stat(){return P(this,void 0,void 0,function*(){return O.clone(this._stat)})}statSync(){return O.clone(this._stat)}truncate(e){if(this.truncateSync(e),this._flag.isSynchronous()&&!_t("/").metadata.synchronous)return this.sync()}truncateSync(e){if(this._dirty=!0,!this._flag.isWriteable())throw new c(l.EPERM,"File not opened with a writeable mode.");if(this._stat.mtimeMs=Date.now(),e>this._buffer.length){let t=new Uint8Array(e-this._buffer.length);this.writeSync(t,0,t.length,this._buffer.length),this._flag.isSynchronous()&&_t("/").metadata.synchronous&&this.syncSync();return}this._stat.size=e,this._buffer=this._buffer.subarray(0,e),this._flag.isSynchronous()&&_t("/").metadata.synchronous&&this.syncSync()}write(e,t,i,r){return P(this,void 0,void 0,function*(){return this.writeSync(e,t,i,r)})}writeSync(e,t,i,r){if(this._dirty=!0,r==null&&(r=this.getPos()),!this._flag.isWriteable())throw new c(l.EPERM,"File not opened with a writeable mode.");let n=r+i;if(n>this._stat.size&&(this._stat.size=n,n>this._buffer.length)){let a=new Uint8Array(n);a.set(this._buffer),this._buffer=a}this._buffer.set(e.slice(t,t+i),r);let s=this._buffer.length;return this._stat.mtimeMs=Date.now(),this._flag.isSynchronous()?(this.syncSync(),s):(this.setPos(r+s),s)}read(e,t,i,r){return P(this,void 0,void 0,function*(){return{bytesRead:this.readSync(e,t,i,r),buffer:e}})}readSync(e,t,i,r){if(!this._flag.isReadable())throw new c(l.EPERM,"File not opened with a readable mode.");return r==null&&(r=this.getPos()),r+i>this._stat.size&&(i=this._stat.size-r),this._buffer.set(e.slice(t,t+i),r),this._stat.atimeMs=Date.now(),this._pos=r+i,this._buffer.length}chmod(e){return P(this,void 0,void 0,function*(){this.chmodSync(e)})}chmodSync(e){if(!this._fs.metadata.supportsProperties)throw new c(l.ENOTSUP);this._dirty=!0,this._stat.chmod(e),this.syncSync()}chown(e,t){return P(this,void 0,void 0,function*(){this.chownSync(e,t)})}chownSync(e,t){if(!this._fs.metadata.supportsProperties)throw new c(l.ENOTSUP);this._dirty=!0,this._stat.chown(e,t),this.syncSync()}isDirty(){return this._dirty}resetDirty(){this._dirty=!1}};h(L,"PreloadFile");var J=class extends L{constructor(e,t,i,r,n){super(e,t,i,r,n)}sync(){return P(this,void 0,void 0,function*(){})}syncSync(){}close(){return P(this,void 0,void 0,function*(){})}closeSync(){}};h(J,"NoSyncFile");var Ft=h((o="",e)=>{throw e.name==="NotFoundError"?c.ENOENT(o):e},"handleError"),ht=class extends L{constructor(e,t,i,r,n){super(e,t,i,r,n)}sync(){return S(this,null,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),k.Root),this.resetDirty())})}close(){return S(this,null,function*(){yield this.sync()})}};h(ht,"FileSystemAccessFile");var Tt=class extends T{constructor({handle:t}){super();this._handles=new Map;this._handles.set("/",t)}static isAvailable(){return typeof FileSystemHandle=="function"}get metadata(){return it($({},super.metadata),{name:Tt.Name})}_sync(t,i,r,n){return S(this,null,function*(){let s=yield this.stat(t,n);r.mtime!==s.mtime&&(yield this.writeFile(t,i,null,_.getFileFlag("w"),s.mode,n))})}rename(t,i,r){return S(this,null,function*(){try{let n=yield this.getHandle(t);if(n instanceof FileSystemDirectoryHandle){let s=yield this.readdir(t,r);if(yield this.mkdir(i,"wx",r),s.length===0)yield this.unlink(t,r);else for(let a of s)yield this.rename(C(t,a),C(i,a),r),yield this.unlink(t,r)}if(n instanceof FileSystemFileHandle){let s=yield n.getFile(),a=yield this.getHandle(g(i));if(a instanceof FileSystemDirectoryHandle){let f=yield(yield a.getFileHandle(I(i),{create:!0})).createWritable(),u=yield s.arrayBuffer();yield f.write(u),f.close(),yield this.unlink(t,r)}}}catch(n){Ft(t,n)}})}writeFile(t,i,r,n,s,a,d){return S(this,null,function*(){let f=yield this.getHandle(g(t));if(f instanceof FileSystemDirectoryHandle){let m=yield(yield f.getFileHandle(I(t),{create:!0})).createWritable();yield m.write(i),yield m.close()}})}createFile(t,i,r,n){return S(this,null,function*(){return yield this.writeFile(t,new Uint8Array,null,i,r,n,!0),this.openFile(t,i,n)})}stat(t,i){return S(this,null,function*(){let r=yield this.getHandle(t);if(!r)throw c.FileError(l.EINVAL,t);if(r instanceof FileSystemDirectoryHandle)return new O(E.DIRECTORY,4096);if(r instanceof FileSystemFileHandle){let{lastModified:n,size:s}=yield r.getFile();return new O(E.FILE,s,void 0,void 0,n)}})}exists(t,i){return S(this,null,function*(){try{return yield this.getHandle(t),!0}catch(r){return!1}})}openFile(t,i,r){return S(this,null,function*(){let n=yield this.getHandle(t);if(n instanceof FileSystemFileHandle){let s=yield n.getFile(),a=yield s.arrayBuffer();return this.newFile(t,i,a,s.size,s.lastModified)}})}unlink(t,i){return S(this,null,function*(){let r=yield this.getHandle(g(t));if(r instanceof FileSystemDirectoryHandle)try{yield r.removeEntry(I(t),{recursive:!0})}catch(n){Ft(t,n)}})}rmdir(t,i){return S(this,null,function*(){return this.unlink(t,i)})}mkdir(t,i,r){return S(this,null,function*(){let n=i&&i.flag&&i.flag.includes("w")&&!i.flag.includes("x");if((yield this.getHandle(t))&&!n)throw c.EEXIST(t);let a=yield this.getHandle(g(t));a instanceof FileSystemDirectoryHandle&&(yield a.getDirectoryHandle(I(t),{create:!0}))})}readdir(t,i){return S(this,null,function*(){let r=yield this.getHandle(t);if(!(r instanceof FileSystemDirectoryHandle))throw c.ENOTDIR(t);let n=[];try{for(var s=$t(r.keys()),a,d,f;a=!(d=yield s.next()).done;a=!1){let u=d.value;n.push(C(t,u))}}catch(d){f=[d]}finally{try{a&&(d=s.return)&&(yield d.call(s))}finally{if(f)throw f[0]}}return n})}newFile(t,i,r,n,s){return new ht(this,t,i,new O(E.FILE,n||0,void 0,void 0,s||new Date().getTime()),new Uint8Array(r))}getHandle(t){return S(this,null,function*(){if(this._handles.has(t))return this._handles.get(t);let i="/",[,...r]=t.split("/"),n=h(d=>S(this,[d],function*([s,...a]){let f=C(i,s),u=h(p=>{if(i=f,this._handles.set(i,p),a.length===0)return this._handles.get(t);n(a)},"continueWalk"),m=this._handles.get(i);try{return yield u(yield m.getDirectoryHandle(s))}catch(p){if(p.name==="TypeMismatchError")try{return yield u(yield m.getFileHandle(s))}catch(w){Ft(f,w)}else{if(p.message==="Name is not allowed.")throw new c(l.ENOENT,p.message,f);Ft(f,p)}}}),"getHandleParts");yield n(r)})}},G=Tt;h(G,"FileSystemAccessFileSystem"),G.Name="FileSystemAccess",G.Create=R.bind(Tt),G.Options={};var Qt=typeof fetch!="undefined"&&fetch!==null;function Dt(o){throw new c(l.EIO,o.message)}h(Dt,"convertError");function Lt(o,e){return S(this,null,function*(){let t=yield fetch(o).catch(Dt);if(!t.ok)throw new c(l.EIO,`fetch error: response returned code ${t.status}`);switch(e){case"buffer":let i=yield t.arrayBuffer().catch(Dt);return new Uint8Array(i);case"json":return t.json().catch(Dt);default:throw new c(l.EINVAL,"Invalid download type: "+e)}})}h(Lt,"fetchFile");function Zt(o){return S(this,null,function*(){let e=yield fetch(o,{method:"HEAD"}).catch(Dt);if(!e.ok)throw new c(l.EIO,`fetch HEAD error: response returned code ${e.status}`);return parseInt(e.headers.get("Content-Length")||"-1",10)})}h(Zt,"fetchFileSize");var Q=class{static fromListing(e){let t=new Q,i=new H;t._index["/"]=i;let r=[["",e,i]];for(;r.length>0;){let n,s=r.pop(),a=s[0],d=s[1],f=s[2];for(let u in d)if(Object.prototype.hasOwnProperty.call(d,u)){let m=d[u],p=`${a}/${u}`;m?(t._index[p]=n=new H,r.push([p,m,n])):n=new Pt(new O(E.FILE,-1,365)),f&&(f._ls[u]=n)}}return t}constructor(){this._index={},this.addPath("/",new H)}fileIterator(e){for(let t in this._index)if(Object.prototype.hasOwnProperty.call(this._index,t)){let i=this._index[t],r=i.getListing();for(let n of r){let s=i.getItem(n);ft(s)&&e(s.getData())}}}addPath(e,t){if(!t)throw new Error("Inode must be specified");if(e[0]!=="/")throw new Error("Path must be absolute, got: "+e);if(Object.prototype.hasOwnProperty.call(this._index,e))return this._index[e]===t;let i=this._split_path(e),r=i[0],n=i[1],s=this._index[r];return s===void 0&&e!=="/"&&(s=new H,!this.addPath(r,s))||e!=="/"&&!s.addItem(n,t)?!1:(ot(t)&&(this._index[e]=t),!0)}addPathFast(e,t){let i=e.lastIndexOf("/"),r=i===0?"/":e.substring(0,i),n=e.substring(i+1),s=this._index[r];return s===void 0&&(s=new H,this.addPathFast(r,s)),s.addItem(n,t)?(t.isDir()&&(this._index[e]=t),!0):!1}removePath(e){let t=this._split_path(e),i=t[0],r=t[1],n=this._index[i];if(n===void 0)return null;let s=n.remItem(r);if(s===null)return null;if(ot(s)){let a=s.getListing();for(let d of a)this.removePath(e+"/"+d);e!=="/"&&delete this._index[e]}return s}ls(e){let t=this._index[e];return t===void 0?null:t.getListing()}getInode(e){let t=this._split_path(e),i=t[0],r=t[1],n=this._index[i];return n===void 0?null:i===e?n:n.getItem(r)}_split_path(e){let t=g(e),i=e.slice(t.length+(t==="/"?0:1));return[t,i]}};h(Q,"FileIndex");var Pt=class{constructor(e){this.data=e}isFile(){return!0}isDir(){return!1}getData(){return this.data}setData(e){this.data=e}toStats(){return new O(E.FILE,4096,438)}};h(Pt,"IndexFileInode");var H=class{constructor(e=null){this.data=e,this._ls={}}isFile(){return!1}isDir(){return!0}getData(){return this.data}getStats(){return new O(E.DIRECTORY,4096,365)}toStats(){return this.getStats()}getListing(){return Object.keys(this._ls)}getItem(e){let t=this._ls[e];return t||null}addItem(e,t){return e in this._ls?!1:(this._ls[e]=t,!0)}remItem(e){let t=this._ls[e];return t===void 0?null:(delete this._ls[e],t)}};h(H,"IndexDirInode");function ft(o){return!!o&&o.isFile()}h(ft,"isIndexFileInode");function ot(o){return!!o&&o.isDir()}h(ot,"isIndexDirInode");var Ct=class extends T{constructor({index:t,baseUrl:i=""}){super();t||(t="index.json");let r=typeof t=="string"?Lt(t,"json"):Promise.resolve(t);this._ready=r.then(n=>(this._index=Q.fromListing(n),this)),i.length>0&&i.charAt(i.length-1)!=="/"&&(i=i+"/"),this.prefixUrl=i}static isAvailable(){return Qt}get metadata(){return it($({},super.metadata),{name:Ct.Name,readonly:!0})}empty(){this._index.fileIterator(function(t){t.fileData=null})}preloadFile(t,i){let r=this._index.getInode(t);if(ft(r)){if(r===null)throw c.ENOENT(t);let n=r.getData();n.size=i.length,n.fileData=i}else throw c.EISDIR(t)}stat(t,i){return S(this,null,function*(){let r=this._index.getInode(t);if(r===null)throw c.ENOENT(t);if(!r.toStats().hasAccess(4,i))throw c.EACCES(t);let n;if(ft(r))n=r.getData(),n.size<0&&(n.size=yield this._requestFileSize(t));else if(ot(r))n=r.getStats();else throw c.FileError(l.EINVAL,t);return n})}open(t,i,r,n){return S(this,null,function*(){if(i.isWriteable())throw new c(l.EPERM,t);let s=this._index.getInode(t);if(s===null)throw c.ENOENT(t);if(!s.toStats().hasAccess(i.getMode(),n))throw c.EACCES(t);if(ft(s)||ot(s))switch(i.pathExistsAction()){case v.THROW_EXCEPTION:case v.TRUNCATE_FILE:throw c.EEXIST(t);case v.NOP:if(ot(s)){let f=s.getStats();return new J(this,t,i,f,f.fileData||void 0)}let a=s.getData();if(a.fileData)return new J(this,t,i,O.clone(a),a.fileData);let d=yield this._requestFile(t,"buffer");return a.size=d.length,a.fileData=d,new J(this,t,i,O.clone(a),d);default:throw new c(l.EINVAL,"Invalid FileMode object.")}else throw c.EPERM(t)})}readdir(t,i){return S(this,null,function*(){return this.readdirSync(t,i)})}readFile(t,i,r,n){return S(this,null,function*(){let s=yield this.open(t,r,420,n);try{let d=s.getBuffer();return i?z(d):d}finally{yield s.close()}})}_getHTTPPath(t){return t.charAt(0)==="/"&&(t=t.slice(1)),this.prefixUrl+t}_requestFile(t,i){return Lt(this._getHTTPPath(t),i)}_requestFileSize(t){return Zt(this._getHTTPPath(t))}},Z=Ct;h(Z,"HTTPRequest"),Z.Name="HTTPRequest",Z.Create=R.bind(Ct),Z.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 N=function(o,e,t,i){function r(n){return n instanceof t?n:new t(function(s){s(n)})}return h(r,"adopt"),new(t||(t=Promise))(function(n,s){function a(u){try{f(i.next(u))}catch(m){s(m)}}h(a,"fulfilled");function d(u){try{f(i.throw(u))}catch(m){s(m)}}h(d,"rejected");function f(u){u.done?n(u.value):r(u.value).then(a,d)}h(f,"step"),f((i=i.apply(o,e||[])).next())})},mt=class{constructor(e,t){this.key=e,this.value=t,this.prev=null,this.next=null}};h(mt,"LRUNode");var Rt=class{constructor(e){this.limit=e,this.size=0,this.map={},this.head=null,this.tail=null}set(e,t){let i=new mt(e,t);this.map[e]?(this.map[e].value=i.value,this.remove(i.key)):this.size>=this.limit&&(delete this.map[this.tail.key],this.size--,this.tail=this.tail.prev,this.tail.next=null),this.setHead(i)}get(e){if(this.map[e]){let t=this.map[e].value,i=new mt(e,t);return this.remove(e),this.setHead(i),t}else return null}remove(e){let t=this.map[e];t&&(t.prev!==null?t.prev.next=t.next:this.head=t.next,t.next!==null?t.next.prev=t.prev:this.tail=t.prev,delete this.map[e],this.size--)}removeAll(){this.size=0,this.map={},this.head=null,this.tail=null}setHead(e){e.next=this.head,e.prev=null,this.head!==null&&(this.head.prev=e),this.head=e,this.tail===null&&(this.tail=e),this.size++,this.map[e.key]=e}};h(Rt,"LRUCache");var pt=class extends L{constructor(e,t,i,r,n){super(e,t,i,r,n)}sync(){return N(this,void 0,void 0,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())})}close(){return N(this,void 0,void 0,function*(){this.sync()})}};h(pt,"AsyncKeyValueFile");var yt=class extends T{static isAvailable(){return!0}constructor(e){super(),this._cache=null,e>0&&(this._cache=new Rt(e))}init(e){return N(this,void 0,void 0,function*(){this.store=e,yield this.makeRootDirectory()})}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!1}empty(){return N(this,void 0,void 0,function*(){this._cache&&this._cache.removeAll(),yield this.store.clear(),yield this.makeRootDirectory()})}access(e,t,i){return N(this,void 0,void 0,function*(){let r=this.store.beginTransaction("readonly"),n=yield this.findINode(r,e);if(!n)throw c.ENOENT(e);if(!n.toStats().hasAccess(t,i))throw c.EACCES(e)})}rename(e,t,i){return N(this,void 0,void 0,function*(){let r=this._cache;this._cache&&(this._cache=null,r.removeAll());try{let n=this.store.beginTransaction("readwrite"),s=g(e),a=I(e),d=g(t),f=I(t),u=yield this.findINode(n,s),m=yield this.getDirListing(n,s,u);if(!u.toStats().hasAccess(2,i))throw c.EACCES(e);if(!m[a])throw c.ENOENT(e);let p=m[a];if(delete m[a],(d+"/").indexOf(e+"/")===0)throw new c(l.EBUSY,s);let w,x;if(d===s?(w=u,x=m):(w=yield this.findINode(n,d),x=yield this.getDirListing(n,d,w)),x[f]){let B=yield this.getINode(n,t,x[f]);if(B.isFile())try{yield n.del(B.id),yield n.del(x[f])}catch(ct){throw yield n.abort(),ct}else throw c.EPERM(t)}x[f]=p;try{yield n.put(u.id,b(JSON.stringify(m)),!0),yield n.put(w.id,b(JSON.stringify(x)),!0)}catch(B){throw yield n.abort(),B}yield n.commit()}finally{r&&(this._cache=r)}})}stat(e,t){return N(this,void 0,void 0,function*(){let i=this.store.beginTransaction("readonly"),n=(yield this.findINode(i,e)).toStats();if(!n.hasAccess(4,t))throw c.EACCES(e);return n})}createFile(e,t,i,r){return N(this,void 0,void 0,function*(){let n=this.store.beginTransaction("readwrite"),s=new Uint8Array(0),a=yield this.commitNewFile(n,e,E.FILE,i,r,s);return new pt(this,e,t,a.toStats(),s)})}openFile(e,t,i){return N(this,void 0,void 0,function*(){let r=this.store.beginTransaction("readonly"),n=yield this.findINode(r,e),s=yield r.get(n.id);if(!n.toStats().hasAccess(t.getMode(),i))throw c.EACCES(e);if(s===void 0)throw c.ENOENT(e);return new pt(this,e,t,n.toStats(),s)})}unlink(e,t){return N(this,void 0,void 0,function*(){return this.removeEntry(e,!1,t)})}rmdir(e,t){return N(this,void 0,void 0,function*(){if((yield this.readdir(e,t)).length>0)throw c.ENOTEMPTY(e);yield this.removeEntry(e,!0,t)})}mkdir(e,t,i){return N(this,void 0,void 0,function*(){let r=this.store.beginTransaction("readwrite"),n=b("{}");yield this.commitNewFile(r,e,E.DIRECTORY,t,i,n)})}readdir(e,t){return N(this,void 0,void 0,function*(){let i=this.store.beginTransaction("readonly"),r=yield this.findINode(i,e);if(!r.toStats().hasAccess(4,t))throw c.EACCES(e);return Object.keys(yield this.getDirListing(i,e,r))})}chmod(e,t,i){return N(this,void 0,void 0,function*(){yield(yield this.openFile(e,_.getFileFlag("r+"),i)).chmod(t)})}chown(e,t,i,r){return N(this,void 0,void 0,function*(){yield(yield this.openFile(e,_.getFileFlag("r+"),r)).chown(t,i)})}_sync(e,t,i){return N(this,void 0,void 0,function*(){let r=this.store.beginTransaction("readwrite"),n=yield this._findINode(r,g(e),I(e)),s=yield this.getINode(r,e,n),a=s.update(i);try{yield r.put(s.id,t,!0),a&&(yield r.put(n,s.serialize(),!0))}catch(d){throw yield r.abort(),d}yield r.commit()})}makeRootDirectory(){return N(this,void 0,void 0,function*(){let e=this.store.beginTransaction("readwrite");if((yield e.get(A))===void 0){let t=new Date().getTime(),i=new D(nt(),4096,511|E.DIRECTORY,t,t,t,0,0);yield e.put(i.id,b("{}"),!1),yield e.put(A,i.serialize(),!1),yield e.commit()}})}_findINode(e,t,i,r=new Set){return N(this,void 0,void 0,function*(){let n=C(t,i);if(r.has(n))throw new c(l.EIO,"Infinite loop detected while finding inode",n);if(r.add(n),this._cache){let s=this._cache.get(n);if(s)return s}if(t==="/"){if(i==="")return this._cache&&this._cache.set(n,A),A;{let s=yield this.getINode(e,t,A),a=yield this.getDirListing(e,t,s);if(a[i]){let d=a[i];return this._cache&&this._cache.set(n,d),d}else throw c.ENOENT(Y(t,i))}}else{let s=yield this.findINode(e,t,r),a=yield this.getDirListing(e,t,s);if(a[i]){let d=a[i];return this._cache&&this._cache.set(n,d),d}else throw c.ENOENT(Y(t,i))}})}findINode(e,t,i=new Set){return N(this,void 0,void 0,function*(){let r=yield this._findINode(e,g(t),I(t),i);return this.getINode(e,t,r)})}getINode(e,t,i){return N(this,void 0,void 0,function*(){let r=yield e.get(i);if(!r)throw c.ENOENT(t);return D.Deserialize(r)})}getDirListing(e,t,i){return N(this,void 0,void 0,function*(){if(!i.isDirectory())throw c.ENOTDIR(t);let r=yield e.get(i.id);try{return JSON.parse(r.toString())}catch(n){throw c.ENOENT(t)}})}addNewNode(e,t){return N(this,void 0,void 0,function*(){let i=0,r=h(()=>N(this,void 0,void 0,function*(){if(++i===5)throw new c(l.EIO,"Unable to commit data to key-value store.");{let n=nt();return(yield e.put(n,t,!1))?n:r()}}),"reroll");return r()})}commitNewFile(e,t,i,r,n,s){return N(this,void 0,void 0,function*(){let a=g(t),d=I(t),f=yield this.findINode(e,a),u=yield this.getDirListing(e,a,f),m=new Date().getTime();if(!f.toStats().hasAccess(2,n))throw c.EACCES(t);if(t==="/")throw c.EEXIST(t);if(u[d])throw yield e.abort(),c.EEXIST(t);try{let p=yield this.addNewNode(e,s),w=new D(p,s.length,r|i,m,m,m,n.uid,n.gid),x=yield this.addNewNode(e,w.serialize());return u[d]=x,yield e.put(f.id,b(JSON.stringify(u)),!0),yield e.commit(),w}catch(p){throw e.abort(),p}})}removeEntry(e,t,i){return N(this,void 0,void 0,function*(){this._cache&&this._cache.remove(e);let r=this.store.beginTransaction("readwrite"),n=g(e),s=yield this.findINode(r,n),a=yield this.getDirListing(r,n,s),d=I(e);if(!a[d])throw c.ENOENT(e);let f=a[d],u=yield this.getINode(r,e,f);if(!u.toStats().hasAccess(2,i))throw c.EACCES(e);if(delete a[d],!t&&u.isDirectory())throw c.EISDIR(e);if(t&&!u.isDirectory())throw c.ENOTDIR(e);try{yield r.del(u.id),yield r.del(f),yield r.put(s.id,b(JSON.stringify(a)),!0)}catch(m){throw yield r.abort(),m}yield r.commit()})}};h(yt,"AsyncKeyValueFileSystem");function wt(o,e=o.toString()){switch(o.name){case"NotFoundError":return new c(l.ENOENT,e);case"QuotaExceededError":return new c(l.ENOSPC,e);default:return new c(l.EIO,e)}}h(wt,"convertError");function Et(o,e=l.EIO,t=null){return function(i){i.preventDefault(),o(new c(e,t!==null?t:void 0))}}h(Et,"onErrorHandler");var at=class{constructor(e,t){this.tx=e;this.store=t}get(e){return new Promise((t,i)=>{try{let r=this.store.get(e);r.onerror=Et(i),r.onsuccess=n=>{let s=n.target.result;t(s===void 0?s:Uint8Array.from(s))}}catch(r){i(wt(r))}})}};h(at,"IndexedDBROTransaction");var gt=class extends at{constructor(e,t){super(e,t)}put(e,t,i){return new Promise((r,n)=>{try{let s=i?this.store.put(t,e):this.store.add(t,e);s.onerror=Et(n),s.onsuccess=()=>{r(!0)}}catch(s){n(wt(s))}})}del(e){return new Promise((t,i)=>{try{let r=this.store.delete(e);r.onerror=Et(i),r.onsuccess=()=>{t()}}catch(r){i(wt(r))}})}commit(){return new Promise(e=>{setTimeout(e,0)})}abort(){return new Promise((e,t)=>{try{this.tx.abort(),e()}catch(i){t(wt(i))}})}};h(gt,"IndexedDBRWTransaction");var tt=class{constructor(e,t){this.db=e;this.storeName=t}static Create(e,t){return new Promise((i,r)=>{let n=t.open(e,1);n.onupgradeneeded=s=>{let a=s.target.result;a.objectStoreNames.contains(e)&&a.deleteObjectStore(e),a.createObjectStore(e)},n.onsuccess=s=>{i(new tt(s.target.result,e))},n.onerror=Et(r,l.EACCES)})}name(){return j.Name+" - "+this.storeName}clear(){return new Promise((e,t)=>{try{let i=this.db.transaction(this.storeName,"readwrite"),r=i.objectStore(this.storeName),n=r.clear();n.onsuccess=()=>{setTimeout(e,0)},n.onerror=Et(t)}catch(i){t(wt(i))}})}beginTransaction(e="readonly"){let t=this.db.transaction(this.storeName,e),i=t.objectStore(this.storeName);if(e==="readwrite")return new gt(t,i);if(e==="readonly")return new at(t,i);throw new c(l.EINVAL,"Invalid transaction type.")}};h(tt,"IndexedDBStore");var Mt=class extends yt{static isAvailable(e=globalThis.indexedDB){try{if(!(e instanceof IDBFactory)||!e.open("__zenfs_test__"))return!1}catch(t){return!1}}constructor({cacheSize:e=100,storeName:t="zenfs",idbFactory:i=globalThis.indexedDB}){super(e),this._ready=tt.Create(t,i).then(r=>(this.init(r),this))}},j=Mt;h(j,"IndexedDBFileSystem"),j.Name="IndexedDB",j.Create=R.bind(Mt),j.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 St=class{constructor(e){this._storage=e}name(){return V.Name}clear(){this._storage.clear()}beginTransaction(e){return new q(this)}get(e){let t=this._storage.getItem(e);if(typeof t=="string")return b(t)}put(e,t,i){try{return!i&&this._storage.getItem(e)!==null?!1:(this._storage.setItem(e,t.toString()),!0)}catch(r){throw new c(l.ENOSPC,"Storage is full.")}}del(e){try{this._storage.removeItem(e)}catch(t){throw new c(l.EIO,"Unable to delete key "+e+": "+t)}}};h(St,"StorageStore");var zt=class extends X{static isAvailable(e=globalThis.localStorage){return e instanceof Storage}constructor({storage:e=globalThis.localStorage}){super({store:new St(e)})}},V=zt;h(V,"StorageFileSystem"),V.Name="Storage",V.Create=R.bind(zt),V.Options={storage:{type:"object",optional:!0,description:"The Storage to use. Defaults to globalThis.localStorage."}};function fe(o){return typeof o=="object"&&"isBFS"in o&&!!o.isBFS}h(fe,"isRPCMessage");var At=class extends T{constructor({worker:t}){super();this._currentID=0;this._requests=new Map;this._isInitialized=!1;this._worker=t,this._worker.onmessage=i=>{if(!fe(i.data))return;let{id:r,method:n,value:s}=i.data;if(n==="metadata"){this._metadata=s,this._isInitialized=!0;return}let{resolve:a,reject:d}=this._requests.get(r);if(this._requests.delete(r),s instanceof Error||s instanceof c){d(s);return}a(s)}}static isAvailable(){return typeof importScripts!="undefined"||typeof Worker!="undefined"}get metadata(){return it($($({},super.metadata),this._metadata),{name:At.Name,synchronous:!1})}_rpc(t,...i){return S(this,null,function*(){return new Promise((r,n)=>{let s=this._currentID++;this._requests.set(s,{resolve:r,reject:n}),this._worker.postMessage({isBFS:!0,id:s,method:t,args:i})})})}rename(t,i,r){return this._rpc("rename",t,i,r)}stat(t,i){return this._rpc("stat",t,i)}open(t,i,r,n){return this._rpc("open",t,i,r,n)}unlink(t,i){return this._rpc("unlink",t,i)}rmdir(t,i){return this._rpc("rmdir",t,i)}mkdir(t,i,r){return this._rpc("mkdir",t,i,r)}readdir(t,i){return this._rpc("readdir",t,i)}exists(t,i){return this._rpc("exists",t,i)}realpath(t,i){return this._rpc("realpath",t,i)}truncate(t,i,r){return this._rpc("truncate",t,i,r)}readFile(t,i,r,n){return this._rpc("readFile",t,i,r,n)}writeFile(t,i,r,n,s,a){return this._rpc("writeFile",t,i,r,n,s,a)}appendFile(t,i,r,n,s,a){return this._rpc("appendFile",t,i,r,n,s,a)}chmod(t,i,r){return this._rpc("chmod",t,i,r)}chown(t,i,r,n){return this._rpc("chown",t,i,r,n)}utimes(t,i,r,n){return this._rpc("utimes",t,i,r,n)}link(t,i,r){return this._rpc("link",t,i,r)}symlink(t,i,r,n){return this._rpc("symlink",t,i,r,n)}readlink(t,i){return this._rpc("readlink",t,i)}syncClose(t,i){return this._rpc("syncClose",t,i)}},et=At;h(et,"WorkerFS"),et.Name="WorkerFS",et.Create=R.bind(At),et.Options={worker:{type:"object",description:"The target worker that you want to connect to, or the current worker if in a worker context.",validator(t){if(typeof(t==null?void 0:t.postMessage)!="function")throw new c(l.EINVAL,"option must be a Web Worker instance.")}}};return ae(me);})();
|
|
9
4
|
//# sourceMappingURL=browser.min.js.map
|