From 5fa13625a1ca0ea1a3a1c5bb86d0880dcfac349f Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Wed, 21 Jun 2023 23:38:18 -0700 Subject: upgrade zig to `v0.11.0-dev.3737+9eb008717` (#3374) * progress * finish `@memset/@memcpy` update * Update build.zig * change `@enumToInt` to `@intFromEnum` and friends * update zig versions * it was 1 * add link to issue * add `compileError` reminder * fix merge * format * upgrade to llvm 16 * Revert "upgrade to llvm 16" This reverts commit cc930ceb1c5b4db9614a7638596948f704544ab8. --------- Co-authored-by: Jarred Sumner Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/webcore/blob.zig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/bun.js/webcore/blob.zig') diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index 9b3ddb8df..d19a2da26 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -546,7 +546,7 @@ pub const Blob = struct { return JSPromise.resolvedPromiseValue(ctx.ptr(), cloned.toJS(ctx)).asObjectRef(); } else if (destination_type == .bytes and source_type == .file) { var fake_call_frame: [8]JSC.JSValue = undefined; - @memset(@ptrCast([*]u8, &fake_call_frame), 0, @sizeOf(@TypeOf(fake_call_frame))); + @memset(@ptrCast([*]u8, &fake_call_frame)[0..@sizeOf(@TypeOf(fake_call_frame))], 0); const blob_value = source_blob.getSlice(ctx, @ptrCast(*JSC.CallFrame, &fake_call_frame)); @@ -1232,7 +1232,7 @@ pub const Blob = struct { }).toSystemError(); // assert we never end up reusing the memory - std.debug.assert(@ptrToInt(this.system_error.?.path.slice().ptr) != @ptrToInt(path_buffer)); + std.debug.assert(@intFromPtr(this.system_error.?.path.slice().ptr) != @intFromPtr(path_buffer)); callback(this, null_fd); return; @@ -1739,12 +1739,12 @@ pub const Blob = struct { }; const unsupported_directory_error = SystemError{ - .errno = @intCast(c_int, @enumToInt(bun.C.SystemErrno.EISDIR)), + .errno = @intCast(c_int, @intFromEnum(bun.C.SystemErrno.EISDIR)), .message = ZigString.init("That doesn't work on folders"), .syscall = ZigString.init("fstat"), }; const unsupported_non_regular_file_error = SystemError{ - .errno = @intCast(c_int, @enumToInt(bun.C.SystemErrno.ENOTSUP)), + .errno = @intCast(c_int, @intFromEnum(bun.C.SystemErrno.ENOTSUP)), .message = ZigString.init("Non-regular files aren't supported yet"), .syscall = ZigString.init("fstat"), }; @@ -1978,14 +1978,14 @@ pub const Blob = struct { } this.system_error = (JSC.Node.Syscall.Error{ - .errno = @intCast(JSC.Node.Syscall.Error.Int, @enumToInt(linux.E.INVAL)), + .errno = @intCast(JSC.Node.Syscall.Error.Int, @intFromEnum(linux.E.INVAL)), .syscall = TryWith.tag.get(use).?, }).toSystemError(); return AsyncIO.asError(linux.E.INVAL); }, else => |errno| { this.system_error = (JSC.Node.Syscall.Error{ - .errno = @intCast(JSC.Node.Syscall.Error.Int, @enumToInt(errno)), + .errno = @intCast(JSC.Node.Syscall.Error.Int, @intFromEnum(errno)), .syscall = TryWith.tag.get(use).?, }).toSystemError(); return AsyncIO.asError(errno); @@ -2000,7 +2000,7 @@ pub const Blob = struct { } pub fn doFCopyFile(this: *CopyFile) anyerror!void { - switch (JSC.Node.Syscall.fcopyfile(this.source_fd, this.destination_fd, os.system.COPYFILE_DATA)) { + switch (JSC.Node.Syscall.fcopyfile(this.source_fd, this.destination_fd, os.system.COPYFILE.DATA)) { .err => |errno| { this.system_error = errno.toSystemError(); @@ -3816,10 +3816,10 @@ pub const InlineBlob = extern struct { var bytes_slice = inline_blob.bytes[0..total]; if (first.len > 0) - @memcpy(bytes_slice.ptr, first.ptr, first.len); + @memcpy(bytes_slice[0..first.len], first); if (second.len > 0) - @memcpy(bytes_slice.ptr + first.len, second.ptr, second.len); + @memcpy(bytes_slice[first.len..][0..second.len], second); inline_blob.len = @truncate(@TypeOf(inline_blob.len), total); return inline_blob; @@ -3834,7 +3834,7 @@ pub const InlineBlob = extern struct { }; if (data.len > 0) - @memcpy(&blob.bytes, data.ptr, data.len); + @memcpy(blob.bytes[0..data.len], data); return blob; } -- cgit v1.2.3 From ff635551436123022ba3980b39580d53973c80a2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 24 Jun 2023 06:02:16 -0700 Subject: Rewrite Bun's runtime CommonJS loader (#3379) * wip changes for CommonJS * this rewrite is almost complete * even more code * wip * Remove usages of `import.meta.require` from builtins * Remove usages of require * Regenerate * :scissors: builtin rewrite commonjs in printer * Use lazy custom getters for import.meta * fixups * Remove depd * ugh * still crashing * fixup undici * comment out import.meta.require.resolve temporarily not a real solution but it stops the crashes * Redo import.meta.primordials * Builtins now have a `builtin://` protocol in source origin * Seems to work? * Finsih getting rid of primordials * switcharoo * No more function * just one more bug * Update launch.json * Implement `require.main` * :scissors: * Bump WebKit * Fixup import cycles * Fixup improt cycles * export more things * Implement `createCommonJSModule` builtin * More exports * regenerate * i broke some stuff * some of these tests work now * We lost the encoding * Sort of fix zlib * Sort of fix util * Update events.js * bump * bump * bump * Fix missing export in fs * fix some bugs with builtin esm modules (stream, worker_threads, events). its not perfect yet. * fix some other internal module bugs * oops * fix some extra require default stuff * uncomment this file but it crsahes on my machine * tidy code here * fixup tls exports * make simdutf happier * Add hasPrefix binding * Add test for `require.main` * Fix CommonJS evaluation order race condition * Make node:http load faster * Add missing exports to tls.js * Use the getter * Regenerate builtins * Fix assertion failure in Bun.write() * revamp dotEnv parser (#3347) - fixes `strings.indexOfAny()` - fixes OOB array access fixes #411 fixes #2823 fixes #3042 * fix tests for `expect()` (#3384) - extend test job time-out for `darwin-aarch64` * `expect().resolves` and `expect().rejects` (#3318) * Move expect and snapshots to their own files * expect().resolves and expect().rejects * Fix promise being added to unhandled rejection list * Handle timeouts in expect() * wip merge * Fix merge issue --------- Co-authored-by: Jarred Sumner Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> * fixup min/memcopy (#3388) * Fix crash in builtins * Don't attempt to evaluate modules with no source code * Update WebCoreJSBuiltins.cpp * Update WebCoreJSBuiltins.cpp * Update WebCoreJSBuiltins.cpp * Fix crash * cleanup * Fix test cc @paperdave * Fixup Undici * Fix issue in node:http * Create util-deprecate.mjs * Fix several bugs * Use the identifier * Support error.code in `util.deprecate` * make the CJs loader slightly more resilient * Update WebCoreJSBuiltins.cpp * Fix macros --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: dave caruso Co-authored-by: Alex Lam S.L Co-authored-by: Ashcon Partovi Co-authored-by: Ciro Spaciari --- .github/workflows/bun-linux-aarch64.yml | 2 +- .github/workflows/bun-linux-build.yml | 4 +- .github/workflows/bun-mac-aarch64.yml | 16 +- .github/workflows/bun-mac-x64-baseline.yml | 16 +- .github/workflows/bun-mac-x64.yml | 16 +- Dockerfile | 2 +- Makefile | 3 + bench/snippets/util-deprecate.mjs | 60 + bun.lockb | Bin 63661 -> 72925 bytes package.json | 2 +- src/bun.js/bindings/BunString.cpp | 5 + src/bun.js/bindings/CommonJSModuleRecord.cpp | 994 ++++++++++------ src/bun.js/bindings/CommonJSModuleRecord.h | 78 +- src/bun.js/bindings/ImportMetaObject.cpp | 484 +++++--- src/bun.js/bindings/ImportMetaObject.h | 100 +- src/bun.js/bindings/ModuleLoader.cpp | 131 ++- src/bun.js/bindings/ModuleLoader.h | 9 + src/bun.js/bindings/ZigGlobalObject.cpp | 143 +-- src/bun.js/bindings/ZigGlobalObject.h | 9 +- src/bun.js/bindings/ZigSourceProvider.cpp | 38 +- src/bun.js/bindings/ZigSourceProvider.h | 2 +- src/bun.js/bindings/bindings.cpp | 43 +- src/bun.js/bindings/node_util_types.cpp | 2 +- .../bindings/webcore/DOMClientIsoSubspaces.h | 1 + src/bun.js/bindings/webcore/DOMIsoSubspaces.h | 1 + src/bun.js/module_loader.zig | 17 +- src/bun.js/modules/BufferModule.h | 11 +- src/bun.js/modules/ProcessModule.h | 31 +- src/bun.js/modules/StringDecoderModule.h | 11 +- src/bun.js/modules/TTYModule.h | 13 +- src/bun.js/webcore/blob.zig | 67 +- src/js/builtins/BunBuiltinNames.h | 25 +- src/js/builtins/ImportMetaObject.ts | 205 ++-- src/js/builtins/Module.ts | 94 ++ src/js/builtins/builtins.d.ts | 6 +- src/js/builtins/tsconfig.json | 8 +- src/js/node/assert.js | 45 +- src/js/node/async_hooks.js | 5 +- src/js/node/child_process.js | 37 +- src/js/node/crypto.js | 88 +- src/js/node/dns.promises.js | 2 +- src/js/node/events.js | 23 +- src/js/node/fs.js | 31 +- src/js/node/http.js | 42 +- src/js/node/https.js | 3 +- src/js/node/net.js | 6 +- src/js/node/path.js | 1 - src/js/node/readline.js | 10 +- src/js/node/readline.promises.js | 6 +- src/js/node/stream.consumers.js | 2 +- src/js/node/stream.js | 89 +- src/js/node/stream.promises.js | 4 +- src/js/node/timers.promises.js | 1 + src/js/node/tls.js | 66 +- src/js/node/url.js | 1193 ++++++++++++++------ src/js/node/util.js | 126 ++- src/js/node/zlib.js | 110 +- src/js/out/WebCoreJSBuiltins.cpp | 194 ++-- src/js/out/WebCoreJSBuiltins.h | 103 ++ src/js/out/modules/node/assert.js | 82 +- src/js/out/modules/node/assert.strict.js | 2 +- src/js/out/modules/node/async_hooks.js | 3 +- src/js/out/modules/node/child_process.js | 21 +- src/js/out/modules/node/cluster.js | 2 +- src/js/out/modules/node/crypto.js | 8 +- src/js/out/modules/node/dns.promises.js | 3 +- src/js/out/modules/node/events.js | 16 +- src/js/out/modules/node/fs.js | 30 +- src/js/out/modules/node/http.js | 39 +- src/js/out/modules/node/https.js | 4 +- src/js/out/modules/node/inspector.js | 2 +- src/js/out/modules/node/net.js | 6 +- src/js/out/modules/node/path.js | 2 +- src/js/out/modules/node/path.posix.js | 2 +- src/js/out/modules/node/readline.js | 6 +- src/js/out/modules/node/readline.promises.js | 10 +- src/js/out/modules/node/stream.consumers.js | 2 +- src/js/out/modules/node/stream.js | 4 +- src/js/out/modules/node/stream.promises.js | 2 +- src/js/out/modules/node/timers.promises.js | 4 +- src/js/out/modules/node/tls.js | 52 +- src/js/out/modules/node/url.js | 512 +++++---- src/js/out/modules/node/util.js | 138 +-- src/js/out/modules/node/zlib.js | 211 ++-- src/js/out/modules/thirdparty/depd.js | 66 +- src/js/out/modules/thirdparty/undici.js | 33 +- src/js/out/modules/thirdparty/ws.js | 4 +- src/js/thirdparty/depd.js | 118 +- src/js/thirdparty/undici.js | 76 +- src/js/thirdparty/ws.js | 2 +- src/js_parser.zig | 89 +- src/js_printer.zig | 73 +- src/string.zig | 9 + src/string_immutable.zig | 3 +- test/bun.lockb | Bin 86272 -> 95035 bytes test/bundler/esbuild/default.test.ts | 17 +- test/cli/run/require-cache-fixture-b.cjs | 5 + test/cli/run/require-cache-fixture.cjs | 5 + test/js/bun/eventsource/eventsource.test.ts | 284 ++--- test/js/bun/resolve/import-meta.test.js | 2 +- test/js/node/assert/assert-test.test.ts | 11 - test/js/node/assert/assert.test.cjs | 9 + test/js/node/assert/assert.test.ts | 11 + test/js/node/disabled-module.test.cjs | 6 + test/js/node/disabled-module.test.js | 19 +- test/js/node/events/event-emitter.test.ts | 7 + test/js/node/events/events-cjs.test.js | 4 + test/js/node/path/path.test.js | 2 +- test/js/node/process/print-process-args.js | 8 + test/js/node/process/process.test.js | 3 +- test/js/node/stubs.test.js | 3 + test/js/node/util/test-util-types.test.js | 32 +- test/package.json | 2 +- 113 files changed, 4188 insertions(+), 2714 deletions(-) create mode 100644 bench/snippets/util-deprecate.mjs create mode 100644 src/js/builtins/Module.ts delete mode 100644 test/js/node/assert/assert-test.test.ts create mode 100644 test/js/node/assert/assert.test.cjs create mode 100644 test/js/node/assert/assert.test.ts create mode 100644 test/js/node/disabled-module.test.cjs create mode 100644 test/js/node/events/events-cjs.test.js (limited to 'src/bun.js/webcore/blob.zig') diff --git a/.github/workflows/bun-linux-aarch64.yml b/.github/workflows/bun-linux-aarch64.yml index 39bfbc413..9bee835b7 100644 --- a/.github/workflows/bun-linux-aarch64.yml +++ b/.github/workflows/bun-linux-aarch64.yml @@ -36,7 +36,7 @@ jobs: arch: aarch64 build_arch: arm64 runner: linux-arm64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-linux-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-linux-arm64-lto.tar.gz" webkit_basename: "bun-webkit-linux-arm64-lto" build_machine_arch: aarch64 diff --git a/.github/workflows/bun-linux-build.yml b/.github/workflows/bun-linux-build.yml index 603c0ad3d..8689d488e 100644 --- a/.github/workflows/bun-linux-build.yml +++ b/.github/workflows/bun-linux-build.yml @@ -46,7 +46,7 @@ jobs: arch: x86_64 build_arch: amd64 runner: big-ubuntu - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" build_machine_arch: x86_64 - cpu: nehalem @@ -54,7 +54,7 @@ jobs: arch: x86_64 build_arch: amd64 runner: big-ubuntu - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" build_machine_arch: x86_64 diff --git a/.github/workflows/bun-mac-aarch64.yml b/.github/workflows/bun-mac-aarch64.yml index e4d93f206..3040eee43 100644 --- a/.github/workflows/bun-mac-aarch64.yml +++ b/.github/workflows/bun-mac-aarch64.yml @@ -117,7 +117,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: haswell @@ -126,7 +126,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: nehalem @@ -135,7 +135,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: haswell @@ -144,7 +144,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: native @@ -152,7 +152,7 @@ jobs: tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 dependencies: true compile_obj: true @@ -257,7 +257,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -265,14 +265,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" - cpu: native arch: aarch64 tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 package: bun-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64-baseline.yml b/.github/workflows/bun-mac-x64-baseline.yml index c7a021c66..dea617b21 100644 --- a/.github/workflows/bun-mac-x64-baseline.yml +++ b/.github/workflows/bun-mac-x64-baseline.yml @@ -117,7 +117,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: haswell @@ -126,7 +126,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: nehalem @@ -135,7 +135,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: haswell @@ -144,7 +144,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: native @@ -152,7 +152,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -258,7 +258,7 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -266,14 +266,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64.yml b/.github/workflows/bun-mac-x64.yml index d8402d95d..2f2143ab1 100644 --- a/.github/workflows/bun-mac-x64.yml +++ b/.github/workflows/bun-mac-x64.yml @@ -117,7 +117,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: haswell @@ -126,7 +126,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: nehalem @@ -135,7 +135,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: haswell @@ -144,7 +144,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: native @@ -152,7 +152,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -260,7 +260,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" - cpu: haswell arch: x86_64 tag: bun-darwin-x64 @@ -268,14 +268,14 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-1/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index 19d071e93..b4a76208f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ ARG ARCH=x86_64 ARG BUILD_MACHINE_ARCH=x86_64 ARG TRIPLET=${ARCH}-linux-gnu ARG BUILDARCH=amd64 -ARG WEBKIT_TAG=may20 +ARG WEBKIT_TAG=may20-1 ARG ZIG_TAG=jul1 ARG ZIG_VERSION="0.11.0-dev.3737+9eb008717" ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH" diff --git a/Makefile b/Makefile index deb4a5c6e..18e229903 100644 --- a/Makefile +++ b/Makefile @@ -561,6 +561,9 @@ builtins: esm: NODE_ENV=production bun src/js/build-esm.ts +esm-debug: + BUN_DEBUG_QUIET_LOGS=1 NODE_ENV=production bun-debug src/js/build-esm.ts + .PHONY: generate-builtins generate-builtins: builtins diff --git a/bench/snippets/util-deprecate.mjs b/bench/snippets/util-deprecate.mjs new file mode 100644 index 000000000..364601d79 --- /dev/null +++ b/bench/snippets/util-deprecate.mjs @@ -0,0 +1,60 @@ +import { bench, run } from "./runner.mjs"; +function deprecateUsingClosure(fn, msg, code) { + if (process.noDeprecation === true) { + return fn; + } + + var realFn = fn; + var wrapper = () => { + return fnToWrap.apply(this, arguments); + }; + + var deprecater = () => { + if (process.throwDeprecation) { + var err = new Error(msg); + if (code) err.code = code; + throw err; + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + + fnToWrap = realFn; + return realFn.apply(this, arguments); + }; + var fnToWrap = deprecater; + + return wrapper; +} + +function deprecateOriginal(fn, msg) { + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + return deprecated; +} + +const deprecatedy = deprecateUsingClosure(() => {}, "This is deprecated", "DEP0001"); +const deprecatedy2 = deprecateOriginal(() => {}, "This is deprecated"); + +bench("deprecateUsingClosure", () => { + deprecatedy(Math.random() + 1); +}); + +bench("deprecateOriginal", () => { + deprecatedy2(Math.random() + 1); +}); + +await run(); diff --git a/bun.lockb b/bun.lockb index 42721afe8..2c2b03711 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index a5cc3ee64..94f9968ea 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@types/react": "^18.0.25", "@typescript-eslint/eslint-plugin": "^5.31.0", "@typescript-eslint/parser": "^5.31.0", - "bun-webkit": "0.0.1-b2f1006a06f81bc860c89dd4c7cec3e7117c4c4c" + "bun-webkit": "0.0.1-4b3750ddfe644a5bb131d652407653fac528ad51" }, "version": "0.0.0", "prettier": "./.prettierrc.cjs" diff --git a/src/bun.js/bindings/BunString.cpp b/src/bun.js/bindings/BunString.cpp index f737342f4..f590edd35 100644 --- a/src/bun.js/bindings/BunString.cpp +++ b/src/bun.js/bindings/BunString.cpp @@ -7,6 +7,11 @@ #include "GCDefferalContext.h" using namespace JSC; +extern "C" bool Bun__WTFStringImpl__hasPrefix(const WTF::StringImpl* impl, const char* bytes, size_t length) +{ + return impl->startsWith(bytes, length); +} + extern "C" void Bun__WTFStringImpl__deref(WTF::StringImpl* impl) { impl->deref(); diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index 1cee1091b..8d4fe0a1e 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -59,458 +59,782 @@ #include #include +#include "ModuleLoader.h" #include #include #include #include "ZigSourceProvider.h" +#include "JavaScriptCore/FunctionPrototype.h" +#include "CommonJSModuleRecord.h" +#include +#include +#include namespace Bun { using namespace JSC; -class JSCommonJSModule final : public JSC::JSNonFinalObject { -public: - using Base = JSC::JSNonFinalObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::OverridesPut; +JSC_DECLARE_HOST_FUNCTION(jsFunctionRequireCommonJS); - mutable JSC::WriteBarrier m_exportsObject; - mutable JSC::WriteBarrier m_id; +static bool canPerformFastEnumeration(Structure* s) +{ + if (s->typeInfo().overridesGetOwnPropertySlot()) + return false; + if (s->typeInfo().overridesAnyFormOfGetOwnPropertyNames()) + return false; + if (hasIndexedProperties(s->indexingType())) + return false; + if (s->hasAnyKindOfGetterSetterProperties()) + return false; + if (s->isUncacheableDictionary()) + return false; + if (s->hasUnderscoreProtoPropertyExcludingOriginalProto()) + return false; + return true; +} - void finishCreation(JSC::VM& vm, JSC::JSValue exportsObject, JSC::JSString* id, JSC::JSString* filename, JSC::JSString* dirname, JSC::JSValue requireFunction) - { - Base::finishCreation(vm); - ASSERT(inherits(vm, info())); - m_exportsObject.set(vm, this, exportsObject); - m_id.set(vm, this, id); +static bool evaluateCommonJSModuleOnce(JSC::VM& vm, Zig::GlobalObject* globalObject, JSCommonJSModule* moduleObject, JSString* dirname, JSString* filename, WTF::NakedPtr& exception) +{ + JSC::Structure* thisObjectStructure = globalObject->commonJSFunctionArgumentsStructure(); + JSC::JSObject* thisObject = JSC::constructEmptyObject( + vm, + thisObjectStructure); + thisObject->putDirectOffset( + vm, + 0, + moduleObject); - this->putDirectOffset( - vm, - 0, - exportsObject); + thisObject->putDirectOffset( + vm, + 1, + dirname); - this->putDirectOffset( - vm, - 1, - id); + thisObject->putDirectOffset( + vm, + 2, + filename); - this->putDirectOffset( - vm, - 2, - filename); + moduleObject->hasEvaluated = true; + globalObject->m_BunCommonJSModuleValue.set(vm, globalObject, thisObject); - this->putDirectOffset( - vm, - 3, - jsBoolean(false)); + JSValue empty = JSC::evaluate(globalObject, moduleObject->sourceCode.get()->sourceCode(), thisObject, exception); + moduleObject->sourceCode.clear(); - this->putDirectOffset( - vm, - 4, - dirname); + return exception.get() == nullptr; +} - this->putDirectOffset( - vm, - 5, - jsUndefined()); +JSC_DEFINE_HOST_FUNCTION(jsFunctionLoadModule, (JSGlobalObject * lexicalGlobalObject, CallFrame* callframe)) +{ + auto* globalObject = jsCast(lexicalGlobalObject); + auto throwScope = DECLARE_THROW_SCOPE(globalObject->vm()); + JSCommonJSModule* moduleObject = jsDynamicCast(callframe->argument(0)); + if (!moduleObject) { + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean(true))); + } + + if (moduleObject->hasEvaluated || !moduleObject->sourceCode) { + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean(true))); } - static JSC::Structure* createStructure( + WTF::NakedPtr exception; + + evaluateCommonJSModuleOnce( + globalObject->vm(), + jsCast(globalObject), + moduleObject, + moduleObject->m_dirname.get(), + moduleObject->m_filename.get(), + exception); + + if (exception.get()) { + // On error, remove the module from the require map/ + // so that it can be re-evaluated on the next require. + globalObject->requireMap()->remove(globalObject, moduleObject->id()); + + throwException(globalObject, throwScope, exception.get()); + exception.clear(); + return JSValue::encode({}); + } + + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean(true))); +} + +JSC_DEFINE_HOST_FUNCTION(requireResolvePathsFunction, (JSGlobalObject * globalObject, CallFrame* callframe)) +{ + return JSValue::encode(JSC::constructEmptyArray(globalObject, nullptr, 0)); +} + +static const HashTableValue RequireResolveFunctionPrototypeValues[] = { + { "paths"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, requireResolvePathsFunction, 1 } }, +}; + +class RequireResolveFunctionPrototype final : public JSC::JSNonFinalObject { +public: + using Base = JSC::JSNonFinalObject; + static RequireResolveFunctionPrototype* create( JSC::JSGlobalObject* globalObject) { auto& vm = globalObject->vm(); - JSC::Structure* structure = JSC::Structure::create( - vm, - globalObject, - globalObject->objectPrototype(), - JSC::TypeInfo(JSC::ObjectType, JSCommonJSModule::StructureFlags), - JSCommonJSModule::info(), - JSC::NonArray, - 6); - JSC::PropertyOffset offset; - auto clientData = WebCore::clientData(vm); + auto* structure = RequireResolveFunctionPrototype::createStructure(vm, globalObject, globalObject->functionPrototype()); + RequireResolveFunctionPrototype* prototype = new (NotNull, JSC::allocateCell(vm)) RequireResolveFunctionPrototype(vm, structure); + prototype->finishCreation(vm); + return prototype; + } - structure = structure->addPropertyTransition( - vm, - structure, - JSC::Identifier::fromString(vm, "exports"_s), - 0, - offset); + DECLARE_INFO; - structure = structure->addPropertyTransition( - vm, - structure, - JSC::Identifier::fromString(vm, "id"_s), - 0, - offset); + RequireResolveFunctionPrototype( + JSC::VM& vm, + JSC::Structure* structure) + : Base(vm, structure) + { + } - structure = structure->addPropertyTransition( - vm, - structure, - JSC::Identifier::fromString(vm, "filename"_s), - 0, - offset); + template + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + return &vm.plainObjectSpace(); + } - structure = structure->addPropertyTransition( - vm, - structure, - JSC::Identifier::fromString(vm, "loaded"_s), - 0, - offset); + void finishCreation(JSC::VM& vm); +}; - structure = structure->addPropertyTransition( - vm, - structure, - JSC::Identifier::fromString(vm, "path"_s), - 0, - offset); +static const HashTableValue RequireFunctionPrototypeValues[] = { + { "cache"_s, static_cast(JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, Zig::jsRequireCacheGetter, Zig::jsRequireCacheSetter } }, +}; - structure = structure->addPropertyTransition( - vm, - structure, - JSC::Identifier::fromString(vm, "require"_s), - 0, - offset); +class RequireFunctionPrototype final : public JSC::JSNonFinalObject { +public: + using Base = JSC::JSNonFinalObject; + static RequireFunctionPrototype* create( + JSC::JSGlobalObject* globalObject) + { + auto& vm = globalObject->vm(); + + auto* structure = RequireFunctionPrototype::createStructure(vm, globalObject, globalObject->functionPrototype()); + RequireFunctionPrototype* prototype = new (NotNull, JSC::allocateCell(vm)) RequireFunctionPrototype(vm, structure); + prototype->finishCreation(vm); - return structure; + JSFunction* resolveFunction = JSFunction::create(vm, moduleRequireResolveCodeGenerator(vm), globalObject->globalScope(), JSFunction::createStructure(vm, globalObject, RequireResolveFunctionPrototype::create(globalObject))); + prototype->putDirect(vm, JSC::Identifier::fromString(vm, "resolve"_s), resolveFunction, PropertyAttribute::Function | 0); + + return prototype; } - static JSCommonJSModule* create( + RequireFunctionPrototype( JSC::VM& vm, - JSC::Structure* structure, - JSC::JSValue exportsObject, - JSC::JSString* id, - JSC::JSString* filename, - JSC::JSString* dirname, - JSC::JSValue requireFunction) + JSC::Structure* structure) + : Base(vm, structure) { - JSCommonJSModule* cell = new (NotNull, JSC::allocateCell(vm)) JSCommonJSModule(vm, structure); - cell->finishCreation(vm, exportsObject, id, filename, dirname, requireFunction); - return cell; } - JSValue exportsObject() + DECLARE_INFO; + + template + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { - return m_exportsObject.get(); + return &vm.plainObjectSpace(); } - JSValue id() + void finishCreation(JSC::VM& vm) { - return m_id.get(); + Base::finishCreation(vm); + ASSERT(inherits(vm, info())); + + reifyStaticProperties(vm, info(), RequireFunctionPrototypeValues, *this); + JSC::JSFunction* requireDotMainFunction = JSFunction::create( + vm, + moduleMainCodeGenerator(vm), + globalObject()->globalScope()); + + this->putDirect( + vm, + JSC::Identifier::fromString(vm, "main"_s), + JSC::GetterSetter::create(vm, globalObject(), requireDotMainFunction, JSValue()), + PropertyAttribute::Builtin | PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | 0); + this->putDirect(vm, JSC::Identifier::fromString(vm, "extensions"_s), constructEmptyObject(globalObject()), 0); } +}; - DECLARE_VISIT_CHILDREN; +JSC_DEFINE_CUSTOM_GETTER(getterFilename, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + JSCommonJSModule* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) { + return JSValue::encode(jsUndefined()); + } + return JSValue::encode(thisObject->m_filename.get()); +} +JSC_DEFINE_CUSTOM_GETTER(getterId, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + JSCommonJSModule* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) { + return JSValue::encode(jsUndefined()); + } + return JSValue::encode(thisObject->m_id.get()); +} - static bool put( - JSC::JSCell* cell, - JSC::JSGlobalObject* globalObject, - JSC::PropertyName propertyName, - JSC::JSValue value, - JSC::PutPropertySlot& slot) - { +JSC_DEFINE_CUSTOM_GETTER(getterPath, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + JSCommonJSModule* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) { + return JSValue::encode(jsUndefined()); + } + return JSValue::encode(thisObject->m_id.get()); +} - auto& vm = globalObject->vm(); - auto* clientData = WebCore::clientData(vm); - auto throwScope = DECLARE_THROW_SCOPE(vm); +JSC_DEFINE_CUSTOM_SETTER(setterPath, + (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, + JSC::EncodedJSValue value, JSC::PropertyName propertyName)) +{ + JSCommonJSModule* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (!thisObject) + return false; - if (propertyName == clientData->builtinNames().exportsPublicName()) { - JSCommonJSModule* thisObject = jsCast(cell); - ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + thisObject->m_id.set(globalObject->vm(), thisObject, JSValue::decode(value).toString(globalObject)); + return true; +} - // It will crash if we attempt to assign Object.defineProperty() result to a JSMap*. - if (UNLIKELY(slot.thisValue() != thisObject)) - RELEASE_AND_RETURN(throwScope, JSObject::definePropertyOnReceiver(globalObject, propertyName, value, slot)); +JSC_DEFINE_CUSTOM_SETTER(setterFilename, + (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, + JSC::EncodedJSValue value, JSC::PropertyName propertyName)) +{ + JSCommonJSModule* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (!thisObject) + return false; - JSValue prevValue = thisObject->m_exportsObject.get(); + thisObject->m_filename.set(globalObject->vm(), thisObject, JSValue::decode(value).toString(globalObject)); + return true; +} - // TODO: refactor this to not go through ESM path and we don't need to do this check. - // IF we do this on every call, it causes GC to happen in a place that it may not be able to. - // This breaks loading Bluebird in some cases, for example. - // We need to update the require map "live" because otherwise the code in Discord.js will break - // The bug is something to do with exception handling which causes GC to happen in the error path and then boom. - if (prevValue != value && (!prevValue.isCell() || !value.isCell() || prevValue.asCell()->type() != value.asCell()->type())) { - jsCast(globalObject)->requireMap()->set(globalObject, thisObject->id(), value); - } +JSC_DEFINE_CUSTOM_SETTER(setterId, + (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, + JSC::EncodedJSValue value, JSC::PropertyName propertyName)) +{ + JSCommonJSModule* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (!thisObject) + return false; - thisObject->m_exportsObject.set(vm, thisObject, value); - } + thisObject->m_id.set(globalObject->vm(), thisObject, JSValue::decode(value).toString(globalObject)); + return true; +} + +static JSValue createLoaded(VM& vm, JSObject* object) +{ + JSCommonJSModule* cjs = jsCast(object); + return jsBoolean(cjs->hasEvaluated); +} +static JSValue createParent(VM& vm, JSObject* object) +{ + return jsUndefined(); +} +static JSValue createChildren(VM& vm, JSObject* object) +{ + return constructEmptyArray(object->globalObject(), nullptr, 0); +} + +static const struct HashTableValue JSCommonJSModulePrototypeTableValues[] = { + { "children"_s, static_cast(PropertyAttribute::PropertyCallback | PropertyAttribute::DontEnum | 0), NoIntrinsic, { HashTableValue::LazyPropertyType, createChildren } }, + { "filename"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, getterFilename, setterFilename } }, + { "id"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, getterId, setterId } }, + { "loaded"_s, static_cast(PropertyAttribute::PropertyCallback | PropertyAttribute::DontEnum | 0), NoIntrinsic, { HashTableValue::LazyPropertyType, createLoaded } }, + { "parent"_s, static_cast(PropertyAttribute::PropertyCallback | PropertyAttribute::DontEnum | 0), NoIntrinsic, { HashTableValue::LazyPropertyType, createParent } }, + { "path"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, getterPath, setterPath } }, +}; - RELEASE_AND_RETURN(throwScope, Base::put(cell, globalObject, propertyName, value, slot)); +class JSCommonJSModulePrototype final : public JSC::JSNonFinalObject { +public: + using Base = JSC::JSNonFinalObject; + static JSCommonJSModulePrototype* create( + JSC::VM& vm, + JSC::JSGlobalObject* globalObject, + JSC::Structure* structure) + { + JSCommonJSModulePrototype* prototype = new (NotNull, JSC::allocateCell(vm)) JSCommonJSModulePrototype(vm, structure); + prototype->finishCreation(vm, globalObject); + return prototype; } DECLARE_INFO; - template static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + + JSCommonJSModulePrototype( + JSC::VM& vm, + JSC::Structure* structure) + : Base(vm, structure) { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - return WebCore::subspaceForImpl( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForCommonJSModuleRecord.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCommonJSModuleRecord = std::forward(space); }, - [](auto& spaces) { return spaces.m_subspaceForCommonJSModuleRecord.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForCommonJSModuleRecord = std::forward(space); }); } - JSCommonJSModule(JSC::VM& vm, JSC::Structure* structure) - : Base(vm, structure) + template + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + return &vm.plainObjectSpace(); + } + + void finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) + { + Base::finishCreation(vm); + ASSERT(inherits(vm, info())); + reifyStaticProperties(vm, JSCommonJSModule::info(), JSCommonJSModulePrototypeTableValues, *this); + + JSFunction* requireFunction = JSFunction::create( + vm, + moduleRequireCodeGenerator(vm), + globalObject->globalScope(), + JSFunction::createStructure(vm, globalObject, RequireFunctionPrototype::create(globalObject))); + + this->putDirect(vm, clientData(vm)->builtinNames().requirePublicName(), requireFunction, PropertyAttribute::Builtin | PropertyAttribute::Function | 0); + + this->putDirectNativeFunction( + vm, + globalObject, + clientData(vm)->builtinNames().requirePrivateName(), + 2, + jsFunctionRequireCommonJS, ImplementationVisibility::Public, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0); } }; -Structure* createCommonJSModuleStructure( - Zig::GlobalObject* globalObject) +const JSC::ClassInfo JSCommonJSModulePrototype::s_info = { "Module"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCommonJSModulePrototype) }; + +void JSCommonJSModule::finishCreation(JSC::VM& vm, JSC::JSString* id, JSC::JSString* filename, JSC::JSString* dirname, JSC::JSSourceCode* sourceCode) { - return JSCommonJSModule::createStructure(globalObject); + Base::finishCreation(vm); + ASSERT(inherits(vm, info())); + m_id.set(vm, this, id); + m_filename.set(vm, this, filename); + m_dirname.set(vm, this, dirname); + this->sourceCode.set(vm, this, sourceCode); } -template -void JSCommonJSModule::visitChildrenImpl(JSCell* cell, Visitor& visitor) +JSC::Structure* JSCommonJSModule::createStructure( + JSC::JSGlobalObject* globalObject) { - JSCommonJSModule* thisObject = jsCast(cell); - ASSERT_GC_OBJECT_INHERITS(thisObject, info()); - Base::visitChildren(thisObject, visitor); - visitor.append(thisObject->m_exportsObject); - visitor.append(thisObject->m_id); -} + auto& vm = globalObject->vm(); -DEFINE_VISIT_CHILDREN(JSCommonJSModule); -const JSC::ClassInfo JSCommonJSModule::s_info = { "Module"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCommonJSModule) }; + auto* prototype = JSCommonJSModulePrototype::create(vm, globalObject, JSCommonJSModulePrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); -static bool canPerformFastEnumeration(Structure* s) + // Do not set the number of inline properties on this structure + // there may be an off-by-one error in the Structure which causes `require.id` to become the require + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), NonArray); +} + +JSCommonJSModule* JSCommonJSModule::create( + JSC::VM& vm, + JSC::Structure* structure, + JSC::JSString* id, + JSC::JSString* filename, + JSC::JSString* dirname, + JSC::JSSourceCode* sourceCode) { - if (s->typeInfo().overridesGetOwnPropertySlot()) - return false; - if (s->typeInfo().overridesAnyFormOfGetOwnPropertyNames()) - return false; - if (hasIndexedProperties(s->indexingType())) - return false; - if (s->hasAnyKindOfGetterSetterProperties()) - return false; - if (s->isUncacheableDictionary()) - return false; - if (s->hasUnderscoreProtoPropertyExcludingOriginalProto()) - return false; - return true; + JSCommonJSModule* cell = new (NotNull, JSC::allocateCell(vm)) JSCommonJSModule(vm, structure); + cell->finishCreation(vm, id, filename, dirname, sourceCode); + return cell; } -JSValue evaluateCommonJSModule( - Zig::GlobalObject* globalObject, - Ref sourceProvider, - const WTF::String& sourceURL, - ResolvedSource source) +JSC_DEFINE_HOST_FUNCTION(jsFunctionCreateCommonJSModule, (JSGlobalObject * globalObject, CallFrame* callframe)) { auto& vm = globalObject->vm(); - auto throwScope = DECLARE_THROW_SCOPE(vm); - auto* requireMapKey = jsString(vm, sourceURL); + auto id = callframe->argument(0).toWTFString(globalObject); - JSC::JSObject* exportsObject = source.commonJSExportsLen < 64 - ? JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), source.commonJSExportsLen) - : JSC::constructEmptyObject(globalObject, globalObject->objectPrototype()); - auto index = sourceURL.reverseFind('/', sourceURL.length()); + JSValue object = callframe->argument(1); + + return JSValue::encode( + JSCommonJSModule::create( + jsCast(globalObject), + id, + object, callframe->argument(2).isBoolean() && callframe->argument(2).asBoolean())); +} + +JSCommonJSModule* JSCommonJSModule::create( + Zig::GlobalObject* globalObject, + const WTF::String& key, + JSValue exportsObject, + bool hasEvaluated) +{ + auto& vm = globalObject->vm(); + JSString* requireMapKey = JSC::jsStringWithCache(vm, key); + auto index = key.reverseFind('/', key.length()); JSString* dirname = jsEmptyString(vm); JSString* filename = requireMapKey; if (index != WTF::notFound) { dirname = JSC::jsSubstring(globalObject, requireMapKey, 0, index); } - globalObject->requireMap()->set(globalObject, requireMapKey, exportsObject); - auto* requireFunction = Zig::ImportMetaObject::createRequireFunction(vm, globalObject, sourceURL); - - JSC::SourceCode inputSource( - WTFMove(sourceProvider)); - - auto* moduleObject = JSCommonJSModule::create( + auto* out = JSCommonJSModule::create( vm, globalObject->CommonJSModuleObjectStructure(), - exportsObject, - requireMapKey, filename, dirname, requireFunction); + requireMapKey, filename, dirname, nullptr); - if (UNLIKELY(throwScope.exception())) { - globalObject->requireMap()->remove(globalObject, requireMapKey); - RELEASE_AND_RETURN(throwScope, JSValue()); - } + out->putDirect(vm, WebCore::clientData(vm)->builtinNames().exportsPublicName(), exportsObject, exportsObject.isCell() && exportsObject.isCallable() ? JSC::PropertyAttribute::Function | 0 : 0); + out->hasEvaluated = hasEvaluated; + return out; +} - JSC::Structure* thisObjectStructure = globalObject->commonJSFunctionArgumentsStructure(); - JSC::JSObject* thisObject = JSC::constructEmptyObject( - vm, - thisObjectStructure); - thisObject->putDirectOffset( - vm, - 0, - moduleObject); +void JSCommonJSModule::destroy(JSC::JSCell* cell) +{ + static_cast(cell)->JSCommonJSModule::~JSCommonJSModule(); +} - thisObject->putDirectOffset( - vm, - 1, - exportsObject); +JSCommonJSModule::~JSCommonJSModule() +{ +} - thisObject->putDirectOffset( - vm, - 2, - dirname); +bool JSCommonJSModule::evaluate( + Zig::GlobalObject* globalObject, + const WTF::String& key, + const SyntheticSourceProvider::SyntheticSourceGenerator& generator) +{ + Vector propertyNames; + JSC::MarkedArgumentBuffer arguments; + auto& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + generator(globalObject, JSC::Identifier::fromString(vm, key), propertyNames, arguments); + RETURN_IF_EXCEPTION(throwScope, false); + + bool needsPut = false; + auto getDefaultValue = [&]() -> JSValue { + size_t defaultValueIndex = propertyNames.find(vm.propertyNames->defaultKeyword); + auto cjsSymbol = Identifier::fromUid(vm.symbolRegistry().symbolForKey("CommonJS"_s)); + + if (defaultValueIndex != notFound && propertyNames.contains(cjsSymbol)) { + JSValue current = arguments.at(defaultValueIndex); + needsPut = true; + return current; + } - thisObject->putDirectOffset( - vm, - 3, - filename); + size_t count = propertyNames.size(); + JSValue existingDefaultObject = this->getIfPropertyExists(globalObject, WebCore::clientData(vm)->builtinNames().exportsPublicName()); + JSObject* defaultObject; - thisObject->putDirectOffset( - vm, - 4, - requireFunction); + if (existingDefaultObject && existingDefaultObject.isObject()) { + defaultObject = jsCast(existingDefaultObject); + } else { + defaultObject = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype()); + needsPut = true; + } - { - WTF::NakedPtr exception; - globalObject->m_BunCommonJSModuleValue.set(vm, globalObject, thisObject); - JSC::evaluate(globalObject, inputSource, globalObject->globalThis(), exception); - - if (exception.get()) { - throwScope.throwException(globalObject, exception->value()); - exception.clear(); - RELEASE_AND_RETURN(throwScope, JSValue()); + for (size_t i = 0; i < count; ++i) { + auto prop = propertyNames[i]; + unsigned attributes = 0; + + JSValue value = arguments.at(i); + + if (prop.isSymbol()) { + attributes |= JSC::PropertyAttribute::DontEnum; + } + + if (value.isCell() && value.isCallable()) { + attributes |= JSC::PropertyAttribute::Function; + } + + defaultObject->putDirect(vm, prop, value, attributes); } - } - if (UNLIKELY(throwScope.exception())) { - globalObject->requireMap()->remove(globalObject, requireMapKey); - RELEASE_AND_RETURN(throwScope, JSValue()); + return defaultObject; + }; + + JSValue defaultValue = getDefaultValue(); + if (needsPut) { + unsigned attributes = 0; + + if (defaultValue.isCell() && defaultValue.isCallable()) { + attributes |= JSC::PropertyAttribute::Function; + } + + this->putDirect(vm, WebCore::clientData(vm)->builtinNames().exportsPublicName(), defaultValue, attributes); } - JSValue result = moduleObject->exportsObject(); - - // The developer can do something like: - // - // Object.defineProperty(module, 'exports', {get: getter}) - // - // In which case, the exports object is now a GetterSetter object. - // - // We can't return a GetterSetter object to ESM code, so we need to call it. - if (!result.isEmpty() && (result.isGetterSetter() || result.isCustomGetterSetter())) { - auto* clientData = WebCore::clientData(vm); - - // TODO: is there a faster way to call these getters? We shouldn't need to do a full property lookup. - // - // we use getIfPropertyExists just incase a pathological devleoper did: - // - // - Object.defineProperty(module, 'exports', {get: getter}) - // - delete module.exports - // - if (result.isGetterSetter()) { - JSC::GetterSetter* getter = jsCast(result); - result = getter->callGetter(globalObject, moduleObject); + this->hasEvaluated = true; + RELEASE_AND_RETURN(throwScope, true); +} + +void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject, + JSC::Identifier moduleKey, + Vector& exportNames, + JSC::MarkedArgumentBuffer& exportValues) +{ + auto result = this->exportsObject(); + + auto& vm = globalObject->vm(); + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(result); + + // This exists to tell ImportMetaObject.ts that this is a CommonJS module. + exportNames.append(Identifier::fromUid(vm.symbolRegistry().symbolForKey("CommonJS"_s))); + exportValues.append(jsNumber(0)); + + if (result.isObject()) { + auto* exports = asObject(result); + + auto* structure = exports->structure(); + uint32_t size = structure->inlineSize() + structure->outOfLineSize(); + exportNames.reserveCapacity(size + 2); + exportValues.ensureCapacity(size + 2); + + if (canPerformFastEnumeration(structure)) { + exports->structure()->forEachProperty(vm, [&](const PropertyTableEntry& entry) -> bool { + auto key = entry.key(); + if (key->isSymbol() || key == vm.propertyNames->defaultKeyword || entry.attributes() & PropertyAttribute::DontEnum) + return true; + + exportNames.append(Identifier::fromUid(vm, key)); + + JSValue value = exports->getDirect(entry.offset()); + + exportValues.append(value); + return true; + }); } else { - result = moduleObject->getIfPropertyExists(globalObject, clientData->builtinNames().exportsPublicName()); - } + auto catchScope = DECLARE_CATCH_SCOPE(vm); + JSC::PropertyNameArray properties(vm, JSC::PropertyNameMode::Strings, JSC::PrivateSymbolMode::Exclude); + exports->methodTable()->getOwnPropertyNames(exports, globalObject, properties, DontEnumPropertiesMode::Exclude); + if (catchScope.exception()) { + catchScope.clearExceptionExceptTermination(); + return; + } + + for (auto property : properties) { + if (UNLIKELY(property.isEmpty() || property.isNull() || property.isPrivateName() || property.isSymbol())) + continue; + + // ignore constructor + if (property == vm.propertyNames->constructor || property == vm.propertyNames->defaultKeyword) + continue; + + JSC::PropertySlot slot(exports, PropertySlot::InternalMethodType::Get); + if (!exports->getPropertySlot(globalObject, property, slot)) + continue; + + exportNames.append(property); - if (UNLIKELY(throwScope.exception())) { - // Unlike getters on properties of the exports object - // When the exports object itself is a getter and it throws - // There's not a lot we can do - // so we surface that error - globalObject->requireMap()->remove(globalObject, requireMapKey); - RELEASE_AND_RETURN(throwScope, JSValue()); + JSValue getterResult = slot.getValue(globalObject, property); + + // If it throws, we keep them in the exports list, but mark it as undefined + // This is consistent with what Node.js does. + if (catchScope.exception()) { + catchScope.clearException(); + getterResult = jsUndefined(); + } + + exportValues.append(getterResult); + } } } +} - globalObject->requireMap()->set(globalObject, requireMapKey, result); +JSValue JSCommonJSModule::exportsObject() +{ + return this->get(globalObject(), JSC::PropertyName(clientData(vm())->builtinNames().exportsPublicName())); +} + +JSValue JSCommonJSModule::id() +{ + return m_id.get(); +} + +bool JSCommonJSModule::put( + JSC::JSCell* cell, + JSC::JSGlobalObject* globalObject, + JSC::PropertyName propertyName, + JSC::JSValue value, + JSC::PutPropertySlot& slot) +{ + + auto& vm = globalObject->vm(); + auto* clientData = WebCore::clientData(vm); + auto throwScope = DECLARE_THROW_SCOPE(vm); + + RELEASE_AND_RETURN(throwScope, Base::put(cell, globalObject, propertyName, value, slot)); +} + +template JSC::GCClient::IsoSubspace* JSCommonJSModule::subspaceFor(JSC::VM& vm) +{ + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForCommonJSModuleRecord.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCommonJSModuleRecord = std::forward(space); }, + [](auto& spaces) { return spaces.m_subspaceForCommonJSModuleRecord.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForCommonJSModuleRecord = std::forward(space); }); +} + +Structure* createCommonJSModuleStructure( + Zig::GlobalObject* globalObject) +{ + return JSCommonJSModule::createStructure(globalObject); +} + +template +void JSCommonJSModule::visitChildrenImpl(JSCell* cell, Visitor& visitor) +{ + JSCommonJSModule* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + Base::visitChildren(thisObject, visitor); + visitor.append(thisObject->m_id); + visitor.append(thisObject->sourceCode); + visitor.append(thisObject->m_filename); + visitor.append(thisObject->m_dirname); +} + +DEFINE_VISIT_CHILDREN(JSCommonJSModule); +const JSC::ClassInfo JSCommonJSModule::s_info = { "Module"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCommonJSModule) }; +const JSC::ClassInfo RequireResolveFunctionPrototype::s_info = { "resolve"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(RequireResolveFunctionPrototype) }; +const JSC::ClassInfo RequireFunctionPrototype::s_info = { "require"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(RequireFunctionPrototype) }; + +JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireCommonJS, (JSGlobalObject * lexicalGlobalObject, CallFrame* callframe)) +{ + auto* globalObject = jsCast(lexicalGlobalObject); + auto& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + + JSCommonJSModule* thisObject = jsDynamicCast(callframe->thisValue()); + if (!thisObject) + return throwVMTypeError(globalObject, throwScope); + + JSValue specifierValue = callframe->argument(0); + WTF::String specifier = specifierValue.toWTFString(globalObject); + RETURN_IF_EXCEPTION(throwScope, {}); + + WTF::String referrer = thisObject->id().toWTFString(globalObject); + RETURN_IF_EXCEPTION(throwScope, {}); + + BunString specifierStr = Bun::toString(specifier); + BunString referrerStr = Bun::toString(referrer); + + JSValue fetchResult = Bun::fetchCommonJSModule( + globalObject, + jsDynamicCast(callframe->argument(1)), + specifierValue, + &specifierStr, + &referrerStr); + + RELEASE_AND_RETURN(throwScope, JSValue::encode(fetchResult)); +} + +void RequireResolveFunctionPrototype::finishCreation(JSC::VM& vm) +{ + Base::finishCreation(vm); + ASSERT(inherits(vm, info())); - return result; + reifyStaticProperties(vm, RequireResolveFunctionPrototype::info(), RequireResolveFunctionPrototypeValues, *this); + JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } -JSC::SourceCode createCommonJSModule( +bool JSCommonJSModule::evaluate( Zig::GlobalObject* globalObject, + const WTF::String& key, ResolvedSource source) { - auto sourceURL = Zig::toStringCopy(source.source_url); - auto sourceProvider = Zig::SourceProvider::create(globalObject, source, JSC::SourceProviderSourceType::Program); + auto& vm = globalObject->vm(); + auto sourceProvider = Zig::SourceProvider::create(jsCast(globalObject), source, JSC::SourceProviderSourceType::Program); + JSC::SourceCode rawInputSource( + WTFMove(sourceProvider)); - return JSC::SourceCode( - JSC::SyntheticSourceProvider::create( - [source, sourceProvider = WTFMove(sourceProvider), sourceURL](JSC::JSGlobalObject* globalObject, - JSC::Identifier moduleKey, - Vector& exportNames, - JSC::MarkedArgumentBuffer& exportValues) -> void { - JSValue result = evaluateCommonJSModule( - jsCast(globalObject), - WTFMove(sourceProvider), - sourceURL, - source); - - if (!result) { - return; - } + if (this->hasEvaluated) + return true; - auto& vm = globalObject->vm(); + this->sourceCode.set(vm, this, JSC::JSSourceCode::create(vm, WTFMove(rawInputSource))); + WTF::NakedPtr exception; - exportNames.append(vm.propertyNames->defaultKeyword); - exportValues.append(result); - - // This exists to tell ImportMetaObject.ts that this is a CommonJS module. - exportNames.append(Identifier::fromUid(vm.symbolRegistry().symbolForKey("CommonJS"_s))); - exportValues.append(jsNumber(0)); - - if (result.isObject()) { - DeferGCForAWhile deferGC(vm); - auto* exports = asObject(result); - - auto* structure = exports->structure(); - uint32_t size = structure->inlineSize() + structure->outOfLineSize(); - exportNames.reserveCapacity(size + 2); - exportValues.ensureCapacity(size + 2); - - if (canPerformFastEnumeration(structure)) { - exports->structure()->forEachProperty(vm, [&](const PropertyTableEntry& entry) -> bool { - auto key = entry.key(); - if (key->isSymbol() || key == vm.propertyNames->defaultKeyword || entry.attributes() & PropertyAttribute::DontEnum) - return true; - - exportNames.append(Identifier::fromUid(vm, key)); - - JSValue value = exports->getDirect(entry.offset()); - - exportValues.append(value); - return true; - }); - } else { - auto catchScope = DECLARE_CATCH_SCOPE(vm); - JSC::PropertyNameArray properties(vm, JSC::PropertyNameMode::Strings, JSC::PrivateSymbolMode::Exclude); - exports->methodTable()->getOwnPropertyNames(exports, globalObject, properties, DontEnumPropertiesMode::Exclude); - if (catchScope.exception()) { - catchScope.clearExceptionExceptTermination(); - return; - } + evaluateCommonJSModuleOnce(vm, globalObject, this, this->m_dirname.get(), this->m_filename.get(), exception); - for (auto property : properties) { - if (UNLIKELY(property.isEmpty() || property.isNull() || property.isPrivateName() || property.isSymbol())) - continue; + if (exception.get()) { + // On error, remove the module from the require map/ + // so that it can be re-evaluated on the next require. + globalObject->requireMap()->remove(globalObject, this->id()); - // ignore constructor - if (property == vm.propertyNames->constructor || property == vm.propertyNames->defaultKeyword) - continue; + auto throwScope = DECLARE_THROW_SCOPE(vm); + throwException(globalObject, throwScope, exception.get()); + exception.clear(); - JSC::PropertySlot slot(exports, PropertySlot::InternalMethodType::Get); - if (!exports->getPropertySlot(globalObject, property, slot)) - continue; + return false; + } - exportNames.append(property); + return true; +} - JSValue getterResult = slot.getValue(globalObject, property); +std::optional createCommonJSModule( + Zig::GlobalObject* globalObject, + ResolvedSource source) +{ + JSCommonJSModule* moduleObject; + WTF::String sourceURL = toStringCopy(source.source_url); - // If it throws, we keep them in the exports list, but mark it as undefined - // This is consistent with what Node.js does. - if (catchScope.exception()) { - catchScope.clearException(); - getterResult = jsUndefined(); - } + JSValue specifierValue = Bun::toJS(globalObject, source.specifier); + JSValue entry = globalObject->requireMap()->get(globalObject, specifierValue); - exportValues.append(getterResult); + auto sourceProvider = Zig::SourceProvider::create(jsCast(globalObject), source, JSC::SourceProviderSourceType::Program); + SourceOrigin sourceOrigin = sourceProvider->sourceOrigin(); + + if (entry) { + moduleObject = jsDynamicCast(entry); + } + + if (!moduleObject) { + auto& vm = globalObject->vm(); + auto* requireMapKey = jsStringWithCache(vm, sourceURL); + auto index = sourceURL.reverseFind('/', sourceURL.length()); + JSString* dirname = jsEmptyString(vm); + JSString* filename = requireMapKey; + if (index != WTF::notFound) { + dirname = JSC::jsSubstring(globalObject, requireMapKey, 0, index); + } + + JSC::SourceCode rawInputSource( + WTFMove(sourceProvider)); + + moduleObject = JSCommonJSModule::create( + vm, + globalObject->CommonJSModuleObjectStructure(), + requireMapKey, filename, dirname, JSC::JSSourceCode::create(vm, WTFMove(rawInputSource))); + + moduleObject->putDirect(vm, + WebCore::clientData(vm)->builtinNames().exportsPublicName(), + JSC::constructEmptyObject(globalObject, globalObject->objectPrototype()), 0); + + globalObject->requireMap()->set(globalObject, requireMapKey, moduleObject); + } + + return JSC::SourceCode( + JSC::SyntheticSourceProvider::create( + [](JSC::JSGlobalObject* lexicalGlobalObject, + JSC::Identifier moduleKey, + Vector& exportNames, + JSC::MarkedArgumentBuffer& exportValues) -> void { + auto* globalObject = jsCast(lexicalGlobalObject); + auto& vm = globalObject->vm(); + + JSValue keyValue = identifierToJSValue(vm, moduleKey); + JSValue entry = globalObject->requireMap()->get(globalObject, keyValue); + + if (entry) { + if (auto* moduleObject = jsDynamicCast(entry)) { + if (!moduleObject->hasEvaluated) { + WTF::NakedPtr exception; + if (!evaluateCommonJSModuleOnce( + vm, + globalObject, + moduleObject, + moduleObject->m_dirname.get(), + moduleObject->m_filename.get(), exception)) { + + // On error, remove the module from the require map + // so that it can be re-evaluated on the next require. + globalObject->requireMap()->remove(globalObject, moduleObject->id()); + + auto scope = DECLARE_THROW_SCOPE(vm); + throwException(globalObject, scope, exception.get()); + exception.clear(); + return; + } } + + moduleObject->toSyntheticSource(globalObject, moduleKey, exportNames, exportValues); } } }, - SourceOrigin(WTF::URL::fileURLWithFileSystemPath(sourceURL)), + sourceOrigin, sourceURL)); } - } \ No newline at end of file diff --git a/src/bun.js/bindings/CommonJSModuleRecord.h b/src/bun.js/bindings/CommonJSModuleRecord.h index 86daf875d..48f14b39c 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.h +++ b/src/bun.js/bindings/CommonJSModuleRecord.h @@ -6,14 +6,90 @@ class GlobalObject; } namespace JSC { class SourceCode; +class JSSourceCode; +class ProgramExecutable; +class AbstractModuleRecord; } namespace Bun { +JSC_DECLARE_HOST_FUNCTION(jsFunctionCreateCommonJSModule); +JSC_DECLARE_HOST_FUNCTION(jsFunctionLoadModule); + +class JSCommonJSModule final : public JSC::JSDestructibleObject { +public: + using Base = JSC::JSDestructibleObject; + static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::OverridesPut; + + mutable JSC::WriteBarrier m_id; + mutable JSC::WriteBarrier m_filename; + mutable JSC::WriteBarrier m_dirname; + mutable JSC::WriteBarrier sourceCode; + + static void destroy(JSC::JSCell*); + ~JSCommonJSModule(); + + void finishCreation(JSC::VM& vm, + JSC::JSString* id, JSC::JSString* filename, + JSC::JSString* dirname, JSC::JSSourceCode* sourceCode); + + static JSC::Structure* createStructure(JSC::JSGlobalObject* globalObject); + + bool evaluate(Zig::GlobalObject* globalObject, const WTF::String& sourceURL, ResolvedSource resolvedSource); + bool evaluate(Zig::GlobalObject* globalObject, const WTF::String& key, const SyntheticSourceProvider::SyntheticSourceGenerator& generator); + + static JSCommonJSModule* create(JSC::VM& vm, JSC::Structure* structure, + JSC::JSString* id, + JSC::JSString* filename, + JSC::JSString* dirname, JSC::JSSourceCode* sourceCode); + + static JSCommonJSModule* create( + Zig::GlobalObject* globalObject, + const WTF::String& key, + JSValue exportsObject, + bool hasEvaluated = false); + + static JSCommonJSModule* create( + Zig::GlobalObject* globalObject, + const WTF::String& key, + ResolvedSource resolvedSource); + + void toSyntheticSource(JSC::JSGlobalObject* globalObject, + JSC::Identifier moduleKey, + Vector& exportNames, + JSC::MarkedArgumentBuffer& exportValues); + + JSValue exportsObject(); + JSValue id(); + + DECLARE_VISIT_CHILDREN; + + static bool put(JSC::JSCell* cell, JSC::JSGlobalObject* globalObject, + JSC::PropertyName propertyName, JSC::JSValue value, + JSC::PutPropertySlot& slot); + + DECLARE_INFO; + template + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm); + + bool hasEvaluated = false; + + JSCommonJSModule(JSC::VM& vm, JSC::Structure* structure) + : Base(vm, structure) + { + } +}; + +JSCommonJSModule* createCommonJSModuleWithoutRunning( + Zig::GlobalObject* globalObject, + Ref sourceProvider, + const WTF::String& sourceURL, + ResolvedSource source); + JSC::Structure* createCommonJSModuleStructure( Zig::GlobalObject* globalObject); -JSC::SourceCode createCommonJSModule( +std::optional createCommonJSModule( Zig::GlobalObject* globalObject, ResolvedSource source); diff --git a/src/bun.js/bindings/ImportMetaObject.cpp b/src/bun.js/bindings/ImportMetaObject.cpp index a53712823..d201dafca 100644 --- a/src/bun.js/bindings/ImportMetaObject.cpp +++ b/src/bun.js/bindings/ImportMetaObject.cpp @@ -38,6 +38,9 @@ #include "JSDOMURL.h" #include "JavaScriptCore/JSNativeStdFunction.h" #include "JavaScriptCore/GetterSetter.h" +#include +#include +#include namespace Zig { using namespace JSC; @@ -83,10 +86,12 @@ static EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObject, // require.resolve also supports a paths array // we only support a single path if (!fromValue.isUndefinedOrNull() && fromValue.isObject()) { - if (JSValue pathsValue = fromValue.getObject()->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "paths"_s))) { - if (JSC::JSArray* array = JSC::jsDynamicCast(pathsValue)) { - if (array->length() > 0) { - fromValue = array->getIndex(globalObject, 0); + if (auto pathsObject = fromValue.getObject()->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "paths"_s))) { + if (pathsObject.isCell() && pathsObject.asCell()->type() == JSC::JSType::ArrayType) { + auto pathsArray = JSC::jsCast(pathsObject); + if (pathsArray->length() > 0) { + fromValue = pathsArray->getIndex(globalObject, 0); + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); } } } @@ -123,142 +128,135 @@ Zig::ImportMetaObject* Zig::ImportMetaObject::create(JSC::JSGlobalObject* global } JSC_DECLARE_HOST_FUNCTION(jsFunctionRequireResolve); +JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireResolve, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + return functionRequireResolve(globalObject, callFrame, callFrame->thisValue().toWTFString(globalObject)); +} -class JSRequireResolveFunctionPrototype final : public JSC::InternalFunction { -public: - using Base = JSC::InternalFunction; +JSC_DEFINE_CUSTOM_GETTER(jsRequireCacheGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + Zig::GlobalObject* thisObject = jsCast(globalObject); + return JSValue::encode(thisObject->lazyRequireCacheObject()); +} - static JSRequireResolveFunctionPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject) - { - auto* structure = createStructure(vm, globalObject, globalObject->functionPrototype()); - JSRequireResolveFunctionPrototype* function = new (NotNull, JSC::allocateCell(vm)) JSRequireResolveFunctionPrototype(vm, structure); - function->finishCreation(vm); - return function; - } +JSC_DEFINE_CUSTOM_SETTER(jsRequireCacheSetter, + (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, + JSC::EncodedJSValue value, JSC::PropertyName propertyName)) +{ + JSObject* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (!thisObject) + return false; - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } + thisObject->putDirect(globalObject->vm(), propertyName, JSValue::decode(value), 0); + return true; +} - DECLARE_INFO; +JSC_DEFINE_HOST_FUNCTION(requireResolvePathsFunction, (JSGlobalObject * globalObject, CallFrame* callframe)) +{ + return JSValue::encode(JSC::constructEmptyArray(globalObject, nullptr, 0)); +} - static JSC::EncodedJSValue pathsFunction(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) +static const HashTableValue RequireResolveFunctionPrototypeValues[] = { + { "paths"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, requireResolvePathsFunction, 1 } }, +}; + +class RequireResolveFunctionPrototype final : public JSC::JSNonFinalObject { +public: + using Base = JSC::JSNonFinalObject; + static RequireResolveFunctionPrototype* create( + JSC::JSGlobalObject* globalObject) { - return JSValue::encode(JSC::constructEmptyArray(globalObject, nullptr)); + auto& vm = globalObject->vm(); + + auto* structure = RequireResolveFunctionPrototype::createStructure(vm, globalObject, globalObject->functionPrototype()); + RequireResolveFunctionPrototype* prototype = new (NotNull, JSC::allocateCell(vm)) RequireResolveFunctionPrototype(vm, structure); + prototype->finishCreation(vm); + return prototype; } -private: - JSRequireResolveFunctionPrototype(JSC::VM& vm, JSC::Structure* structure) - : JSC::InternalFunction(vm, structure, jsFunctionRequireResolve, jsFunctionRequireResolve) + DECLARE_INFO; + RequireResolveFunctionPrototype( + JSC::VM& vm, + JSC::Structure* structure) + : Base(vm, structure) { } - void finishCreation(JSC::VM& vm) + template + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { - this->putDirectNativeFunction(vm, globalObject(), Identifier::fromString(vm, "paths"_s), 0, pathsFunction, ImplementationVisibility::Public, NoIntrinsic, 0); - Base::finishCreation(vm, 2, "resolve"_s, PropertyAdditionMode::WithoutStructureTransition); + return &vm.plainObjectSpace(); } }; -const JSC::ClassInfo JSRequireResolveFunctionPrototype::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRequireResolveFunctionPrototype) }; +class ResolveFunction final : public JSC::InternalFunction { -class JSRequireResolveFunction final : public JSC::InternalFunction { public: using Base = JSC::InternalFunction; - - static JSRequireResolveFunction* create(JSC::VM& vm, JSC::Structure* structure, const WTF::String& from) - { - JSRequireResolveFunction* function = new (NotNull, JSC::allocateCell(vm)) JSRequireResolveFunction(vm, structure, from); - function->finishCreation(vm); - return function; - } - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + static ResolveFunction* create(JSGlobalObject* globalObject) { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); + JSObject* resolvePrototype = RequireResolveFunctionPrototype::create(globalObject); + Structure* structure = Structure::create( + globalObject->vm(), + globalObject, + resolvePrototype, + JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), + ResolveFunction::info()); + auto* resolveFunction = new (NotNull, JSC::allocateCell(globalObject->vm())) ResolveFunction(globalObject->vm(), structure); + resolveFunction->finishCreation(globalObject->vm()); + return resolveFunction; } DECLARE_INFO; - WTF::String from; - - template static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - if constexpr (mode == JSC::SubspaceAccess::Concurrently) - return nullptr; - - return WebCore::subspaceForImpl( - vm, - [](auto& spaces) { return spaces.m_clientSubspaceForRequireResolveFunction.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForRequireResolveFunction = std::forward(space); }, - [](auto& spaces) { return spaces.m_subspaceForRequireResolveFunction.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForRequireResolveFunction = std::forward(space); }); - } - -private: - JSRequireResolveFunction(JSC::VM& vm, JSC::Structure* structure, const WTF::String& from_) - : JSC::InternalFunction(vm, structure, jsFunctionRequireResolve, jsFunctionRequireResolve) - , from(from_) + template + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { + return &vm.internalFunctionSpace(); } - void finishCreation(JSC::VM& vm) + ResolveFunction( + JSC::VM& vm, + JSC::Structure* structure) + : InternalFunction(vm, structure, jsFunctionRequireResolve, nullptr) { - Base::finishCreation(vm); } }; -const JSC::ClassInfo JSRequireResolveFunction::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRequireResolveFunction) }; - -JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireResolve, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +Structure* Zig::ImportMetaObject::createRequireFunctionStructure(VM& vm, JSGlobalObject* globalObject) { - JSRequireResolveFunction* thisObject = JSC::jsCast(callFrame->jsCallee()); - return functionRequireResolve(globalObject, callFrame, thisObject->from); -} -JSValue Zig::ImportMetaObject::createResolveFunctionPrototype(JSC::VM& vm, Zig::GlobalObject* globalObject) -{ - return JSRequireResolveFunctionPrototype::create(vm, globalObject); + return nullptr; } -JSC::Structure* Zig::ImportMetaObject::createResolveFunctionStructure(JSC::VM& vm, Zig::GlobalObject* globalObject) +JSObject* Zig::ImportMetaObject::createRequireFunction(VM& vm, JSGlobalObject* lexicalGlobalObject, const WTF::String& pathString) { - JSValue prototype = globalObject->requireResolveFunctionPrototype(); - return JSRequireResolveFunction::createStructure(vm, globalObject, prototype); -} + auto* globalObject = lexicalGlobalObject; + JSFunction* requireFunction = JSFunction::create(vm, importMetaObjectRequireCodeGenerator(vm), lexicalGlobalObject); -JSC_DEFINE_CUSTOM_GETTER(jsRequireCacheGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) -{ - Zig::GlobalObject* thisObject = jsCast(globalObject); - return JSValue::encode(thisObject->lazyRequireCacheObject()); -} + JSC::JSFunction* requireDotMainFunction = JSFunction::create( + vm, + moduleMainCodeGenerator(vm), + globalObject->globalScope()); -JSC_DEFINE_CUSTOM_SETTER(jsRequireCacheSetter, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::EncodedJSValue value, JSC::PropertyName propertyName)) -{ - JSObject* thisObject = jsDynamicCast(JSValue::decode(thisValue)); - if (!thisObject) - return false; + requireFunction->putDirect( + vm, + JSC::Identifier::fromString(vm, "main"_s), + JSC::GetterSetter::create(vm, globalObject, requireDotMainFunction, JSValue()), + PropertyAttribute::Builtin | PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | 0); - thisObject->putDirect(globalObject->vm(), propertyName, JSValue::decode(value), 0); - return true; -} + requireFunction->putDirect(vm, JSC::Identifier::fromString(vm, "extensions"_s), JSC::constructEmptyObject(globalObject), 0); + requireFunction->putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "cache"_s), JSC::CustomGetterSetter::create(vm, Zig::jsRequireCacheGetter, Zig::jsRequireCacheSetter), 0); + requireFunction->putDirect(vm, JSC::Identifier::fromString(vm, "resolve"_s), ResolveFunction::create(globalObject), JSC::PropertyAttribute::Function | 0); + requireFunction->putDirect(vm, JSC::Identifier::fromString(vm, "path"_s), jsString(vm, pathString)); -JSObject* Zig::ImportMetaObject::createRequireFunction(VM& vm, JSGlobalObject* lexicalGlobalObject, const WTF::String& pathString) -{ - Zig::GlobalObject* globalObject = static_cast(lexicalGlobalObject); - JSFunction* requireFunction = JSFunction::create(vm, importMetaObjectRequireCodeGenerator(vm), globalObject); - auto* resolveFunction = JSRequireResolveFunction::create(vm, globalObject->requireResolveFunctionStructure(), pathString); - auto clientData = WebCore::clientData(vm); - requireFunction->putDirect(vm, clientData->builtinNames().pathPublicName(), jsString(vm, pathString), PropertyAttribute::DontEnum | 0); - requireFunction->putDirect(vm, clientData->builtinNames().resolvePublicName(), resolveFunction, PropertyAttribute::Function | PropertyAttribute::DontDelete | 0); - requireFunction->putDirectCustomAccessor(vm, Identifier::fromString(vm, "cache"_s), JSC::CustomGetterSetter::create(vm, jsRequireCacheGetter, jsRequireCacheSetter), 0); return requireFunction; } +const JSC::ClassInfo RequireResolveFunctionPrototype::s_info = { "resolve"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(RequireResolveFunctionPrototype) }; +const JSC::ClassInfo ResolveFunction::s_info = { "resolve"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ResolveFunction) }; + extern "C" EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) { JSC::VM& vm = globalObject->vm(); @@ -268,7 +266,7 @@ extern "C" EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObject* g case 0: { // not "requires" because "require" could be confusing - JSC::throwTypeError(globalObject, scope, "import.meta.resolveSync needs 1 argument (a string)"_s); + JSC::throwTypeError(globalObject, scope, "needs 1 argument (a string)"_s); scope.release(); return JSC::JSValue::encode(JSC::JSValue {}); } @@ -276,7 +274,7 @@ extern "C" EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObject* g JSC::JSValue moduleName = callFrame->argument(0); if (moduleName.isUndefinedOrNull()) { - JSC::throwTypeError(globalObject, scope, "import.meta.resolveSync expects a string"_s); + JSC::throwTypeError(globalObject, scope, "expects a string"_s); scope.release(); return JSC::JSValue::encode(JSC::JSValue {}); } @@ -287,27 +285,34 @@ extern "C" EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObject* g if (callFrame->argumentCount() > 1) { JSC::JSValue fromValue = callFrame->argument(1); - // require.resolve also supports a paths array - // we only support a single path - if (!fromValue.isUndefinedOrNull() && fromValue.isObject()) { - if (JSC::JSArray* array = JSC::jsDynamicCast(fromValue.getObject()->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "paths"_s)))) { - if (array->length() > 0) { - fromValue = array->getIndex(globalObject, 0); - } + if (callFrame->argumentCount() > 2) { + JSC::JSValue isESMValue = callFrame->argument(2); + if (isESMValue.isBoolean()) { + isESM = isESMValue.toBoolean(globalObject); + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); } + } - if (callFrame->argumentCount() > 2) { - JSC::JSValue isESMValue = callFrame->argument(2); - if (isESMValue.isBoolean()) { - isESM = isESMValue.toBoolean(globalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + if (!fromValue.isUndefinedOrNull() && fromValue.isObject()) { + + if (auto pathsObject = fromValue.getObject()->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "paths"_s))) { + if (pathsObject.isCell() && pathsObject.asCell()->type() == JSC::JSType::ArrayType) { + auto pathsArray = JSC::jsCast(pathsObject); + if (pathsArray->length() > 0) { + fromValue = pathsArray->getIndex(globalObject, 0); + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + } } } + } else if (fromValue.isBoolean()) { isESM = fromValue.toBoolean(globalObject); RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); } - from = JSC::JSValue::encode(fromValue); + + if (fromValue.isString()) { + from = JSC::JSValue::encode(fromValue); + } } else { JSC::JSObject* thisObject = JSC::jsDynamicCast(callFrame->thisValue()); @@ -318,8 +323,10 @@ extern "C" EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObject* g } auto clientData = WebCore::clientData(vm); + JSValue pathProperty = thisObject->getIfPropertyExists(globalObject, clientData->builtinNames().pathPublicName()); - from = JSC::JSValue::encode(thisObject->get(globalObject, clientData->builtinNames().pathPublicName())); + if (pathProperty && pathProperty.isString()) + from = JSC::JSValue::encode(pathProperty); } auto result = Bun__resolveSync(globalObject, JSC::JSValue::encode(moduleName), from, isESM); @@ -362,7 +369,7 @@ JSC_DEFINE_HOST_FUNCTION(functionImportMeta__resolve, JSC__JSValue from; - if (callFrame->argumentCount() > 1) { + if (callFrame->argumentCount() > 1 && callFrame->argument(1).isString()) { from = JSC::JSValue::encode(callFrame->argument(1)); } else { JSC::JSObject* thisObject = JSC::jsDynamicCast(callFrame->thisValue()); @@ -374,7 +381,7 @@ JSC_DEFINE_HOST_FUNCTION(functionImportMeta__resolve, auto clientData = WebCore::clientData(vm); - from = JSC::JSValue::encode(thisObject->get(globalObject, clientData->builtinNames().pathPublicName())); + from = JSC::JSValue::encode(thisObject->getIfPropertyExists(globalObject, clientData->builtinNames().pathPublicName())); } return Bun__resolve(globalObject, JSC::JSValue::encode(moduleName), from, true); @@ -382,89 +389,235 @@ JSC_DEFINE_HOST_FUNCTION(functionImportMeta__resolve, } } +enum class ImportMetaPropertyOffset : uint32_t { + url, + dir, + file, + path, + require, + +}; +static constexpr uint32_t numberOfImportMetaProperties = 5; + +Zig::ImportMetaObject* ImportMetaObject::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, const WTF::String& url) +{ + ImportMetaObject* ptr = new (NotNull, JSC::allocateCell(vm)) ImportMetaObject(vm, structure, url); + ptr->finishCreation(vm); + return ptr; +} +Zig::ImportMetaObject* ImportMetaObject::create(JSC::JSGlobalObject* jslobalObject, JSC::JSString* keyString) +{ + auto* globalObject = jsCast(jslobalObject); + auto& vm = globalObject->vm(); + auto view = keyString->value(globalObject); + JSC::Structure* structure = globalObject->ImportMetaObjectStructure(); + return Zig::ImportMetaObject::create(vm, globalObject, structure, view); +} + +JSC_DEFINE_CUSTOM_GETTER(jsImportMetaObjectGetter_url, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName propertyName)) +{ + ImportMetaObject* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) + return JSValue::encode(jsUndefined()); + + return JSValue::encode(thisObject->urlProperty.getInitializedOnMainThread(thisObject)); +} +JSC_DEFINE_CUSTOM_GETTER(jsImportMetaObjectGetter_dir, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName propertyName)) +{ + ImportMetaObject* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) + return JSValue::encode(jsUndefined()); + + return JSValue::encode(thisObject->dirProperty.getInitializedOnMainThread(thisObject)); +} +JSC_DEFINE_CUSTOM_GETTER(jsImportMetaObjectGetter_file, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName propertyName)) +{ + ImportMetaObject* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) + return JSValue::encode(jsUndefined()); + + return JSValue::encode(thisObject->fileProperty.getInitializedOnMainThread(thisObject)); +} +JSC_DEFINE_CUSTOM_GETTER(jsImportMetaObjectGetter_path, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName propertyName)) +{ + ImportMetaObject* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) + return JSValue::encode(jsUndefined()); + + return JSValue::encode(thisObject->pathProperty.getInitializedOnMainThread(thisObject)); +} +JSC_DEFINE_CUSTOM_GETTER(jsImportMetaObjectGetter_require, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName propertyName)) +{ + ImportMetaObject* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) + return JSValue::encode(jsUndefined()); + + return JSValue::encode(thisObject->requireProperty.getInitializedOnMainThread(thisObject)); +} + +static const HashTableValue ImportMetaObjectPrototypeValues[] = { + { "resolve"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, functionImportMeta__resolve, 0 } }, + { "resolveSync"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, functionImportMeta__resolveSync, 0 } }, + { "url"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, jsImportMetaObjectGetter_url, 0 } }, + { "dir"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, jsImportMetaObjectGetter_dir, 0 } }, + { "file"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, jsImportMetaObjectGetter_file, 0 } }, + { "path"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, jsImportMetaObjectGetter_path, 0 } }, + { "require"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, jsImportMetaObjectGetter_require, 0 } }, +}; + class ImportMetaObjectPrototype final : public JSC::JSNonFinalObject { public: + DECLARE_INFO; using Base = JSC::JSNonFinalObject; - static ImportMetaObjectPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + static Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { - ImportMetaObjectPrototype* ptr = new (NotNull, JSC::allocateCell(vm)) ImportMetaObjectPrototype(vm, globalObject, structure); - ptr->finishCreation(vm, globalObject); - return ptr; + return Structure::create(vm, globalObject, globalObject->objectPrototype(), TypeInfo(ObjectType, StructureFlags), info()); + } + + static ImportMetaObjectPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + ImportMetaObjectPrototype* prototype = new (NotNull, JSC::allocateCell(vm)) ImportMetaObjectPrototype(vm, structure); + prototype->finishCreation(vm, globalObject); + return prototype; } - DECLARE_INFO; template static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { return &vm.plainObjectSpace(); } - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + + void finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + Base::finishCreation(vm); + + auto* clientData = WebCore::clientData(vm); + auto& builtinNames = clientData->builtinNames(); + + reifyStaticProperties(vm, ImportMetaObject::info(), ImportMetaObjectPrototypeValues, *this); + JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); + + this->putDirect( + vm, + builtinNames.mainPublicName(), + GetterSetter::create(vm, globalObject, JSFunction::create(vm, importMetaObjectMainCodeGenerator(vm), globalObject), nullptr), + JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin | 0); } -private: - ImportMetaObjectPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + ImportMetaObjectPrototype(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure) { } +}; - void finishCreation(JSC::VM&, JSC::JSGlobalObject*); +const ClassInfo ImportMetaObjectPrototype::s_info = { + "ImportMeta"_s, + + Base::info(), nullptr, nullptr, CREATE_METHOD_TABLE(ImportMetaObjectPrototype) }; -STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(ImportMetaObjectPrototype, ImportMetaObjectPrototype::Base); -JSObject* ImportMetaObject::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) +JSC::Structure* ImportMetaObject::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { - return ImportMetaObjectPrototype::create(vm, &globalObject, ImportMetaObjectPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); -} + ImportMetaObjectPrototype* prototype = ImportMetaObjectPrototype::create(vm, + globalObject, + ImportMetaObjectPrototype::createStructure(vm, globalObject)); -void ImportMetaObjectPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject_) -{ - Base::finishCreation(vm); - auto* globalObject = reinterpret_cast(globalObject_); auto clientData = WebCore::clientData(vm); - auto& builtinNames = clientData->builtinNames(); - this->putDirect(vm, builtinNames.filePublicName(), jsEmptyString(vm), 0); - this->putDirect(vm, builtinNames.dirPublicName(), jsEmptyString(vm), 0); - this->putDirect(vm, builtinNames.pathPublicName(), jsEmptyString(vm), 0); - this->putDirect(vm, builtinNames.urlPublicName(), jsEmptyString(vm), 0); - - this->putDirect( - vm, - builtinNames.mainPublicName(), - GetterSetter::create(vm, globalObject, JSFunction::create(vm, importMetaObjectMainCodeGenerator(vm), globalObject), nullptr), - JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin | 0); - - this->putDirect(vm, Identifier::fromString(vm, "primordials"_s), jsUndefined(), JSC::PropertyAttribute::DontEnum | 0); - - String requireString = "[[require]]"_s; - this->putDirect(vm, builtinNames.requirePublicName(), Zig::ImportMetaObject::createRequireFunction(vm, globalObject, requireString), PropertyAttribute::Builtin | PropertyAttribute::Function | 0); - - this->putDirectNativeFunction(vm, globalObject, builtinNames.resolvePublicName(), 1, - functionImportMeta__resolve, - ImplementationVisibility::Public, - NoIntrinsic, - JSC::PropertyAttribute::Function | 0); - this->putDirectNativeFunction( - vm, globalObject, builtinNames.resolveSyncPublicName(), - 1, - functionImportMeta__resolveSync, - ImplementationVisibility::Public, - NoIntrinsic, - JSC::PropertyAttribute::Function | 0); - - JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); + return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), ImportMetaObject::info()); } void ImportMetaObject::finishCreation(VM& vm) { Base::finishCreation(vm); ASSERT(inherits(info())); + + this->requireProperty.initLater([](const JSC::LazyProperty::Initializer& init) { + ImportMetaObject* meta = jsCast(init.owner); + JSFunction* value = jsCast(ImportMetaObject::createRequireFunction(init.vm, meta->globalObject(), meta->url)); + init.set(value); + }); + this->urlProperty.initLater([](const JSC::LazyProperty::Initializer& init) { + ImportMetaObject* meta = jsCast(init.owner); + WTF::URL url = meta->url.startsWith('/') ? WTF::URL::fileURLWithFileSystemPath(meta->url) : WTF::URL(meta->url); + + init.set(jsString(init.vm, url.string())); + }); + this->dirProperty.initLater([](const JSC::LazyProperty::Initializer& init) { + ImportMetaObject* meta = jsCast(init.owner); + + WTF::URL url = meta->url.startsWith('/') ? WTF::URL::fileURLWithFileSystemPath(meta->url) : WTF::URL(meta->url); + WTF::StringView dirname; + + if (url.protocolIs("file"_s)) { + dirname = url.fileSystemPath(); + } else { + dirname = url.path(); + } + + if (dirname.endsWith("/"_s)) { + dirname = dirname.substring(0, dirname.length() - 1); + } else if (dirname.contains('/')) { + dirname = dirname.substring(0, dirname.reverseFind('/')); + } + + init.set(jsString(init.vm, dirname.toString())); + }); + this->fileProperty.initLater([](const JSC::LazyProperty::Initializer& init) { + ImportMetaObject* meta = jsCast(init.owner); + + WTF::URL url = meta->url.startsWith('/') ? WTF::URL::fileURLWithFileSystemPath(meta->url) : WTF::URL(meta->url); + WTF::StringView path; + if (url.protocolIs("file"_s)) { + path = url.fileSystemPath(); + } else { + path = url.path(); + } + + WTF::StringView filename; + + if (path.endsWith("/"_s)) { + filename = path.substring(path.reverseFind('/', path.length() - 2) + 1); + } else { + filename = path.substring(path.reverseFind('/') + 1); + } + + init.set(jsString(init.vm, filename.toString())); + }); + this->pathProperty.initLater([](const JSC::LazyProperty::Initializer& init) { + ImportMetaObject* meta = jsCast(init.owner); + + WTF::URL url = meta->url.startsWith('/') ? WTF::URL::fileURLWithFileSystemPath(meta->url) : WTF::URL(meta->url); + WTF::StringView path; + + if (url.protocolIs("file"_s)) { + path = url.fileSystemPath(); + } else { + path = url.path(); + } + + init.set(jsString(init.vm, path.toString())); + }); } +template +void ImportMetaObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) +{ + ImportMetaObject* fn = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(fn, info()); + Base::visitChildren(fn, visitor); + + fn->requireProperty.visit(visitor); + fn->urlProperty.visit(visitor); + fn->dirProperty.visit(visitor); + fn->fileProperty.visit(visitor); + fn->pathProperty.visit(visitor); +} + +DEFINE_VISIT_CHILDREN(ImportMetaObject); + void ImportMetaObject::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) { auto* thisObject = jsCast(cell); @@ -475,9 +628,6 @@ void ImportMetaObject::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } -const JSC::ClassInfo ImportMetaObjectPrototype::s_info = { "ImportMeta"_s, &Base::s_info, nullptr, nullptr, - CREATE_METHOD_TABLE(ImportMetaObjectPrototype) }; - const JSC::ClassInfo ImportMetaObject::s_info = { "ImportMeta"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ImportMetaObject) }; } diff --git a/src/bun.js/bindings/ImportMetaObject.h b/src/bun.js/bindings/ImportMetaObject.h index d0f8f0963..2794ddbb6 100644 --- a/src/bun.js/bindings/ImportMetaObject.h +++ b/src/bun.js/bindings/ImportMetaObject.h @@ -18,97 +18,55 @@ namespace Zig { using namespace JSC; using namespace WebCore; -class ImportMetaObject final : public JSC::JSDestructibleObject { +JSC_DECLARE_CUSTOM_GETTER(jsRequireCacheGetter); +JSC_DECLARE_CUSTOM_SETTER(jsRequireCacheSetter); + +class ImportMetaObject final : public JSC::JSNonFinalObject { public: - using Base = JSC::JSDestructibleObject; + using Base = JSC::JSNonFinalObject; - static ImportMetaObject* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) - { - ImportMetaObject* ptr = new (NotNull, JSC::allocateCell(vm)) ImportMetaObject(vm, globalObject, structure); - ptr->finishCreation(vm); - return ptr; - } + static ImportMetaObject* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, const WTF::String& url); - static JSC::Structure* createResolveFunctionStructure(JSC::VM& vm, Zig::GlobalObject* globalObject); - static JSValue createResolveFunctionPrototype(JSC::VM& vm, Zig::GlobalObject* globalObject); + static JSC::Structure* createRequireFunctionStructure(JSC::VM& vm, JSGlobalObject* globalObject); static JSObject* createRequireFunction(VM& vm, JSGlobalObject* lexicalGlobalObject, const WTF::String& pathString); - static ImportMetaObject* create(JSC::JSGlobalObject* globalObject, JSC::JSValue key); - - static inline Zig::ImportMetaObject* create(JSC::JSGlobalObject* globalObject, JSC::JSString* keyString) - { - // TODO: optimize this by reusing the same JSC::Structure object and using putDirectOffset - auto& vm = globalObject->vm(); - auto view = keyString->value(globalObject); - JSC::Structure* structure = WebCore::getDOMStructure(vm, *reinterpret_cast(globalObject)); - Zig::ImportMetaObject* metaProperties = Zig::ImportMetaObject::create(vm, globalObject, structure); - if (UNLIKELY(!metaProperties)) { - return nullptr; - } - - auto clientData = WebCore::clientData(vm); - auto& builtinNames = clientData->builtinNames(); - - auto index = view.reverseFind('/', view.length()); - if (index != WTF::notFound) { - metaProperties->putDirect(vm, builtinNames.dirPublicName(), - JSC::jsSubstring(globalObject, keyString, 0, index)); - metaProperties->putDirect( - vm, builtinNames.filePublicName(), - JSC::jsSubstring(globalObject, keyString, index + 1, view.length() - index - 1)); - } else { - metaProperties->putDirect(vm, builtinNames.filePublicName(), keyString); - } - metaProperties->putDirect( - vm, - builtinNames.pathPublicName(), - keyString, - 0); - - metaProperties->putDirect( - vm, - builtinNames.requirePublicName(), - Zig::ImportMetaObject::createRequireFunction(vm, globalObject, view), - PropertyAttribute::Builtin | PropertyAttribute::Function | 0); - - if (view.startsWith('/')) { - metaProperties->putDirect(vm, builtinNames.urlPublicName(), JSC::JSValue(JSC::jsString(vm, WTF::URL::fileURLWithFileSystemPath(view).string()))); - } else { - if (view.startsWith("node:"_s) || view.startsWith("bun:"_s)) { - metaProperties->putDirect(globalObject->vm(), JSC::Identifier::fromString(globalObject->vm(), "primordials"_s), reinterpret_cast(globalObject)->primordialsObject()); - } - metaProperties->putDirect(vm, builtinNames.urlPublicName(), keyString); - } - - return metaProperties; - } + static ImportMetaObject* create(JSC::JSGlobalObject* globalObject, JSC::JSString* keyString); + static ImportMetaObject* create(JSC::JSGlobalObject* globalObject, JSValue keyString); DECLARE_INFO; + DECLARE_VISIT_CHILDREN; - static constexpr bool needsDestruction = true; - - template - static CompleteSubspace* subspaceFor(VM& vm) + template static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { - return &vm.destructibleObjectSpace(); - } + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + return WebCore::subspaceForImpl( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForImportMeta.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForImportMeta = std::forward(space); }, + [](auto& spaces) { return spaces.m_subspaceForImportMeta.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForImportMeta = std::forward(space); }); } - static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject); static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + WTF::String url; + LazyProperty requireProperty; + LazyProperty dirProperty; + LazyProperty urlProperty; + LazyProperty fileProperty; + LazyProperty pathProperty; + private: - ImportMetaObject(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + ImportMetaObject(JSC::VM& vm, JSC::Structure* structure, const WTF::String& url) : Base(vm, structure) + , url(url) { } void finishCreation(JSC::VM&); }; -STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(ImportMetaObject, ImportMetaObject::Base); } \ No newline at end of file diff --git a/src/bun.js/bindings/ModuleLoader.cpp b/src/bun.js/bindings/ModuleLoader.cpp index ed1e5702b..0ccbb7dbb 100644 --- a/src/bun.js/bindings/ModuleLoader.cpp +++ b/src/bun.js/bindings/ModuleLoader.cpp @@ -36,6 +36,11 @@ #include "../modules/TTYModule.h" #include "node_util_types.h" #include "CommonJSModuleRecord.h" +#include +#include +#include +#include +#include namespace Bun { using namespace Zig; @@ -350,6 +355,110 @@ extern "C" void Bun__onFulfillAsyncModule( promise->resolve(promise->globalObject(), JSC::JSSourceCode::create(vm, JSC::SourceCode(provider))); } +JSValue fetchCommonJSModule( + Zig::GlobalObject* globalObject, + JSCommonJSModule* target, + JSValue specifierValue, + BunString* specifier, + BunString* referrer) +{ + void* bunVM = globalObject->bunVM(); + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + ErrorableResolvedSource resValue; + ErrorableResolvedSource* res = &resValue; + + auto& builtinNames = WebCore::clientData(vm)->builtinNames(); + + if (Bun__fetchBuiltinModule(bunVM, globalObject, specifier, referrer, res)) { + if (!res->success) { + throwException(scope, res->result.err, globalObject); + return JSValue(); + } + + switch (res->result.value.tag) { + case SyntheticModuleType::Module: { + target->evaluate(globalObject, Bun::toWTFString(*specifier), generateNodeModuleModule); + RETURN_IF_EXCEPTION(scope, {}); + RELEASE_AND_RETURN(scope, target); + } + + case SyntheticModuleType::Buffer: { + target->evaluate(globalObject, Bun::toWTFString(*specifier), generateBufferSourceCode); + RETURN_IF_EXCEPTION(scope, {}); + RELEASE_AND_RETURN(scope, target); + } + case SyntheticModuleType::TTY: { + target->evaluate(globalObject, Bun::toWTFString(*specifier), generateTTYSourceCode); + RETURN_IF_EXCEPTION(scope, {}); + RELEASE_AND_RETURN(scope, target); + } + case SyntheticModuleType::NodeUtilTypes: { + target->evaluate(globalObject, Bun::toWTFString(*specifier), Bun::generateNodeUtilTypesSourceCode); + RETURN_IF_EXCEPTION(scope, {}); + RELEASE_AND_RETURN(scope, target); + } + case SyntheticModuleType::Process: { + target->evaluate(globalObject, Bun::toWTFString(*specifier), generateProcessSourceCode); + RETURN_IF_EXCEPTION(scope, {}); + RELEASE_AND_RETURN(scope, target); + } + case SyntheticModuleType::Events: { + target->evaluate(globalObject, Bun::toWTFString(*specifier), generateEventsSourceCode); + RETURN_IF_EXCEPTION(scope, {}); + RELEASE_AND_RETURN(scope, target); + } + case SyntheticModuleType::StringDecoder: { + target->evaluate(globalObject, Bun::toWTFString(*specifier), generateStringDecoderSourceCode); + RETURN_IF_EXCEPTION(scope, {}); + RELEASE_AND_RETURN(scope, target); + } + default: { + RELEASE_AND_RETURN(scope, jsNumber(-1)); + } + } + } + + // if (JSC::JSValue virtualModuleResult = JSValue::decode(Bun__runVirtualModule(globalObject, specifier))) { + // return handleVirtualModuleResult(globalObject, virtualModuleResult, res, specifier, referrer); + // } + auto* loader = globalObject->moduleLoader(); + JSMap* registry = jsCast(loader->getDirect(vm, Identifier::fromString(vm, "registry"_s))); + + auto hasAlreadyLoadedESMVersionSoWeShouldntTranspileItTwice = [&]() -> bool { + JSValue entry = registry->get(globalObject, specifierValue); + + if (!entry || !entry.isObject()) { + return false; + } + + int status = entry.getObject()->getDirect(vm, WebCore::clientData(vm)->builtinNames().statePublicName()).asInt32(); + return status > JSModuleLoader::Status::Fetch; + }; + + if (hasAlreadyLoadedESMVersionSoWeShouldntTranspileItTwice()) { + RELEASE_AND_RETURN(scope, jsNumber(-1)); + } + + Bun__transpileFile(bunVM, globalObject, specifier, referrer, res, false); + + if (res->success && res->result.value.commonJSExportsLen) { + target->evaluate(globalObject, Bun::toWTFString(*specifier).isolatedCopy(), res->result.value); + RETURN_IF_EXCEPTION(scope, {}); + RELEASE_AND_RETURN(scope, target); + } + + if (!res->success) { + throwException(scope, res->result.err, globalObject); + RELEASE_AND_RETURN(scope, {}); + } + + auto&& provider = Zig::SourceProvider::create(globalObject, res->result.value); + globalObject->moduleLoader()->provideFetch(globalObject, specifierValue, JSC::SourceCode(provider)); + RETURN_IF_EXCEPTION(scope, {}); + RELEASE_AND_RETURN(scope, jsNumber(-1)); +} + template static JSValue fetchSourceCode( Zig::GlobalObject* globalObject, @@ -382,6 +491,11 @@ static JSValue fetchSourceCode( auto rejectOrResolve = [&](JSValue code) -> JSValue { if (auto* exception = scope.exception()) { + if constexpr (!allowPromise) { + scope.release(); + return {}; + } + scope.clearException(); return rejectedInternalPromise(globalObject, exception); } @@ -457,7 +571,7 @@ static JSValue fetchSourceCode( return rejectOrResolve(JSSourceCode::create(vm, WTFMove(source))); } default: { - auto&& provider = Zig::SourceProvider::create(globalObject, res->result.value); + auto&& provider = Zig::SourceProvider::create(globalObject, res->result.value, JSC::SourceProviderSourceType::Module, true); return rejectOrResolve(JSC::JSSourceCode::create(vm, JSC::SourceCode(provider))); } } @@ -477,8 +591,19 @@ static JSValue fetchSourceCode( } if (res->success && res->result.value.commonJSExportsLen) { - auto source = Bun::createCommonJSModule(globalObject, res->result.value); - return rejectOrResolve(JSSourceCode::create(vm, WTFMove(source))); + auto created = Bun::createCommonJSModule(globalObject, res->result.value); + + if (created.has_value()) { + return rejectOrResolve(JSSourceCode::create(vm, WTFMove(created.value()))); + } + + if constexpr (allowPromise) { + auto* exception = scope.exception(); + scope.clearException(); + return rejectedInternalPromise(globalObject, exception); + } else { + return JSC::jsUndefined(); + } } if (!res->success) { diff --git a/src/bun.js/bindings/ModuleLoader.h b/src/bun.js/bindings/ModuleLoader.h index 0deaeff08..6eb04bf40 100644 --- a/src/bun.js/bindings/ModuleLoader.h +++ b/src/bun.js/bindings/ModuleLoader.h @@ -15,6 +15,8 @@ class JSInternalPromise; namespace Bun { using namespace JSC; +class JSCommonJSModule; + typedef uint8_t OnLoadResultType; const OnLoadResultType OnLoadResultTypeError = 0; const OnLoadResultType OnLoadResultTypeCode = 1; @@ -91,4 +93,11 @@ JSValue fetchSourceCodeAsync( BunString* specifier, BunString* referrer); +JSValue fetchCommonJSModule( + Zig::GlobalObject* globalObject, + JSCommonJSModule* moduleObject, + JSValue specifierValue, + BunString* specifier, + BunString* referrer); + } // namespace Bun \ No newline at end of file diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index e49b94687..401485f51 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -361,8 +361,8 @@ JSC_DEFINE_HOST_FUNCTION(functionFulfillModuleSync, &specifier, &specifier); - if (result.isUndefined() || !result) { - return JSValue::encode(result); + if (scope.exception() || !result) { + RELEASE_AND_RETURN(scope, JSValue::encode(JSC::jsUndefined())); } globalObject->moduleLoader()->provideFetch(globalObject, key, jsCast(result)->sourceCode()); @@ -1271,10 +1271,12 @@ JSC_DEFINE_HOST_FUNCTION(functionCallNotImplemented, // we're trying out a new way to do this lazy loading static JSC_DEFINE_HOST_FUNCTION(functionLazyLoad, - (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) + (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { JSC: + Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); VM& vm = globalObject->vm(); + switch (callFrame->argumentCount()) { case 0: { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); @@ -1283,13 +1285,6 @@ JSC: return JSC::JSValue::encode(JSC::JSValue {}); } default: { - static NeverDestroyed sqliteString(MAKE_STATIC_STRING_IMPL("sqlite")); - static NeverDestroyed bunJSCString(MAKE_STATIC_STRING_IMPL("bun:jsc")); - static NeverDestroyed bunStreamString(MAKE_STATIC_STRING_IMPL("bun:stream")); - static NeverDestroyed noopString(MAKE_STATIC_STRING_IMPL("noop")); - static NeverDestroyed createImportMeta(MAKE_STATIC_STRING_IMPL("createImportMeta")); - static NeverDestroyed masqueradesAsUndefined(MAKE_STATIC_STRING_IMPL("masqueradesAsUndefined")); - static NeverDestroyed vmString(MAKE_STATIC_STRING_IMPL("vm")); JSC::JSValue moduleName = callFrame->argument(0); if (moduleName.isNumber()) { @@ -1328,24 +1323,24 @@ JSC: return JSC::JSValue::encode(JSC::JSValue {}); } - if (string == sqliteString) { + if (string == "sqlite"_s) { return JSC::JSValue::encode(JSSQLStatementConstructor::create(vm, globalObject, JSSQLStatementConstructor::createStructure(vm, globalObject, globalObject->m_functionPrototype.get()))); } - if (string == bunJSCString) { + if (string == "bun:jsc"_s) { return JSC::JSValue::encode(createJSCModule(globalObject)); } - if (string == pathToFileURLString) { + if (string == "pathToFileURL"_s) { return JSValue::encode( JSFunction::create(vm, globalObject, 1, pathToFileURLString, functionPathToFileURL, ImplementationVisibility::Public, NoIntrinsic)); } - if (string == fileURLToPathString) { + if (string == "fileURLToPath"_s) { return JSValue::encode( JSFunction::create(vm, globalObject, 1, fileURLToPathString, functionFileURLToPath, ImplementationVisibility::Public, NoIntrinsic)); } - if (string == bunStreamString) { + if (string == "bun:stream"_s) { auto* obj = constructEmptyObject(globalObject); obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "BufferList"_s)), reinterpret_cast(globalObject)->JSBufferList(), 0); obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "ReadableState"_s)), reinterpret_cast(globalObject)->JSReadableState(), 0); @@ -1364,16 +1359,16 @@ JSC: return JSValue::encode(obj); } - if (string == createImportMeta) { + if (string == "createImportMeta"_s) { Zig::ImportMetaObject* obj = Zig::ImportMetaObject::create(globalObject, callFrame->argument(1)); return JSValue::encode(obj); } - if (string == masqueradesAsUndefined) { + if (string == "masqueradesAsUndefined"_s) { return JSValue::encode(InternalFunction::createFunctionThatMasqueradesAsUndefined(vm, globalObject, 0, String(), functionCallNotImplemented)); } - if (string == vmString) { + if (string == "vm"_s) { auto* obj = constructEmptyObject(globalObject); obj->putDirect( vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "Script"_s)), @@ -1394,7 +1389,22 @@ JSC: return JSValue::encode(obj); } - if (UNLIKELY(string == noopString)) { + if (string == "vm"_s) { + auto* obj = constructEmptyObject(globalObject); + } + + if (string == "primordials"_s) { + auto sourceOrigin = callFrame->callerSourceOrigin(vm).url(); + bool isBuiltin = sourceOrigin.protocolIs("builtin"_s); + if (!isBuiltin) { + return JSC::JSValue::encode(JSC::jsUndefined()); + } + + auto* obj = globalObject->primordialsObject(); + return JSValue::encode(obj); + } + + if (UNLIKELY(string == "noop"_s)) { auto* obj = constructEmptyObject(globalObject); obj->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "getterSetter"_s)), JSC::CustomGetterSetter::create(vm, noop_getter, noop_setter), 0); Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, reinterpret_cast(globalObject), 0, String(), functionNoop, JSC::NoIntrinsic); @@ -2721,7 +2731,7 @@ void GlobalObject::finishCreation(VM& vm) JSC::Structure* structure = globalObject->structureCache().emptyObjectStructureForPrototype( globalObject, globalObject->objectPrototype(), - 5); + 3); JSC::PropertyOffset offset; auto& vm = globalObject->vm(); @@ -2732,13 +2742,6 @@ void GlobalObject::finishCreation(VM& vm) 0, offset); - structure = structure->addPropertyTransition( - vm, - structure, - JSC::Identifier::fromString(vm, "exports"_s), - 0, - offset); - structure = structure->addPropertyTransition( vm, structure, @@ -2753,13 +2756,6 @@ void GlobalObject::finishCreation(VM& vm) 0, offset); - structure = structure->addPropertyTransition( - vm, - structure, - JSC::Identifier::fromString(vm, "require"_s), - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::Builtin | 0, - offset); - init.set(structure); }); @@ -2979,14 +2975,14 @@ void GlobalObject::finishCreation(VM& vm) init.set(structure); }); - m_requireResolveFunctionStructure.initLater( + m_importMetaRequireStructure.initLater( [](const JSC::LazyProperty::Initializer& init) { - init.set(Zig::ImportMetaObject::createResolveFunctionStructure(init.vm, jsCast(init.owner))); + init.set(Zig::ImportMetaObject::createRequireFunctionStructure(init.vm, jsCast(init.owner))); }); - m_resolveFunctionPrototype.initLater( - [](const JSC::LazyProperty::Initializer& init) { - init.set(Zig::ImportMetaObject::createResolveFunctionPrototype(init.vm, jsCast(init.owner)).getObject()); + m_importMetaObjectStructure.initLater( + [](const JSC::LazyProperty::Initializer& init) { + init.set(Zig::ImportMetaObject::createStructure(init.vm, init.owner)); }); m_JSFileSinkClassStructure.initLater( @@ -3434,7 +3430,7 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm) auto& builtinNames = WebCore::builtinNames(vm); WTF::Vector extraStaticGlobals; - extraStaticGlobals.reserveCapacity(43); + extraStaticGlobals.reserveCapacity(44); JSC::Identifier queueMicrotaskIdentifier = JSC::Identifier::fromString(vm, "queueMicrotask"_s); extraStaticGlobals.uncheckedAppend( @@ -3655,30 +3651,44 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm) PUT_WEBCORE_GENERATED_CONSTRUCTOR("Headers"_s, JSFetchHeaders); PUT_WEBCORE_GENERATED_CONSTRUCTOR("URLSearchParams"_s, JSURLSearchParams); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().TransformStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamConstructor, nullptr), attributesForStructure(static_cast(JSC::PropertyAttribute::DontEnum))); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().TransformStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamConstructor, nullptr), attributesForStructure(static_cast(JSC::PropertyAttribute::DontEnum))); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().TransformStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), attributesForStructure(static_cast(JSC::PropertyAttribute::DontEnum))); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().TransformStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), attributesForStructure(static_cast(JSC::PropertyAttribute::DontEnum))); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableByteStreamControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamBYOBReaderPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamBYOBRequestPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamDefaultReaderPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().WritableStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().WritableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().WritableStreamDefaultWriterPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().AbortSignalPrivateName(), CustomGetterSetter::create(vm, JSDOMAbortSignal_getter, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableByteStreamControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamBYOBReaderPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamBYOBRequestPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().ReadableStreamDefaultReaderPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().WritableStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().WritableStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - putDirectCustomAccessor(vm, static_cast(vm.clientData)->builtinNames().WritableStreamDefaultWriterPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - + putDirectCustomAccessor(vm, builtinNames.TransformStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamConstructor, nullptr), attributesForStructure(static_cast(JSC::PropertyAttribute::DontEnum))); + putDirectCustomAccessor(vm, builtinNames.TransformStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamConstructor, nullptr), attributesForStructure(static_cast(JSC::PropertyAttribute::DontEnum))); + putDirectCustomAccessor(vm, builtinNames.TransformStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), attributesForStructure(static_cast(JSC::PropertyAttribute::DontEnum))); + putDirectCustomAccessor(vm, builtinNames.TransformStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), attributesForStructure(static_cast(JSC::PropertyAttribute::DontEnum))); + putDirectCustomAccessor(vm, builtinNames.ReadableByteStreamControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamBYOBReaderPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamBYOBRequestPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamDefaultReaderPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); + putDirectCustomAccessor(vm, builtinNames.WritableStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); + putDirectCustomAccessor(vm, builtinNames.WritableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); + putDirectCustomAccessor(vm, builtinNames.WritableStreamDefaultWriterPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)); + putDirectCustomAccessor(vm, builtinNames.AbortSignalPrivateName(), CustomGetterSetter::create(vm, JSDOMAbortSignal_getter, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, builtinNames.ReadableByteStreamControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamBYOBReaderPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamBYOBRequestPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, builtinNames.ReadableStreamDefaultReaderPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, builtinNames.WritableStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, builtinNames.WritableStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + putDirectCustomAccessor(vm, builtinNames.WritableStreamDefaultWriterPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + + putDirectNativeFunction(vm, this, + builtinNames.createCommonJSModulePrivateName(), + 2, + Bun::jsFunctionCreateCommonJSModule, + ImplementationVisibility::Public, + NoIntrinsic, + JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + putDirectNativeFunction(vm, this, + builtinNames.evaluateCommonJSModulePrivateName(), + 2, + Bun::jsFunctionLoadModule, + ImplementationVisibility::Public, + NoIntrinsic, + JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ByteLengthQueuingStrategy"_s), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "CountQueuingStrategy"_s), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_CountQueuingStrategyConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "SubtleCrypto"_s), JSC::CustomGetterSetter::create(vm, getterSubtleCryptoConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); @@ -4023,8 +4033,9 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) thisObject->m_emitReadableNextTickFunction.visit(visitor); thisObject->m_JSBufferSubclassStructure.visit(visitor); - thisObject->m_requireResolveFunctionStructure.visit(visitor); - thisObject->m_resolveFunctionPrototype.visit(visitor); + thisObject->m_importMetaRequireStructure.visit(visitor); + thisObject->m_importMetaObjectStructure.visit(visitor); + thisObject->m_dnsObject.visit(visitor); thisObject->m_lazyRequireCacheObject.visit(visitor); thisObject->m_vmModuleContextMap.visit(visitor); diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index 2d69e764f..daf0abc5b 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -248,8 +248,7 @@ public: JSC::JSFunction* emitReadableNextTickFunction() { return m_emitReadableNextTickFunction.getInitializedOnMainThread(this); } - Structure* requireResolveFunctionStructure() { return m_requireResolveFunctionStructure.getInitializedOnMainThread(this); } - JSObject* requireResolveFunctionPrototype() { return m_resolveFunctionPrototype.getInitializedOnMainThread(this); } + Structure* importMetaRequireStructure() { return m_importMetaRequireStructure.getInitializedOnMainThread(this); } JSObject* lazyRequireCacheObject() { return m_lazyRequireCacheObject.getInitializedOnMainThread(this); } @@ -262,6 +261,7 @@ public: JSObject* lazyTestModuleObject() { return m_lazyTestModuleObject.getInitializedOnMainThread(this); } JSObject* lazyPreloadTestModuleObject() { return m_lazyPreloadTestModuleObject.getInitializedOnMainThread(this); } Structure* CommonJSModuleObjectStructure() { return m_commonJSModuleObjectStructure.getInitializedOnMainThread(this); } + Structure* ImportMetaObjectStructure() { return m_importMetaObjectStructure.getInitializedOnMainThread(this); } Structure* commonJSFunctionArgumentsStructure() { return m_commonJSFunctionArgumentsStructure.getInitializedOnMainThread(this); } @@ -481,8 +481,6 @@ private: LazyProperty m_subtleCryptoObject; LazyProperty m_JSHTTPResponseController; LazyProperty m_JSBufferSubclassStructure; - LazyProperty m_requireResolveFunctionStructure; - LazyProperty m_resolveFunctionPrototype; LazyProperty m_dnsObject; LazyProperty m_vmModuleContextMap; LazyProperty m_lazyRequireCacheObject; @@ -496,6 +494,9 @@ private: LazyProperty m_commonJSModuleObjectStructure; LazyProperty m_commonJSFunctionArgumentsStructure; + LazyProperty m_importMetaRequireStructure; + LazyProperty m_importMetaObjectStructure; + DOMGuardedObjectSet m_guardedObjects WTF_GUARDED_BY_LOCK(m_gcLock); void* m_bunVM; diff --git a/src/bun.js/bindings/ZigSourceProvider.cpp b/src/bun.js/bindings/ZigSourceProvider.cpp index ab3062cd5..dda7135b4 100644 --- a/src/bun.js/bindings/ZigSourceProvider.cpp +++ b/src/bun.js/bindings/ZigSourceProvider.cpp @@ -43,21 +43,24 @@ static uintptr_t getSourceProviderMapKey(ResolvedSource& resolvedSource) } } -Ref SourceProvider::create(Zig::GlobalObject* globalObject, ResolvedSource resolvedSource, JSC::SourceProviderSourceType sourceType) +static SourceOrigin toSourceOrigin(const String& sourceURL, bool isBuiltin) { - - uintptr_t providerKey = 0; - if (globalObject->isThreadLocalDefaultGlobalObject) { - auto& sourceProviderMap = globalObject->sourceProviderMap; - providerKey = getSourceProviderMapKey(resolvedSource); - if (providerKey) { - auto sourceProvider = sourceProviderMap.get(providerKey); - if (sourceProvider != nullptr) { - sourceProvider->ref(); - return adoptRef(*reinterpret_cast(sourceProvider)); - } + if (isBuiltin) { + if (sourceURL.startsWith("node:"_s)) { + return SourceOrigin(WTF::URL(makeString("builtin://node/", sourceURL.substring(5)))); + } else if (sourceURL.startsWith("bun:"_s)) { + return SourceOrigin(WTF::URL(makeString("builtin://bun/", sourceURL.substring(4)))); + } else { + return SourceOrigin(WTF::URL(makeString("builtin://", sourceURL))); } } + + return SourceOrigin(WTF::URL::fileURLWithFileSystemPath(sourceURL)); +} + +Ref SourceProvider::create(Zig::GlobalObject* globalObject, ResolvedSource resolvedSource, JSC::SourceProviderSourceType sourceType, bool isBuiltin) +{ + auto stringImpl = Bun::toWTFString(resolvedSource.source_code); auto sourceURLString = toStringCopy(resolvedSource.source_url); @@ -68,14 +71,10 @@ Ref SourceProvider::create(Zig::GlobalObject* globalObject, Reso auto provider = adoptRef(*new SourceProvider( globalObject->isThreadLocalDefaultGlobalObject ? globalObject : nullptr, resolvedSource, stringImpl.releaseImpl().releaseNonNull(), - JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(sourceURLString)), + toSourceOrigin(sourceURLString, isBuiltin), sourceURLString.impl(), TextPosition(), sourceType)); - if (providerKey) { - globalObject->sourceProviderMap.set(providerKey, provider.copyRef()); - } - return provider; } @@ -90,11 +89,6 @@ unsigned SourceProvider::hash() const void SourceProvider::freeSourceCode() { - if (m_globalObjectForSourceProviderMap) { - m_globalObjectForSourceProviderMap->sourceProviderMap.remove((uintptr_t)m_source.get().characters8()); - } - - m_source = *WTF::StringImpl::empty(); } void SourceProvider::updateCache(const UnlinkedFunctionExecutable* executable, const SourceCode&, diff --git a/src/bun.js/bindings/ZigSourceProvider.h b/src/bun.js/bindings/ZigSourceProvider.h index dd78b20ae..c189cc454 100644 --- a/src/bun.js/bindings/ZigSourceProvider.h +++ b/src/bun.js/bindings/ZigSourceProvider.h @@ -34,7 +34,7 @@ class SourceProvider final : public JSC::SourceProvider { using SourceOrigin = JSC::SourceOrigin; public: - static Ref create(Zig::GlobalObject*, ResolvedSource resolvedSource, JSC::SourceProviderSourceType sourceType = JSC::SourceProviderSourceType::Module); + static Ref create(Zig::GlobalObject*, ResolvedSource resolvedSource, JSC::SourceProviderSourceType sourceType = JSC::SourceProviderSourceType::Module, bool isBuiltIn = false); ~SourceProvider() { freeSourceCode(); diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 2c2f5c2ea..3f3d82dc4 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -3912,36 +3912,6 @@ void JSC__VM__throwError(JSC__VM* vm_, JSC__JSGlobalObject* arg1, JSC__JSValue v scope.throwException(arg1, exception); } -#pragma mark - JSC::ThrowScope - -void JSC__ThrowScope__clearException(JSC__ThrowScope* arg0) -{ - arg0->clearException(); -}; -bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2, - size_t arg3) -{ - Wrap wrapped = Wrap(); - wrapped.cpp = new (wrapped.alignedBuffer()) JSC::ThrowScope(reinterpret_cast(arg0)); - return wrapped.result; -}; -JSC__Exception* JSC__ThrowScope__exception(JSC__ThrowScope* arg0) { return arg0->exception(); } -void JSC__ThrowScope__release(JSC__ThrowScope* arg0) { arg0->release(); } - -#pragma mark - JSC::CatchScope - -void JSC__CatchScope__clearException(JSC__CatchScope* arg0) -{ - arg0->clearException(); -} -bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2, - size_t arg3) -{ - JSC::CatchScope scope = JSC::CatchScope(reinterpret_cast(arg0)); - return cast(&scope); -} -JSC__Exception* JSC__CatchScope__exception(JSC__CatchScope* arg0) { return arg0->exception(); } - JSC__JSValue JSC__JSPromise__rejectedPromiseValue(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1) { @@ -4103,9 +4073,18 @@ restart: if (key.len == 0) return true; - JSC::JSValue propertyValue = objectToUse == object ? objectToUse->getDirect(entry.offset()) : JSValue(); + JSC::JSValue propertyValue = JSValue(); + + if (objectToUse == object) { + propertyValue = objectToUse->getDirect(entry.offset()); + if (!propertyValue) { + scope.clearException(); + return true; + } + } + if (!propertyValue || propertyValue.isGetterSetter() && !((entry.attributes() & PropertyAttribute::Accessor) != 0)) { - propertyValue = objectToUse->get(globalObject, prop); + propertyValue = objectToUse->getIfPropertyExists(globalObject, prop); } if (scope.exception()) diff --git a/src/bun.js/bindings/node_util_types.cpp b/src/bun.js/bindings/node_util_types.cpp index 0c75662cf..f7ae3949e 100644 --- a/src/bun.js/bindings/node_util_types.cpp +++ b/src/bun.js/bindings/node_util_types.cpp @@ -322,7 +322,7 @@ void generateNodeUtilTypesSourceCode(JSC::JSGlobalObject* lexicalGlobalObject, JSC::VM& vm = globalObject->vm(); - JSC::JSObject* defaultObject = constructEmptyObject(globalObject, globalObject->objectPrototype(), 43); + JSC::JSObject* defaultObject = constructEmptyObject(globalObject, globalObject->objectPrototype(), 42); exportNames.reserveCapacity(43); exportValues.ensureCapacity(43); diff --git a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h index 3997c1d88..65875d091 100644 --- a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h @@ -29,6 +29,7 @@ public: std::unique_ptr m_clientSubspaceForReadableState; std::unique_ptr m_clientSubspaceForPendingVirtualModuleResult; std::unique_ptr m_clientSubspaceForCallSite; + std::unique_ptr m_clientSubspaceForImportMeta; std::unique_ptr m_clientSubspaceForNapiExternal; std::unique_ptr m_clientSubspaceForRequireResolveFunction; std::unique_ptr m_clientSubspaceForBundlerPlugin; diff --git a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h index 4feca1754..433832450 100644 --- a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h @@ -30,6 +30,7 @@ public: std::unique_ptr m_subspaceForPendingVirtualModuleResult; std::unique_ptr m_subspaceForCallSite; std::unique_ptr m_subspaceForNapiExternal; + std::unique_ptr m_subspaceForImportMeta; std::unique_ptr m_subspaceForRequireResolveFunction; std::unique_ptr m_subspaceForBundlerPlugin; std::unique_ptr m_subspaceForNodeVMScript; diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index e249bba8b..5838d8a49 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -1836,8 +1836,7 @@ pub const ModuleLoader = struct { .@"node:wasi" => return jsResolvedSource(jsc_vm, jsc_vm.load_builtins_from_path, .@"node:wasi", "node/wasi.js", specifier), .@"node:zlib" => return jsResolvedSource(jsc_vm, jsc_vm.load_builtins_from_path, .@"node:zlib", "node/zlib.js", specifier), - .@"detect-libc" => return jsResolvedSource(jsc_vm, jsc_vm.load_builtins_from_path, .depd, if (Environment.isLinux) "thirdparty/detect-libc.linux.js" else "thirdparty/detect-libc.js", specifier), - .depd => return jsResolvedSource(jsc_vm, jsc_vm.load_builtins_from_path, .depd, "thirdparty/depd.js", specifier), + .@"detect-libc" => return jsResolvedSource(jsc_vm, jsc_vm.load_builtins_from_path, .@"detect-libc", if (Environment.isLinux) "thirdparty/detect-libc.linux.js" else "thirdparty/detect-libc.js", specifier), .undici => return jsResolvedSource(jsc_vm, jsc_vm.load_builtins_from_path, .undici, "thirdparty/undici.js", specifier), .ws => return jsResolvedSource(jsc_vm, jsc_vm.load_builtins_from_path, .ws, "thirdparty/ws.js", specifier), @@ -1851,7 +1850,9 @@ pub const ModuleLoader = struct { .@"node:v8" => return jsResolvedSource(jsc_vm, jsc_vm.load_builtins_from_path, .@"node:v8", "node/v8.js", specifier), } } else if (specifier.hasPrefixComptime(js_ast.Macro.namespaceWithColon)) { - if (jsc_vm.macro_entry_points.get(MacroEntryPoint.generateIDFromSpecifier(specifier.byteSlice()))) |entry| { + const spec = specifier.toUTF8(bun.default_allocator); + defer spec.deinit(); + if (jsc_vm.macro_entry_points.get(MacroEntryPoint.generateIDFromSpecifier(spec.slice()))) |entry| { return ResolvedSource{ .allocator = null, .source_code = bun.String.create(entry.source.contents), @@ -1864,10 +1865,9 @@ pub const ModuleLoader = struct { return ResolvedSource{ .allocator = null, .source_code = bun.String.static( - \\const symbol = Symbol.for("CommonJS"); - \\const lazy = globalThis[Symbol.for("Bun.lazy")]; - \\var masqueradesAsUndefined = lazy("masqueradesAsUndefined"); - \\masqueradesAsUndefined[symbol] = 0; + \\var masqueradesAsUndefined=globalThis[Symbol.for("Bun.lazy")]("masqueradesAsUndefined"); + \\masqueradesAsUndefined[Symbol.for("CommonJS")]=0; + \\masqueradesAsUndefined.default=masqueradesAsUndefined; \\export default masqueradesAsUndefined; \\ ), @@ -2021,7 +2021,6 @@ pub const HardcodedModule = enum { @"node:vm", @"node:wasi", @"node:zlib", - depd, undici, ws, // These are all not implemented yet, but are stubbed @@ -2047,7 +2046,6 @@ pub const HardcodedModule = enum { .{ "bun:main", HardcodedModule.@"bun:main" }, .{ "bun:sqlite", HardcodedModule.@"bun:sqlite" }, .{ "bun:events_native", HardcodedModule.@"bun:events_native" }, - .{ "depd", HardcodedModule.depd }, .{ "detect-libc", HardcodedModule.@"detect-libc" }, .{ "node:assert", HardcodedModule.@"node:assert" }, .{ "node:assert/strict", HardcodedModule.@"node:assert/strict" }, @@ -2118,7 +2116,6 @@ pub const HardcodedModule = enum { .{ "bun:events_native", .{ .path = "bun:events_native" } }, .{ "child_process", .{ .path = "node:child_process" } }, .{ "crypto", .{ .path = "node:crypto" } }, - .{ "depd", .{ .path = "depd" } }, .{ "detect-libc", .{ .path = "detect-libc" } }, .{ "detect-libc/lib/detect-libc.js", .{ .path = "detect-libc" } }, .{ "dns", .{ .path = "node:dns" } }, diff --git a/src/bun.js/modules/BufferModule.h b/src/bun.js/modules/BufferModule.h index 42eab5173..a96fb18c8 100644 --- a/src/bun.js/modules/BufferModule.h +++ b/src/bun.js/modules/BufferModule.h @@ -29,10 +29,13 @@ inline void generateBufferSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, JSC::JSObject *defaultObject = JSC::constructEmptyObject( globalObject, globalObject->objectPrototype(), 12); - defaultObject->putDirect(vm, - PropertyName(Identifier::fromUid( - vm.symbolRegistry().symbolForKey("CommonJS"_s))), - jsNumber(0), 0); + auto CommonJS = + Identifier::fromUid(vm.symbolRegistry().symbolForKey("CommonJS"_s)); + + defaultObject->putDirect(vm, PropertyName(CommonJS), jsNumber(0), 0); + + exportNames.append(CommonJS); + exportValues.append(jsNumber(0)); auto exportProperty = [&](JSC::Identifier name, JSC::JSValue value) { exportNames.append(name); diff --git a/src/bun.js/modules/ProcessModule.h b/src/bun.js/modules/ProcessModule.h index 3c9c3261f..2df74598a 100644 --- a/src/bun.js/modules/ProcessModule.h +++ b/src/bun.js/modules/ProcessModule.h @@ -50,26 +50,23 @@ inline void generateProcessSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, process->getPropertyNames(globalObject, properties, DontEnumPropertiesMode::Exclude); - exportNames.append(JSC::Identifier::fromString(vm, "default"_s)); - JSFunction *processModuleCommonJS = JSFunction::create( - vm, globalObject, 0, "process"_s, jsFunctionProcessModuleCommonJS, - ImplementationVisibility::Public); - processModuleCommonJS->putDirect( - vm, - PropertyName( - Identifier::fromUid(vm.symbolRegistry().symbolForKey("CommonJS"_s))), - jsBoolean(true), 0); - exportValues.append(processModuleCommonJS); + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(process); + + exportNames.append( + Identifier::fromUid(vm.symbolRegistry().symbolForKey("CommonJS"_s))); + exportValues.append(jsNumber(0)); for (auto &entry : properties) { exportNames.append(entry); - exportValues.append(process->get(globalObject, entry)); - processModuleCommonJS->putDirectCustomAccessor( - vm, entry, - JSC::CustomGetterSetter::create(vm, - jsFunctionProcessModuleCommonJSGetter, - jsFunctionProcessModuleCommonJSSetter), - 0); + auto catchScope = DECLARE_CATCH_SCOPE(vm); + JSValue result = process->get(globalObject, entry); + if (catchScope.exception()) { + result = jsUndefined(); + catchScope.clearException(); + } + + exportValues.append(result); } } diff --git a/src/bun.js/modules/StringDecoderModule.h b/src/bun.js/modules/StringDecoderModule.h index c3b5f57bb..1dbf5ef8e 100644 --- a/src/bun.js/modules/StringDecoderModule.h +++ b/src/bun.js/modules/StringDecoderModule.h @@ -16,11 +16,11 @@ generateStringDecoderSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, exportNames.append(JSC::Identifier::fromString(vm, "StringDecoder"_s)); exportValues.append(globalObject->JSStringDecoder()); + auto CommonJS = + Identifier::fromUid(vm.symbolRegistry().symbolForKey("CommonJS"_s)); + JSC::JSObject *defaultObject = constructEmptyObject(globalObject); - defaultObject->putDirect(vm, - PropertyName(Identifier::fromUid( - vm.symbolRegistry().symbolForKey("CommonJS"_s))), - jsNumber(0), 0); + defaultObject->putDirect(vm, PropertyName(CommonJS), jsNumber(0), 0); for (size_t i = 0; i < exportNames.size(); i++) { defaultObject->putDirect(vm, exportNames[i], exportValues.at(i), 0); @@ -28,6 +28,9 @@ generateStringDecoderSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, exportNames.append(vm.propertyNames->defaultKeyword); exportValues.append(defaultObject); + + exportNames.append(CommonJS); + exportValues.append(jsNumber(0)); } } // namespace Zig diff --git a/src/bun.js/modules/TTYModule.h b/src/bun.js/modules/TTYModule.h index 423268b32..79bc8c871 100644 --- a/src/bun.js/modules/TTYModule.h +++ b/src/bun.js/modules/TTYModule.h @@ -62,17 +62,20 @@ inline void generateTTYSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, tty->putDirect(vm, JSC::Identifier::fromString(vm, "WriteStream"_s), notimpl); exportValues.append(notimpl); - tty->putDirect(vm, - PropertyName(Identifier::fromUid( - vm.symbolRegistry().symbolForKey("CommonJS"_s))), - jsNumber(0), 0); - for (size_t i = 0; i < exportNames.size(); i++) { tty->putDirect(vm, exportNames[i], exportValues.at(i), 0); } exportNames.append(vm.propertyNames->defaultKeyword); exportValues.append(tty); + + auto CommonJS = + Identifier::fromUid(vm.symbolRegistry().symbolForKey("CommonJS"_s)); + + exportNames.append(CommonJS); + exportValues.append(jsNumber(0)); + + tty->putDirect(vm, PropertyName(CommonJS), jsNumber(0), 0); } } // namespace Zig diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index d19a2da26..1e63ea3a2 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -599,11 +599,14 @@ pub const Blob = struct { } var needs_async = false; + if (data.isString()) { + defer if (!needs_async and path_or_blob == .path) path_or_blob.path.deinit(); + const len = data.getLength(ctx); if (len < 256 * 1024 or bun.isMissingIOUring()) { - const str = data.getZigString(ctx); + const str = data.toBunString(ctx); const pathlike: JSC.Node.PathOrFileDescriptor = if (path_or_blob == .path) path_or_blob.path @@ -635,6 +638,8 @@ pub const Blob = struct { } } } else if (data.asArrayBuffer(ctx)) |buffer_view| { + defer if (!needs_async and path_or_blob == .path) path_or_blob.path.deinit(); + if (buffer_view.byte_len < 256 * 1024 or bun.isMissingIOUring()) { const pathlike: JSC.Node.PathOrFileDescriptor = if (path_or_blob == .path) path_or_blob.path @@ -784,7 +789,7 @@ pub const Blob = struct { fn writeStringToFileFast( globalThis: *JSC.JSGlobalObject, pathlike: JSC.Node.PathOrFileDescriptor, - str: ZigString, + str: bun.String, needs_async: *bool, comptime needs_open: bool, ) JSC.JSValue { @@ -807,7 +812,7 @@ pub const Blob = struct { unreachable; }; - var truncate = needs_open or str.len == 0; + var truncate = needs_open or str.isEmpty(); var jsc_vm = globalThis.bunVM(); var written: usize = 0; @@ -822,62 +827,12 @@ pub const Blob = struct { _ = JSC.Node.Syscall.close(fd); } } - if (str.len == 0) {} else if (str.is16Bit()) { - var decoded = str.toSlice(jsc_vm.allocator); + if (!str.isEmpty()) { + var decoded = str.toUTF8(jsc_vm.allocator); defer decoded.deinit(); var remain = decoded.slice(); - const end = remain.ptr + remain.len; - - while (remain.ptr != end) { - const result = JSC.Node.Syscall.write(fd, remain); - switch (result) { - .result => |res| { - written += res; - remain = remain[res..]; - if (res == 0) break; - }, - .err => |err| { - truncate = false; - if (err.getErrno() == .AGAIN) { - needs_async.* = true; - return .zero; - } - return JSC.JSPromise.rejectedPromiseValue(globalThis, err.toJSC(globalThis)); - }, - } - } - } else if (str.isUTF8() or strings.isAllASCII(str.slice())) { - var remain = str.slice(); - const end = remain.ptr + remain.len; - - while (remain.ptr != end) { - const result = JSC.Node.Syscall.write(fd, remain); - switch (result) { - .result => |res| { - written += res; - remain = remain[res..]; - if (res == 0) break; - }, - .err => |err| { - truncate = false; - if (err.getErrno() == .AGAIN) { - needs_async.* = true; - return .zero; - } - - return JSC.JSPromise.rejectedPromiseValue(globalThis, err.toJSC(globalThis)); - }, - } - } - } else { - var decoded = str.toOwnedSlice(jsc_vm.allocator) catch { - return JSC.JSPromise.rejectedPromiseValue(globalThis, ZigString.static("Out of memory").toErrorInstance(globalThis)); - }; - defer jsc_vm.allocator.free(decoded); - var remain = decoded; - const end = remain.ptr + remain.len; - while (remain.ptr != end) { + while (remain.len > 0) { const result = JSC.Node.Syscall.write(fd, remain); switch (result) { .result => |res| { diff --git a/src/js/builtins/BunBuiltinNames.h b/src/js/builtins/BunBuiltinNames.h index 640d122ca..af9291918 100644 --- a/src/js/builtins/BunBuiltinNames.h +++ b/src/js/builtins/BunBuiltinNames.h @@ -1,5 +1,15 @@ #pragma once + +#ifdef ASSERT_ENABLED +#if ASSERT_ENABLED +#define ORIGINAL_ASSERT_ENABLED 1 +#undef ASSERT_ENABLED +#define ASSERT_ENABLED 0 +#endif +#endif + + #include "JavaScriptCore/BuiltinUtils.h" #include "root.h" @@ -49,11 +59,11 @@ using namespace JSC; macro(cloneArrayBuffer) \ macro(close) \ macro(closeAlgorithm) \ - macro(closeRequest) \ - macro(closeRequested) \ macro(closed) \ macro(closedPromise) \ macro(closedPromiseCapability) \ + macro(closeRequest) \ + macro(closeRequested) \ macro(code) \ macro(commonJSSymbol) \ macro(connect) \ @@ -61,6 +71,7 @@ using namespace JSC; macro(controlledReadableStream) \ macro(controller) \ macro(cork) \ + macro(createCommonJSModule) \ macro(createEmptyReadableStream) \ macro(createFIFO) \ macro(createNativeReadableStream) \ @@ -93,13 +104,11 @@ using namespace JSC; macro(file) \ macro(filePath) \ macro(fillFromJS) \ - macro(filter) \ macro(finishConsumingStream) \ macro(flush) \ macro(flushAlgorithm) \ macro(format) \ macro(fulfillModuleSync) \ - macro(get) \ macro(getInternalWritableStream) \ macro(handleEvent) \ macro(hash) \ @@ -128,7 +137,7 @@ using namespace JSC; macro(lazyLoad) \ macro(lazyStreamPrototypeMap) \ macro(loadCJS2ESM) \ - macro(loadModule) \ + macro(evaluateCommonJSModule) \ macro(localStreams) \ macro(main) \ macro(makeDOMException) \ @@ -265,3 +274,9 @@ private: }; } // namespace WebCore + +#ifdef ORIGINAL_ASSERT_ENABLED +#undef ASSERT_ENABLED +#define ASSERT_ENABLED 1 +#undef ORIGINAL_ASSERT_ENABLED +#endif diff --git a/src/js/builtins/ImportMetaObject.ts b/src/js/builtins/ImportMetaObject.ts index 7fc8b5fe8..23b795735 100644 --- a/src/js/builtins/ImportMetaObject.ts +++ b/src/js/builtins/ImportMetaObject.ts @@ -8,9 +8,9 @@ export function loadCJS2ESM(this: ImportMetaObject, resolvedSpecifier: string) { // we need to explicitly check because state could be $ModuleFetch // it will throw this error if we do not: // $throwTypeError("Requested module is already fetched."); - var entry = loader.registry.$get(key); + var entry = loader.registry.$get(key)!; - if (!entry || !entry.state || entry.state <= $ModuleFetch) { + if ((entry?.state ?? 0) <= $ModuleFetch) { $fulfillModuleSync(key); entry = loader.registry.$get(key)!; } @@ -24,14 +24,14 @@ export function loadCJS2ESM(this: ImportMetaObject, resolvedSpecifier: string) { // so we just pull it out of the promise here once again // But, this time we do it a little more carefully because this is a JSC function call and not bun source code var moduleRecordPromise = loader.parseModule(key, sourceCodeObject); - var module = entry.module; - if (!module && moduleRecordPromise && $isPromise(moduleRecordPromise)) { + var mod = entry.module; + if (moduleRecordPromise && $isPromise(moduleRecordPromise)) { var reactionsOrResult = $getPromiseInternalField(moduleRecordPromise, $promiseFieldReactionsOrResult); var flags = $getPromiseInternalField(moduleRecordPromise, $promiseFieldFlags); var state = flags & $promiseStateMask; // this branch should never happen, but just to be safe if (state === $promiseStatePending || (reactionsOrResult && $isPromise(reactionsOrResult))) { - throw new TypeError(`require() async module "${key}" is unsupported`); + throw new TypeError(`require() async module "${key}" is unsupported. use "await import()" instead.`); } else if (state === $promiseStateRejected) { if (!reactionsOrResult?.message) { throw new TypeError( @@ -43,15 +43,15 @@ export function loadCJS2ESM(this: ImportMetaObject, resolvedSpecifier: string) { throw reactionsOrResult; } - entry.module = module = reactionsOrResult; - } else if (moduleRecordPromise && !module) { - entry.module = module = moduleRecordPromise as LoaderModule; + entry.module = mod = reactionsOrResult; + } else if (moduleRecordPromise && !mod) { + entry.module = mod = moduleRecordPromise as LoaderModule; } // This is very similar to "requestInstantiate" in ModuleLoader.js in JavaScriptCore. $setStateToMax(entry, $ModuleLink); - var dependenciesMap = module.dependenciesMap; - var requestedModules = loader.requestedModules(module); + var dependenciesMap = mod.dependenciesMap; + var requestedModules = loader.requestedModules(mod); var dependencies = $newArrayWithSize(requestedModules.length); for (var i = 0, length = requestedModules.length; i < length; ++i) { var depName = requestedModules[i]; @@ -59,6 +59,7 @@ export function loadCJS2ESM(this: ImportMetaObject, resolvedSpecifier: string) { // we don't need to run the resolver a 2nd time var depKey = depName[0] === "/" ? depName : loader.resolve(depName, key); var depEntry = loader.ensureRegistered(depKey); + if (depEntry.state < $ModuleLink) { queue.push(depKey); } @@ -81,7 +82,9 @@ export function loadCJS2ESM(this: ImportMetaObject, resolvedSpecifier: string) { if (linkAndEvaluateResult && $isPromise(linkAndEvaluateResult)) { // if you use top-level await, or any dependencies use top-level await, then we throw here // this means the module will still actually load eventually, but that's okay. - throw new TypeError(`require() async module \"${resolvedSpecifier}\" is unsupported`); + throw new TypeError( + `require() async module \"${resolvedSpecifier}\" is unsupported. use "await import()" instead.`, + ); } return loader.registry.$get(resolvedSpecifier); @@ -104,152 +107,114 @@ export function requireESM(this: ImportMetaObject, resolved) { return; } - var commonJS = exports.default; - var cjs = commonJS?.[$commonJSSymbol]; - if (cjs === 0) { - return commonJS; - } else if (cjs && $isCallable(commonJS)) { - return commonJS(); - } - return exports; } -export function internalRequire(this: ImportMetaObject, resolved) { - var cached = $requireMap.$get(resolved); - const last5 = resolved.substring(resolved.length - 5); +export function internalRequire(this: ImportMetaObject, id) { + var cached = $requireMap.$get(id); + const last5 = id.substring(id.length - 5); if (cached) { - if (last5 === ".node") { - return cached.exports; - } - return cached; + return cached.exports; } // TODO: remove this hardcoding if (last5 === ".json") { var fs = (globalThis[Symbol.for("_fs")] ||= Bun.fs()); - var exports = JSON.parse(fs.readFileSync(resolved, "utf8")); - $requireMap.$set(resolved, exports); + var exports = JSON.parse(fs.readFileSync(id, "utf8")); + $requireMap.$set(id, $createCommonJSModule(id, exports, true)); return exports; } else if (last5 === ".node") { - var module = { exports: {} }; - process.dlopen(module, resolved); - $requireMap.$set(resolved, module); + const module = $createCommonJSModule(id, {}, true); + process.dlopen(module, id); + $requireMap.$set(id, module); return module.exports; } else if (last5 === ".toml") { var fs = (globalThis[Symbol.for("_fs")] ||= Bun.fs()); - var exports = Bun.TOML.parse(fs.readFileSync(resolved, "utf8")); - $requireMap.$set(resolved, exports); + var exports = Bun.TOML.parse(fs.readFileSync(id, "utf8")); + $requireMap.$set(id, $createCommonJSModule(id, exports, true)); return exports; } else { - var exports = $requireESM(resolved); - const cachedExports = $requireMap.$get(resolved); - if (cachedExports) { - return cachedExports; + var exports = $requireESM(id); + const cachedModule = $requireMap.$get(id); + if (cachedModule) { + return cachedModule.exports; } - - $requireMap.$set(resolved, exports); + var defaultExport = exports?.default; + if (defaultExport?.[$commonJSSymbol] === 0) { + exports = defaultExport; + } + $requireMap.$set(id, $createCommonJSModule(id, exports, true)); return exports; } } export function createRequireCache() { - class Module { - id; - parent; - filename; - children = []; - paths = []; - - constructor(filename) { - this.id = filename; - // TODO: windows - const lastSlash = filename.lastIndexOf("/"); - if (lastSlash !== -1 && filename.length > lastSlash + 1) { - this.filename = filename.substring(lastSlash + 1); - } else { - this.filename = filename; + var moduleMap = new Map(); + var inner = {}; + return new Proxy(inner, { + get(target, key: string) { + const entry = $requireMap.$get(key); + if (entry) return entry; + + const esm = Loader.registry.$get(key); + if (esm?.evaluated) { + const namespace = Loader.getModuleNamespaceObject(esm.module); + const exports = + namespace[$commonJSSymbol] === 0 || namespace.default?.[$commonJSSymbol] ? namespace.default : namespace; + const mod = $createCommonJSModule(key, exports, true); + $requireMap.$set(key, mod); + return mod; } - } - get loaded() { + return inner[key]; + }, + set(target, key: string, value) { + $requireMap.$set(key, value); return true; - } - - require(path) { - return $internalRequire($resolveSync(path, this.id)); - } - - get exports() { - return $requireMap.$get(this.id) ?? {}; - } + }, - set exports(value) { - $requireMap.$set(this.id, value); - } - } + has(target, key: string) { + return $requireMap.$has(key) || Loader.registry.$has(key); + }, - var moduleMap = new Map(); + deleteProperty(target, key: string) { + moduleMap.$delete(key); + $requireMap.$delete(key); + Loader.registry.$delete(key); + return true; + }, - return new Proxy( - {}, - { - get(target, key: string) { - const entry = $requireMap.$get(key); - if (entry) { - var mod = moduleMap.$get(key); - if (!mod) { - mod = new Module(key); - moduleMap.$set(key, mod); - } - return mod; + ownKeys(target) { + var array = [...$requireMap.$keys()]; + const registryKeys = [...Loader.registry.$keys()]; + for (const key of registryKeys) { + if (!array.includes(key)) { + $arrayPush(array, key); } - }, - set(target, key: string, value) { - if (!moduleMap.$has(key)) { - moduleMap.$set(key, new Module(key)); - } - - $requireMap.$set(key, value?.exports); - - return true; - }, - - has(target, key: string) { - return $requireMap.$has(key); - }, - - deleteProperty(target, key: string) { - moduleMap.$delete(key); - $requireMap.$delete(key); - Loader.registry.$delete(key); - return true; - }, + } - ownKeys(target) { - return [...$requireMap.$keys()]; - }, + return array; + }, - // In Node, require.cache has a null prototype - getPrototypeOf(target) { - return null; - }, + // In Node, require.cache has a null prototype + getPrototypeOf(target) { + return null; + }, - getOwnPropertyDescriptor(target, key: string) { - if ($requireMap.$has(key)) { - return { - configurable: true, - enumerable: true, - }; - } - }, + getOwnPropertyDescriptor(target, key: string) { + if ($requireMap.$has(key) || Loader.registry.$has(key)) { + return { + configurable: true, + enumerable: true, + }; + } }, - ); + }); } $sloppy; export function require(this: ImportMetaObject, name) { - var from = this?.path ?? arguments.callee.path; + var from = this?.path ?? arguments.callee?.path; if (typeof name !== "string") { throw new TypeError("require(name) must be a string"); diff --git a/src/js/builtins/Module.ts b/src/js/builtins/Module.ts new file mode 100644 index 000000000..ebfc1c477 --- /dev/null +++ b/src/js/builtins/Module.ts @@ -0,0 +1,94 @@ +interface Module { + id: string; + path: string; + + $require(id: string, mod: any): any; + children: Module[]; +} + +$getter; +export function main() { + return $requireMap.$get(Bun.main); +} + +export function require(this: Module, id: string) { + const existing = $requireMap.$get(id) || $requireMap.$get((id = $resolveSync(id, this.path, false))); + if (existing) { + // Scenario where this is necessary: + // + // In an ES Module, we have: + // + // import "react-dom/server" + // import "react" + // + // Synchronously, the "react" import is created first, and then the + // "react-dom/server" import is created. Then, at ES Module link time, they + // are evaluated. The "react-dom/server" import is evaluated first, and + // require("react") was previously created as an ESM module, so we wait + // for the ESM module to load + // + // ...and then when this code is reached, unless + // we evaluate it "early", we'll get an empty object instead of the module + // exports. + // + $evaluateCommonJSModule(existing); + return existing.exports; + } + + if (id.endsWith(".json") || id.endsWith(".toml") || id.endsWith(".node")) { + return $internalRequire(id); + } + + let esm = Loader.registry.$get(id); + if (esm?.evaluated) { + const mod = esm.module; + const namespace = Loader.getModuleNamespaceObject(mod); + const exports = + namespace?.[$commonJSSymbol] === 0 || namespace?.default?.[$commonJSSymbol] === 0 ? namespace.default : namespace; + $requireMap.$set(id, $createCommonJSModule(id, exports, true)); + return exports; + } + + // To handle import/export cycles, we need to create a module object and put + // it into the map before we import it. + const mod = $createCommonJSModule(id, {}, false); + $requireMap.$set(id, mod); + + // This is where we load the module. We will see if Module._load and + // Module._compile are actually important for compatibility. + // + // Note: we do not need to wrap this in a try/catch, if it throws the C++ code will + // clear the module from the map. + // + var out = this.$require(id, mod); + + // -1 means we need to lookup the module from the ESM registry. + if (out === -1) { + try { + out = $requireESM(id); + } catch (exception) { + // Since the ESM code is mostly JS, we need to handle exceptions here. + $requireMap.$delete(id); + throw exception; + } + + esm = Loader.registry.$get(id); + + // If we can pull out a ModuleNamespaceObject, let's do it. + if (esm?.evaluated) { + const namespace = Loader.getModuleNamespaceObject(esm!.module); + return (mod.exports = + // if they choose a module + namespace?.[$commonJSSymbol] === 0 || namespace?.default?.[$commonJSSymbol] === 0 + ? namespace.default + : namespace); + } + } + + $evaluateCommonJSModule(mod); + return mod.exports; +} + +export function requireResolve(this: Module, id: string) { + return $resolveSync(id, this.path, false); +} diff --git a/src/js/builtins/builtins.d.ts b/src/js/builtins/builtins.d.ts index d2e7037dc..449c9c128 100644 --- a/src/js/builtins/builtins.d.ts +++ b/src/js/builtins/builtins.d.ts @@ -341,9 +341,9 @@ declare function $releaseLock(): TODO; declare function $removeEventListener(): TODO; declare function $require(): TODO; declare function $requireESM(path: string): any; -declare const $requireMap: Map; +declare const $requireMap: Map; declare function $resolve(name: string, from: string): Promise; -declare function $resolveSync(name: string, from: string): string; +declare function $resolveSync(name: string, from: string, isESM?: boolean): string; declare function $resume(): TODO; declare function $search(): TODO; declare function $searchParams(): TODO; @@ -402,6 +402,8 @@ declare function $writer(): TODO; declare function $writing(): TODO; declare function $written(): TODO; +declare function $createCommonJSModule(id: string, exports: any, hasEvaluated: boolean): NodeModule; + // The following I cannot find any definitions of, but they are functional. declare function $toLength(length: number): number; declare function $isTypedArrayView(obj: unknown): obj is ArrayBufferView | DataView | Uint8Array; diff --git a/src/js/builtins/tsconfig.json b/src/js/builtins/tsconfig.json index f8b12c5c3..6cdbe0eef 100644 --- a/src/js/builtins/tsconfig.json +++ b/src/js/builtins/tsconfig.json @@ -3,5 +3,11 @@ "compilerOptions": { "noEmit": true }, - "include": [".", "../private.d.ts", "builtins.d.ts", "../generated/builtins/WebCoreJSBuiltins.d.ts", "../../../packages/bun-types/index.d.ts"] + "include": [ + ".", + "../private.d.ts", + "builtins.d.ts", + "../out/WebCoreJSBuiltins.d.ts", + "../../../packages/bun-types/index.d.ts" + ] } diff --git a/src/js/node/assert.js b/src/js/node/assert.js index 3cf158f57..ba4df43cc 100644 --- a/src/js/node/assert.js +++ b/src/js/node/assert.js @@ -1,43 +1,12 @@ // Hardcoded module "node:assert" -var { Bun } = import.meta.primordials; +var { Bun } = globalThis[Symbol.for("Bun.lazy")]("primordials"); +import util from "node:util"; + var isDeepEqual = Bun.deepEquals; -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf, - __hasOwnProp = Object.prototype.hasOwnProperty; -var __markAsModule = target => __defProp(target, "__esModule", { value: !0 }); var __commonJS = (cb, mod) => function () { return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; -var __reExport = (target, module2, desc) => { - if ((module2 && typeof module2 == "object") || typeof module2 == "function") - for (let key of __getOwnPropNames(module2)) - !__hasOwnProp.call(target, key) && - key !== "default" && - __defProp(target, key, { - get: () => module2[key], - enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable, - }); - return target; - }, - __toModule = module2 => - __reExport( - __markAsModule( - __defProp( - module2 != null ? __create(__getProtoOf(module2)) : {}, - "default", - module2 && module2.__esModule && "default" in module2 - ? { get: () => module2.default, enumerable: !0 } - : { value: module2, enumerable: !0 }, - ), - ), - module2, - ); - -var require = path => import.meta.require(path); // assert/build/internal/errors.js var require_errors = __commonJS({ @@ -175,7 +144,6 @@ var require_errors = __commonJS({ "ERR_INVALID_ARG_VALUE", function (name, value) { var reason = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "is invalid"; - util === void 0 && (util = require("util")); var inspected = util.inspect(value); return ( inspected.length > 128 && (inspected = "".concat(inspected.slice(0, 128), "...")), @@ -387,8 +355,7 @@ var require_assertion_error = __commonJS({ _typeof(obj) ); } - var _require = require("util"), - inspect = _require.inspect, + var inspect = util.inspect, _require2 = require_errors(), ERR_INVALID_ARG_TYPE = _require2.codes.ERR_INVALID_ARG_TYPE; function endsWith(str, search, this_len) { @@ -871,9 +838,9 @@ var require_assert = __commonJS({ ERR_INVALID_RETURN_VALUE = _require$codes.ERR_INVALID_RETURN_VALUE, ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, AssertionError = require_assertion_error(), - _require2 = require("util"), + _require2 = util, inspect = _require2.inspect, - _require$types = require("util").types, + _require$types = util.types, isPromise = _require$types.isPromise, isRegExp = _require$types.isRegExp, objectAssign = Object.assign, diff --git a/src/js/node/async_hooks.js b/src/js/node/async_hooks.js index 7887bb64f..ec82ce8aa 100644 --- a/src/js/node/async_hooks.js +++ b/src/js/node/async_hooks.js @@ -1,8 +1,5 @@ // Hardcoded module "node:async_hooks" -var drainMicrotasks = () => { - ({ drainMicrotasks } = import.meta.require("bun:jsc")); - drainMicrotasks(); -}; +import { drainMicrotasks } from "bun:jsc"; var notImplemented = () => { console.warn( diff --git a/src/js/node/child_process.js b/src/js/node/child_process.js index 691c9e096..29b203219 100644 --- a/src/js/node/child_process.js +++ b/src/js/node/child_process.js @@ -1,15 +1,11 @@ // Hardcoded module "node:child_process" -const EventEmitter = import.meta.require("node:events"); -const { - Readable: { fromWeb: ReadableFromWeb }, - NativeWritable, -} = import.meta.require("node:stream"); -const { - constants: { signals }, -} = import.meta.require("node:os"); -const { promisify } = import.meta.require("node:util"); - -const { ArrayBuffer, Uint8Array, String, Object, Buffer, Promise } = import.meta.primordials; +import { EventEmitter } from "node:events"; +import * as StreamModule from "node:stream"; +import { constants } from "node:os"; +import { promisify } from "node:util"; +const signals = constants.signals; + +const { ArrayBuffer, Uint8Array, String, Object, Buffer, Promise } = globalThis[Symbol.for("Bun.lazy")]("primordials"); var ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty; var ObjectCreate = Object.create; @@ -21,8 +17,6 @@ var BufferIsEncoding = Buffer.isEncoding; var kEmptyObject = ObjectCreate(null); var ArrayPrototypePush = Array.prototype.push; -var ArrayPrototypeReduce = Array.prototype.reduce; -var ArrayPrototypeFilter = Array.prototype.filter; var ArrayPrototypeJoin = Array.prototype.join; var ArrayPrototypeMap = Array.prototype.map; var ArrayPrototypeIncludes = Array.prototype.includes; @@ -60,6 +54,9 @@ if (__TRACK_STDIO__) { }; } +var NativeWritable; +var ReadableFromWeb; + // Sections: // 1. Exported child_process functions // 2. child_process helpers @@ -961,6 +958,10 @@ export class ChildProcess extends EventEmitter { debug("ChildProcess: getBunSpawnIo: this.#handle is undefined"); } } + + NativeWritable ||= StreamModule.NativeWritable; + ReadableFromWeb ||= StreamModule.Readable.fromWeb; + const io = this.#stdioOptions[i]; switch (i) { case 0: { @@ -979,15 +980,7 @@ export class ChildProcess extends EventEmitter { case 1: { switch (io) { case "pipe": - return ReadableFromWeb( - this.#handle[fdToStdioName(i)], - __TRACK_STDIO__ - ? { - encoding, - __id: `PARENT_${fdToStdioName(i).toUpperCase()}-${globalThis.__getId()}`, - } - : { encoding }, - ); + return ReadableFromWeb(this.#handle[fdToStdioName(i)], { encoding }); case "inherit": return process[fdToStdioName(i)] || null; case "destroyed": diff --git a/src/js/node/crypto.js b/src/js/node/crypto.js index a644499c8..3791bdcd9 100644 --- a/src/js/node/crypto.js +++ b/src/js/node/crypto.js @@ -5,10 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; +import { StringDecoder } from "node:string_decoder"; +import * as BufferModule from "node:buffer"; +import * as StreamModule from "node:stream"; const MAX_STRING_LENGTH = 536870888; - -var __require = id => import.meta.require(id); +var Buffer = globalThis.Buffer; const crypto = globalThis.crypto; const globalCrypto = crypto; @@ -48,7 +50,7 @@ var __export = (target, all) => { // node_modules/safe-buffer/index.js var require_safe_buffer = __commonJS({ "node_modules/safe-buffer/index.js"(exports, module) { - var buffer = __require("buffer"), + var buffer = BufferModule, Buffer2 = buffer.Buffer; function copyProps(src, dst) { for (var key in src) dst[key] = src[key]; @@ -146,21 +148,20 @@ var require_hash_base = __commonJS({ "node_modules/hash-base/index.js"(exports, module) { "use strict"; var Buffer2 = require_safe_buffer().Buffer, - Transform = __require("readable-stream").Transform, inherits = require_inherits_browser(); function throwIfNotStringOrBuffer(val, prefix) { if (!Buffer2.isBuffer(val) && typeof val != "string") throw new TypeError(prefix + " must be a string or a buffer"); } function HashBase(blockSize) { - Transform.call(this), + StreamModule.Transform.call(this), (this._block = Buffer2.allocUnsafe(blockSize)), (this._blockSize = blockSize), (this._blockOffset = 0), (this._length = [0, 0, 0, 0]), (this._finalized = !1); } - inherits(HashBase, Transform); + inherits(HashBase, StreamModule.Transform); HashBase.prototype._transform = function (chunk, encoding, callback) { var error = null; try { @@ -341,7 +342,7 @@ var require_md5 = __commonJS({ var require_ripemd160 = __commonJS({ "node_modules/ripemd160/index.js"(exports, module) { "use strict"; - var Buffer2 = __require("buffer").Buffer, + var Buffer2 = Buffer, inherits = require_inherits_browser(), HashBase = require_hash_base(), ARRAY16 = new Array(16), @@ -1063,25 +1064,20 @@ var require_sha2 = __commonJS({ }, }); -// stream.js -var stream_exports = import.meta.require("node:stream"); - // node_modules/cipher-base/index.js var require_cipher_base = __commonJS({ "node_modules/cipher-base/index.js"(exports, module) { var Buffer2 = require_safe_buffer().Buffer, - Transform = stream_exports.Transform, - StringDecoder = __require("string_decoder").StringDecoder, inherits = require_inherits_browser(); function CipherBase(hashMode) { - Transform.call(this), + StreamModule.Transform.call(this), (this.hashMode = typeof hashMode == "string"), this.hashMode ? (this[hashMode] = this._finalOrDigest) : (this.final = this._finalOrDigest), this._final && ((this.__final = this._final), (this._final = null)), (this._decoder = null), (this._encoding = null); } - inherits(CipherBase, Transform); + inherits(CipherBase, StreamModule.Transform); CipherBase.prototype.update = function (data, inputEnc, outputEnc) { typeof data == "string" && (data = Buffer2.from(data, inputEnc)); var outData = this._update(data); @@ -1134,15 +1130,13 @@ var require_cipher_base = __commonJS({ var require_browser2 = __commonJS({ "node_modules/create-hash/browser.js"(exports, module) { ("use strict"); - const { Transform } = stream_exports; - // does not become a node stream unless you create it into one const LazyHash = function Hash(algorithm, options) { this._options = options; this._hasher = new CryptoHasher(algorithm, options); this._finalized = false; }; - LazyHash.prototype = Object.create(Transform.prototype); + LazyHash.prototype = Object.create(StreamModule.Transform.prototype); LazyHash.prototype.update = function update(data, encoding) { this._checkFinalized(); this._hasher.update(data, encoding); @@ -1169,7 +1163,7 @@ var require_browser2 = __commonJS({ }; const lazyHashFullInitProto = { - __proto__: Transform.prototype, + __proto__: StreamModule.Transform.prototype, ...LazyHash.prototype, _transform(data, encoding, callback) { this.update(data, encoding); @@ -1271,7 +1265,7 @@ var require_browser2 = __commonJS({ Object.defineProperty(LazyHash.prototype, method, { get() { Object.setPrototypeOf(this, lazyHashFullInitProto); - Transform.call(this, this._options); + StreamModule.Transform.call(this, this._options); return this[method]; }, enumerable: false, @@ -3330,12 +3324,7 @@ var require_bn = __commonJS({ this._init(number || 0, base || 10, endian || "be")); } typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2; - try { - typeof window < "u" && typeof window.Buffer < "u" - ? (Buffer2 = window.Buffer) - : (Buffer2 = __require("buffer").Buffer); - } catch {} + var Buffer2 = Buffer; (BN.isBN = function (num) { return num instanceof BN ? !0 @@ -5322,12 +5311,7 @@ var require_bn2 = __commonJS({ this._init(number || 0, base || 10, endian || "be")); } typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2; - try { - typeof window < "u" && typeof window.Buffer < "u" - ? (Buffer2 = window.Buffer) - : (Buffer2 = __require("buffer").Buffer); - } catch {} + var Buffer2 = Buffer; (BN.isBN = function (num) { return num instanceof BN ? !0 @@ -7670,12 +7654,7 @@ var require_bn3 = __commonJS({ this._init(number || 0, base || 10, endian || "be")); } typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2; - try { - typeof window < "u" && typeof window.Buffer < "u" - ? (Buffer2 = window.Buffer) - : (Buffer2 = __require("buffer").Buffer); - } catch {} + var Buffer2 = Buffer; (BN.isBN = function (num) { return num instanceof BN ? !0 @@ -9797,12 +9776,7 @@ var require_bn4 = __commonJS({ this._init(number || 0, base || 10, endian || "be")); } typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2; - try { - typeof window < "u" && typeof window.Buffer < "u" - ? (Buffer2 = window.Buffer) - : (Buffer2 = __require("buffer").Buffer); - } catch {} + var Buffer2 = Buffer; (BN.isBN = function (num) { return num instanceof BN ? !0 @@ -15491,12 +15465,8 @@ var require_bn5 = __commonJS({ this._init(number || 0, base || 10, endian || "be")); } typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2; - try { - typeof window < "u" && typeof window.Buffer < "u" - ? (Buffer2 = window.Buffer) - : (Buffer2 = __require("buffer").Buffer); - } catch {} + var Buffer2 = Buffer; + (BN.isBN = function (num) { return num instanceof BN ? !0 @@ -17461,8 +17431,8 @@ var require_bn5 = __commonJS({ var require_safer = __commonJS({ "node_modules/safer-buffer/safer.js"(exports, module) { "use strict"; - var buffer = __require("buffer"), - Buffer2 = buffer.Buffer, + var buffer = BufferModule, + Buffer2 = Buffer, safer = {}, key; for (key in buffer) @@ -19334,7 +19304,6 @@ var require_browser8 = __commonJS({ "node_modules/browserify-sign/browser/index.js"(exports, module) { var Buffer2 = require_safe_buffer().Buffer, createHash = require_browser2(), - stream = __require("readable-stream"), inherits = require_inherits_browser(), sign = require_sign(), verify = require_verify(), @@ -19343,7 +19312,7 @@ var require_browser8 = __commonJS({ (algorithms[key].id = Buffer2.from(algorithms[key].id, "hex")), (algorithms[key.toLowerCase()] = algorithms[key]); }); function Sign(algorithm) { - stream.Writable.call(this); + StreamModule.Writable.call(this); var data = algorithms[algorithm]; if (!data) throw new Error("Unknown message digest"); (this._hashType = data.hash), @@ -19351,7 +19320,7 @@ var require_browser8 = __commonJS({ (this._tag = data.id), (this._signType = data.sign); } - inherits(Sign, stream.Writable); + inherits(Sign, StreamModule.Writable); Sign.prototype._write = function (data, _, done) { this._hash.update(data), done(); }; @@ -19365,12 +19334,12 @@ var require_browser8 = __commonJS({ return enc ? sig.toString(enc) : sig; }; function Verify(algorithm) { - stream.Writable.call(this); + StreamModule.Writable.call(this); var data = algorithms[algorithm]; if (!data) throw new Error("Unknown message digest"); (this._hash = createHash(data.hash)), (this._tag = data.id), (this._signType = data.sign); } - inherits(Verify, stream.Writable); + inherits(Verify, StreamModule.Writable); Verify.prototype._write = function (data, _, done) { this._hash.update(data), done(); }; @@ -19423,12 +19392,7 @@ var require_bn6 = __commonJS({ this._init(number || 0, base || 10, endian || "be")); } typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2; - try { - typeof window < "u" && typeof window.Buffer < "u" - ? (Buffer2 = window.Buffer) - : (Buffer2 = __require("buffer").Buffer); - } catch {} + var Buffer2 = Buffer; (BN.isBN = function (num) { return num instanceof BN ? !0 diff --git a/src/js/node/dns.promises.js b/src/js/node/dns.promises.js index b41cc2b22..8b1aa4e48 100644 --- a/src/js/node/dns.promises.js +++ b/src/js/node/dns.promises.js @@ -1,5 +1,5 @@ // Hardcoded module "node:dns/promises" -const { promises } = import.meta.require("node:dns"); +import { promises } from "node:dns"; export const { lookup, diff --git a/src/js/node/events.js b/src/js/node/events.js index e42f89ad1..4fd16a85b 100644 --- a/src/js/node/events.js +++ b/src/js/node/events.js @@ -1,7 +1,8 @@ // Reimplementation of https://nodejs.org/api/events.html // Reference: https://github.com/nodejs/node/blob/main/lib/events.js import { throwNotImplemented } from "../shared"; -var { isPromise, Array, Object } = import.meta.primordials; + +var { isPromise, Array, Object } = globalThis[Symbol.for("Bun.lazy")]("primordials"); const SymbolFor = Symbol.for; const ObjectDefineProperty = Object.defineProperty; const kCapture = Symbol("kCapture"); @@ -386,8 +387,6 @@ Object.defineProperties(EventEmitter, { EventEmitter.init = EventEmitter; EventEmitter[Symbol.for("CommonJS")] = 0; -export default EventEmitter; - function eventTargetAgnosticRemoveListener(emitter, name, listener, flags) { if (typeof emitter.removeListener === "function") { emitter.removeListener(name, listener); @@ -454,10 +453,22 @@ function checkListener(listener) { } } -export class EventEmitterAsyncResource extends EventEmitter { +class EventEmitterAsyncResource extends EventEmitter { constructor(options = undefined) { throwNotImplemented("EventEmitterAsyncResource", 1832); } } - -EventEmitter.EventEmitterAsyncResource = EventEmitterAsyncResource; +const usingDomains = false; +// EventEmitter[Symbol.for("CommonJS")] = 0; +Object.assign(EventEmitter, { once, on, getEventListeners, setMaxListeners, listenerCount, EventEmitterAsyncResource }); +export { + EventEmitter, + once, + on, + getEventListeners, + setMaxListeners, + listenerCount, + usingDomains, + captureRejectionSymbol, +}; +export default EventEmitter; diff --git a/src/js/node/fs.js b/src/js/node/fs.js index 6b0e3954e..2bd752d19 100644 --- a/src/js/node/fs.js +++ b/src/js/node/fs.js @@ -1,11 +1,14 @@ -import { EventEmitter } from "stream"; +export var ReadStream; +export var WriteStream; + +import { EventEmitter } from "node:events"; // Hardcoded module "node:fs" -var { direct, isPromise, isCallable } = import.meta.primordials; -var promises = import.meta.require("node:fs/promises"); +var { direct, isPromise, isCallable } = globalThis[Symbol.for("Bun.lazy")]("primordials"); +export { default as promises } from "node:fs/promises"; +import promises from "node:fs/promises"; -var { Readable, NativeWritable, _getNativeReadableStreamPrototype, eos: eos_ } = import.meta.require("node:stream"); -var NativeReadable = _getNativeReadableStreamPrototype(2, Readable); // 2 means native type is a file here +import * as Stream from "node:stream"; var fs = Bun.fs(); var debug = process.env.DEBUG ? console.log : () => {}; @@ -214,8 +217,7 @@ export var access = function access(...args) { Stats = fs.Stats, watch = function watch(path, options, listener) { return new FSWatcher(path, options, listener); - }, - promises = import.meta.require("node:fs/promises"); + }; function callbackify(fsFunction, args) { try { @@ -284,7 +286,8 @@ var defaultReadStreamOptions = { }; var ReadStreamClass; -export var ReadStream = (function (InternalReadStream) { + +ReadStream = (function (InternalReadStream) { ReadStreamClass = InternalReadStream; Object.defineProperty(ReadStreamClass.prototype, Symbol.toStringTag, { value: "ReadStream", @@ -303,7 +306,7 @@ export var ReadStream = (function (InternalReadStream) { }, ); })( - class ReadStream extends NativeReadable { + class ReadStream extends Stream._getNativeReadableStreamPrototype(2, Stream.Readable) { constructor(pathOrFd, options = defaultReadStreamOptions) { if (typeof options !== "object" || !options) { throw new TypeError("Expected options to be an object"); @@ -631,7 +634,7 @@ var defaultWriteStreamOptions = { }; var WriteStreamClass; -export var WriteStream = (function (InternalWriteStream) { +WriteStream = (function (InternalWriteStream) { WriteStreamClass = InternalWriteStream; Object.defineProperty(WriteStreamClass.prototype, Symbol.toStringTag, { value: "WritesStream", @@ -650,7 +653,7 @@ export var WriteStream = (function (InternalWriteStream) { }, ); })( - class WriteStream extends NativeWritable { + class WriteStream extends Stream.NativeWritable { constructor(path, options = defaultWriteStreamOptions) { if (!options) { throw new TypeError("Expected options to be an object"); @@ -939,7 +942,7 @@ export function createWriteStream(path, options) { } // NOTE: This was too smart and doesn't actually work -// export var WriteStream = Object.defineProperty( +// WriteStream = Object.defineProperty( // function WriteStream(path, options) { // var _InternalWriteStream = getLazyWriteStream(); // return new _InternalWriteStream(path, options); @@ -948,7 +951,7 @@ export function createWriteStream(path, options) { // { value: (instance) => instance[writeStreamSymbol] === true }, // ); -// export var ReadStream = Object.defineProperty( +// ReadStream = Object.defineProperty( // function ReadStream(path, options) { // var _InternalReadStream = getLazyReadStream(); // return new _InternalReadStream(path, options); @@ -1077,3 +1080,5 @@ export default { // return getLazyReadStream(); // }, }; + +export { constants } from "node:fs/promises"; diff --git a/src/js/node/http.js b/src/js/node/http.js index 8839c9af7..4fba20881 100644 --- a/src/js/node/http.js +++ b/src/js/node/http.js @@ -1,10 +1,34 @@ // Hardcoded module "node:http" -const { EventEmitter } = import.meta.require("node:events"); -const { isIPv6 } = import.meta.require("node:net"); -const { Readable, Writable, Duplex } = import.meta.require("node:stream"); -const { URL } = import.meta.require("node:url"); -const { newArrayWithSize, String, Object, Array } = import.meta.primordials; -const { isTypedArray } = import.meta.require("util/types"); +import { EventEmitter } from "node:events"; +import { Readable, Writable, Duplex } from "node:stream"; +import { isTypedArray } from "util/types"; + +// Cheaper to duplicate this than to import it from node:net +function isIPv6(input) { + const v4Seg = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"; + const v4Str = `(${v4Seg}[.]){3}${v4Seg}`; + const v6Seg = "(?:[0-9a-fA-F]{1,4})"; + const IPv6Reg = new RegExp( + "^(" + + `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` + + `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` + + `(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|` + + `(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|` + + `(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|` + + `(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` + + `(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` + + `(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` + + ")(%[0-9a-zA-Z-.:]{1,})?$", + ); + + return IPv6Reg.test(input); +} + +// TODO: add primordial for URL +// Importing from node:url is unnecessary +const { URL } = globalThis; + +const { newArrayWithSize, String, Object, Array } = globalThis[Symbol.for("Bun.lazy")]("primordials"); const globalReportError = globalThis.reportError; const setTimeout = globalThis.setTimeout; @@ -1788,7 +1812,7 @@ export function get(url, options, cb) { req.end(); return req; } - +_globalAgent ??= new Agent(); var defaultObject = { Agent, Server, @@ -1806,10 +1830,12 @@ var defaultObject = { debug(`${NODE_HTTP_WARNING}\n`, "setMaxIdleHTTPParsers() is a no-op"); }, get globalAgent() { - return (_globalAgent ??= new Agent()); + return _globalAgent; }, set globalAgent(agent) {}, [Symbol.for("CommonJS")]: 0, }; export default defaultObject; + +export { _globalAgent as globalAgent }; diff --git a/src/js/node/https.js b/src/js/node/https.js index 8253e2905..5bef145ff 100644 --- a/src/js/node/https.js +++ b/src/js/node/https.js @@ -1,4 +1,3 @@ // Hardcoded module "node:https" export * from "node:http"; -const HTTP = import.meta.require("node:http"); -export default HTTP; +export { default as default } from "node:http"; diff --git a/src/js/node/net.js b/src/js/node/net.js index e767d0096..430a0dfa2 100644 --- a/src/js/node/net.js +++ b/src/js/node/net.js @@ -19,6 +19,8 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +import { Duplex } from "node:stream"; +import { EventEmitter } from "node:events"; // IPv4 Segment const v4Seg = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"; @@ -54,10 +56,8 @@ function isIP(s) { return 0; } -const { Bun, createFIFO, Object } = import.meta.primordials; +const { Bun, createFIFO, Object } = globalThis[Symbol.for("Bun.lazy")]("primordials"); const { connect: bunConnect } = Bun; -const { Duplex } = import.meta.require("node:stream"); -const { EventEmitter } = import.meta.require("node:events"); var { setTimeout } = globalThis; const bunTlsSymbol = Symbol.for("::buntls::"); diff --git a/src/js/node/path.js b/src/js/node/path.js index bcdd1f7f7..7c20d520b 100644 --- a/src/js/node/path.js +++ b/src/js/node/path.js @@ -1,6 +1,5 @@ // Hardcoded module "node:path" export const createModule = obj => Object.assign(Object.create(null), obj); - function bound(obj) { var result = createModule({ basename: obj.basename.bind(obj), diff --git a/src/js/node/readline.js b/src/js/node/readline.js index 0c253e8a0..64e73172a 100644 --- a/src/js/node/readline.js +++ b/src/js/node/readline.js @@ -25,10 +25,10 @@ // ---------------------------------------------------------------------------- // Section: Imports // ---------------------------------------------------------------------------- -var { Array, RegExp, String, Bun } = import.meta.primordials; -var EventEmitter = import.meta.require("node:events"); -var { clearTimeout, setTimeout } = import.meta.require("timers"); -var { StringDecoder } = import.meta.require("string_decoder"); +var { Array, RegExp, String, Bun } = globalThis[Symbol.for("Bun.lazy")]("primordials"); +import { EventEmitter } from "node:events"; +import { clearTimeout, setTimeout } from "timers"; +import { StringDecoder } from "string_decoder"; var isWritable; var { inspect } = Bun; @@ -1573,7 +1573,7 @@ function InterfaceConstructor(input, output, completer, terminal) { } ObjectSetPrototypeOf(InterfaceConstructor.prototype, EventEmitter.prototype); -ObjectSetPrototypeOf(InterfaceConstructor, EventEmitter); +// ObjectSetPrototypeOf(InterfaceConstructor, EventEmitter); var _Interface = class Interface extends InterfaceConstructor { // TODO: Enumerate all the properties of the class diff --git a/src/js/node/readline.promises.js b/src/js/node/readline.promises.js index 94d9b3f96..6890235b4 100644 --- a/src/js/node/readline.promises.js +++ b/src/js/node/readline.promises.js @@ -1,7 +1,7 @@ // Hardcoded module "node:readline/promises" -var { - promises: { Readline, Interface, createInterface }, -} = import.meta.require("node:readline"); +import { promises } from "node:readline"; + +export const { Readline, Interface, createInterface } = promises; export default { Readline, diff --git a/src/js/node/stream.consumers.js b/src/js/node/stream.consumers.js index 39d436eed..a1f85ab94 100644 --- a/src/js/node/stream.consumers.js +++ b/src/js/node/stream.consumers.js @@ -1,5 +1,5 @@ // Hardcoded module "node:stream/consumers" / "readable-stream/consumer" -const { Bun } = import.meta.primordials; +const { Bun } = globalThis[Symbol.for("Bun.lazy")]("primordials"); export const arrayBuffer = Bun.readableStreamToArrayBuffer; export const text = Bun.readableStreamToText; diff --git a/src/js/node/stream.js b/src/js/node/stream.js index 67d82d287..9344fa73f 100644 --- a/src/js/node/stream.js +++ b/src/js/node/stream.js @@ -1,7 +1,9 @@ // Hardcoded module "node:stream" / "readable-stream" // "readable-stream" npm package // just transpiled -var { isPromise, isCallable, direct, Object } = import.meta.primordials; +var { isPromise, isCallable, direct, Object } = globalThis[Symbol.for("Bun.lazy")]("primordials"); +import { EventEmitter as EE } from "bun:events_native"; +import { StringDecoder } from "node:string_decoder"; globalThis.__IDS_TO_TRACK = process.env.DEBUG_TRACK_EE?.length ? process.env.DEBUG_TRACK_EE.split(",") @@ -37,48 +39,6 @@ var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __ObjectSetPrototypeOf = Object.setPrototypeOf; -var __require = x => import.meta.require(x); - -var _EE = __require("bun:events_native"); - -function DebugEventEmitter(opts) { - if (!(this instanceof DebugEventEmitter)) return new DebugEventEmitter(opts); - _EE.call(this, opts); - const __id = opts.__id; - if (__id) { - __defProp(this, "__id", { - value: __id, - readable: true, - writable: false, - enumerable: false, - }); - } -} - -__ObjectSetPrototypeOf(DebugEventEmitter.prototype, _EE.prototype); -__ObjectSetPrototypeOf(DebugEventEmitter, _EE); - -DebugEventEmitter.prototype.emit = function (event, ...args) { - var __id = this.__id; - if (__id) { - debug("emit", event, ...args, __id); - } else { - debug("emit", event, ...args); - } - return _EE.prototype.emit.call(this, event, ...args); -}; -DebugEventEmitter.prototype.on = function (event, handler) { - var __id = this.__id; - if (__id) { - debug("on", event, "added", __id); - } else { - debug("on", event, "added"); - } - return _EE.prototype.on.call(this, event, handler); -}; -DebugEventEmitter.prototype.addListener = function (event, handler) { - return this.on(event, handler); -}; var __commonJS = (cb, mod) => function __require2() { @@ -260,9 +220,8 @@ var require_primordials = __commonJS({ var require_util = __commonJS({ "node_modules/readable-stream/lib/ours/util.js"(exports, module) { "use strict"; - var bufferModule = __require("buffer"); + var AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; - var Blob = globalThis.Blob || bufferModule.Blob; var isBlob = typeof Blob !== "undefined" ? function isBlob2(b) { @@ -1388,7 +1347,6 @@ var require_end_of_stream = __commonJS({ var require_operators = __commonJS({ "node_modules/readable-stream/lib/internal/streams/operators.js"(exports, module) { "use strict"; - var AbortController = globalThis.AbortController || __require("abort-controller").AbortController; var { codes: { ERR_INVALID_ARG_TYPE, ERR_MISSING_ARGS, ERR_OUT_OF_RANGE }, AbortError, @@ -2084,13 +2042,6 @@ var require_legacy = __commonJS({ "node_modules/readable-stream/lib/internal/streams/legacy.js"(exports, module) { "use strict"; var { ArrayIsArray, ObjectSetPrototypeOf } = require_primordials(); - var { EventEmitter: _EE } = __require("bun:events_native"); - var EE; - if (__TRACK_EE__) { - EE = DebugEventEmitter; - } else { - EE = _EE; - } function Stream(options) { if (!(this instanceof Stream)) return new Stream(options); @@ -2332,6 +2283,7 @@ var require_from = __commonJS({ }); var _ReadableFromWeb; +var _ReadableFromWebForUndici; // node_modules/readable-stream/lib/internal/streams/readable.js var require_readable = __commonJS({ @@ -2352,7 +2304,6 @@ var require_readable = __commonJS({ } = require_primordials(); var ReadableState = globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState; - var { EventEmitter: EE } = __require("bun:events_native"); var { Stream, prependListener } = require_legacy(); function Readable(options) { @@ -2537,6 +2488,8 @@ var require_readable = __commonJS({ } } + _ReadableFromWebForUndici = ReadableFromWeb; + /** * @param {ReadableStream} readableStream * @param {{ @@ -2596,7 +2549,7 @@ var require_readable = __commonJS({ } module.exports = Readable; - _ReadableFromWeb = ReadableFromWeb; + _ReadableFromWeb = newStreamReadableFromReadableStream; var { addAbortSignal } = require_add_abort_signal(); var eos = require_end_of_stream(); @@ -2626,7 +2579,6 @@ var require_readable = __commonJS({ }, } = require_errors(); var { validateObject } = require_validators(); - var { StringDecoder } = __require("string_decoder"); var from = require_from(); var nop = () => {}; var { errorOrDestroy } = destroyImpl; @@ -3422,7 +3374,6 @@ var require_writable = __commonJS({ SymbolHasInstance, } = require_primordials(); - var { EventEmitter: EE } = __require("bun:events_native"); var Stream = require_legacy().Stream; var destroyImpl = require_destroy(); var { addAbortSignal } = require_add_abort_signal(); @@ -4048,7 +3999,6 @@ var require_writable = __commonJS({ var require_duplexify = __commonJS({ "node_modules/readable-stream/lib/internal/streams/duplexify.js"(exports, module) { "use strict"; - var bufferModule = __require("buffer"); var { isReadable, isWritable, @@ -4068,7 +4018,6 @@ var require_duplexify = __commonJS({ var Readable = require_readable(); var { createDeferredPromise } = require_util(); var from = require_from(); - var Blob = globalThis.Blob || bufferModule.Blob; var isBlob = typeof Blob !== "undefined" ? function isBlob2(b) { @@ -4077,7 +4026,6 @@ var require_duplexify = __commonJS({ : function isBlob2(b) { return false; }; - var AbortController = globalThis.AbortController || __require("abort-controller").AbortController; var { FunctionPrototypeCall } = require_primordials(); class Duplexify extends Duplex { constructor(options) { @@ -4619,7 +4567,6 @@ var require_pipeline = __commonJS({ } = require_errors(); var { validateFunction, validateAbortSignal } = require_validators(); var { isIterable, isReadable, isReadableNodeStream, isNodeStream } = require_utils(); - var AbortController = globalThis.AbortController || __require("abort-controller").AbortController; var PassThrough; var Readable; function destroyer(stream, reading, writing) { @@ -5304,7 +5251,7 @@ function createNativeStreamReadable(nativeType, Readable) { const finalizer = new FinalizationRegistry(ptr => ptr && deinit(ptr)); const MIN_BUFFER_SIZE = 512; var NativeReadable = class NativeReadable extends Readable { - #ptr; + #bunNativePtr; #refCount = 1; #constructed = false; #remainingChunk = undefined; @@ -5319,12 +5266,12 @@ function createNativeStreamReadable(nativeType, Readable) { } else { this.#highWaterMark = 256 * 1024; } - this.#ptr = ptr; + this.#bunNativePtr = ptr; this.#constructed = false; this.#remainingChunk = undefined; this.#pendingRead = false; this.#unregisterToken = {}; - finalizer.register(this, this.#ptr, this.#unregisterToken); + finalizer.register(this, this.#bunNativePtr, this.#unregisterToken); } // maxToRead is by default the highWaterMark passed from the Readable.read call to this fn @@ -5337,7 +5284,7 @@ function createNativeStreamReadable(nativeType, Readable) { return; } - var ptr = this.#ptr; + var ptr = this.#bunNativePtr; __DEBUG__ && debug("ptr @ NativeReadable._read", ptr, this.__id); if (ptr === 0) { this.push(null); @@ -5458,14 +5405,14 @@ function createNativeStreamReadable(nativeType, Readable) { } _destroy(error, callback) { - var ptr = this.#ptr; + var ptr = this.#bunNativePtr; if (ptr === 0) { callback(error); return; } finalizer.unregister(this.#unregisterToken); - this.#ptr = 0; + this.#bunNativePtr = 0; if (updateRef) { updateRef(ptr, false); } @@ -5475,7 +5422,7 @@ function createNativeStreamReadable(nativeType, Readable) { } ref() { - var ptr = this.#ptr; + var ptr = this.#bunNativePtr; if (ptr === 0) return; if (this.#refCount++ === 0) { updateRef(ptr, true); @@ -5483,7 +5430,7 @@ function createNativeStreamReadable(nativeType, Readable) { } unref() { - var ptr = this.#ptr; + var ptr = this.#bunNativePtr; if (ptr === 0) return; if (this.#refCount-- === 1) { updateRef(ptr, false); @@ -5632,7 +5579,7 @@ var NativeWritable = class NativeWritable extends Writable { const stream_exports = require_ours(); stream_exports[Symbol.for("CommonJS")] = 0; -stream_exports[Symbol.for("::bunternal::")] = { _ReadableFromWeb }; +stream_exports[Symbol.for("::bunternal::")] = { _ReadableFromWeb, _ReadableFromWebForUndici }; export default stream_exports; export var _uint8ArrayToBuffer = stream_exports._uint8ArrayToBuffer; export var _isUint8Array = stream_exports._isUint8Array; @@ -5654,4 +5601,4 @@ export var Stream = stream_exports.Stream; export var eos = (stream_exports["eos"] = require_end_of_stream); export var _getNativeReadableStreamPrototype = stream_exports._getNativeReadableStreamPrototype; export var NativeWritable = stream_exports.NativeWritable; -export var promises = Stream.promise; +export var promises = Stream.promises; diff --git a/src/js/node/stream.promises.js b/src/js/node/stream.promises.js index d00c424a6..323785a4c 100644 --- a/src/js/node/stream.promises.js +++ b/src/js/node/stream.promises.js @@ -1,5 +1,5 @@ -// Hardcoded module "node:stream" -var { promises } = import.meta.require("node:stream"); +// Hardcoded module "node:stream/promises" +import { promises } from "node:stream"; export var { pipeline, finished } = promises; diff --git a/src/js/node/timers.promises.js b/src/js/node/timers.promises.js index 2bb7bce49..3e2e7bcd5 100644 --- a/src/js/node/timers.promises.js +++ b/src/js/node/timers.promises.js @@ -233,3 +233,4 @@ function setIntervalPromise(after = 1, value, options = {}) { } export { setTimeoutPromise as setTimeout, setImmediatePromise as setImmediate, setIntervalPromise as setInterval }; +export default { setTimeout: setTimeoutPromise, setImmediate: setImmediatePromise, setInterval: setIntervalPromise }; diff --git a/src/js/node/tls.js b/src/js/node/tls.js index b3b089daf..356c25cbd 100644 --- a/src/js/node/tls.js +++ b/src/js/node/tls.js @@ -1,5 +1,7 @@ // Hardcoded module "node:tls" import { isTypedArray } from "util/types"; +import net, { Server as NetServer } from "node:net"; +const InternalTCPSocket = net[Symbol.for("::bunternal::")]; function parseCertString() { throwNotImplemented("Not implemented"); @@ -81,8 +83,6 @@ function createSecureContext(options) { return new SecureContext(options); } -const { [Symbol.for("::bunternal::")]: InternalTCPSocket, Server: NetServer } = import.meta.require("net"); - const buntls = Symbol.for("::buntls::"); var SocketClass; @@ -286,7 +286,7 @@ class Server extends NetServer { function createServer(options, connectionListener) { return new Server(options, connectionListener); } -export const CLIENT_RENEG_LIMIT = 3, +const CLIENT_RENEG_LIMIT = 3, CLIENT_RENEG_WINDOW = 600, DEFAULT_ECDH_CURVE = "auto", // https://github.com/Jarred-Sumner/uSockets/blob/fafc241e8664243fc0c51d69684d5d02b9805134/src/crypto/openssl.c#L519-L523 @@ -304,34 +304,54 @@ export const CLIENT_RENEG_LIMIT = 3, }, connect = createConnection; -var exports = { - createSecureContext, - parseCertString, +function getCiphers() { + return DEFAULT_CIPHERS.split(":"); +} - getCiphers() { - return DEFAULT_CIPHERS.split(":"); - }, +function getCurves() { + return; +} - getCurves() { - return; - }, +function convertALPNProtocols(protocols, out) {} - convertALPNProtocols(protocols, out) {}, - TLSSocket, - SecureContext, +var exports = { + [Symbol.for("CommonJS")]: 0, CLIENT_RENEG_LIMIT, CLIENT_RENEG_WINDOW, - DEFAULT_ECDH_CURVE, + connect, + convertALPNProtocols, + createConnection, + createSecureContext, + createServer, DEFAULT_CIPHERS, - DEFAULT_MIN_VERSION, + DEFAULT_ECDH_CURVE, DEFAULT_MAX_VERSION, - [Symbol.for("CommonJS")]: 0, + DEFAULT_MIN_VERSION, + getCiphers, + getCurves, + parseCertString, + SecureContext, + Server, + TLSSocket, +}; + +export { + CLIENT_RENEG_LIMIT, + CLIENT_RENEG_WINDOW, connect, + convertALPNProtocols, createConnection, - Server, + createSecureContext, createServer, + DEFAULT_CIPHERS, + DEFAULT_ECDH_CURVE, + DEFAULT_MAX_VERSION, + DEFAULT_MIN_VERSION, + getCiphers, + getCurves, + parseCertString, + SecureContext, + Server, + TLSSocket, + exports as default, }; - -export default exports; - -export { createSecureContext, parseCertString, TLSSocket, SecureContext }; diff --git a/src/js/node/url.js b/src/js/node/url.js index f9a4427ce..9fb1b4374 100644 --- a/src/js/node/url.js +++ b/src/js/node/url.js @@ -1,398 +1,851 @@ -// Hardcoded module "node:url" +/* + * Copyright Joyent, Inc. and other Node contributors. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + "use strict"; -const { URL: F, URLSearchParams: M, [Symbol.for("Bun.lazy")]: S } = globalThis; -function it(s) { - return typeof s == "string"; + +const { URL, URLSearchParams } = globalThis; + +function Url() { + this.protocol = null; + this.slashes = null; + this.auth = null; + this.host = null; + this.port = null; + this.hostname = null; + this.hash = null; + this.search = null; + this.query = null; + this.pathname = null; + this.path = null; + this.href = null; } -function D(s) { - return typeof s == "object" && s !== null; -} -function I(s) { - return s === null; -} -function E(s) { - return s == null; -} -function ft(s) { - return s === void 0; -} -function m() { - (this.protocol = null), - (this.slashes = null), - (this.auth = null), - (this.host = null), - (this.port = null), - (this.hostname = null), - (this.hash = null), - (this.search = null), - (this.query = null), - (this.pathname = null), - (this.path = null), - (this.href = null); -} -var tt = /^([a-z0-9.+-]+:)/i, - st = /:[0-9]*$/, - ht = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, - et = [ - "<", - ">", - '"', - "`", - " ", - "\r", - ` -`, - " ", - ], - rt = ["{", "}", "|", "\\", "^", "`"].concat(et), - B = ["'"].concat(rt), - G = ["%", "/", "?", ";", "#"].concat(B), - J = ["/", "?", "#"], - ot = 255, - K = /^[+a-z0-9A-Z_-]{0,63}$/, - at = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, - nt = { javascript: !0, "javascript:": !0 }, - N = { javascript: !0, "javascript:": !0 }, - R = { - http: !0, - https: !0, - ftp: !0, - gopher: !0, - file: !0, - "http:": !0, - "https:": !0, - "ftp:": !0, - "gopher:": !0, - "file:": !0, + +// Reference: RFC 3986, RFC 1808, RFC 2396 + +/* + * define these here so at least they only have to be + * compiled once on the first module load. + */ +var protocolPattern = /^([a-z0-9.+-]+:)/i, + portPattern = /:[0-9]*$/, + // Special case for a simple path URL + simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/, + /* + * RFC 2396: characters reserved for delimiting URLs. + * We actually just auto-escape these. + */ + delims = ["<", ">", '"', "`", " ", "\r", "\n", "\t"], + // RFC 2396: characters not allowed for various reasons. + unwise = ["{", "}", "|", "\\", "^", "`"].concat(delims), + // Allowed by RFCs, but cause of XSS attacks. Always escape these. + autoEscape = ["'"].concat(unwise), + /* + * Characters that are never ever allowed in a hostname. + * Note that any invalid chars are also handled, but these + * are the ones that are *expected* to be seen, so we fast-path + * them. + */ + nonHostChars = ["%", "/", "?", ";", "#"].concat(autoEscape), + hostEndingChars = ["/", "?", "#"], + hostnameMaxLen = 255, + hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, + hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, + // protocols that can allow "unsafe" and "unwise" chars. + unsafeProtocol = { + javascript: true, + "javascript:": true, + }, + // protocols that never have a hostname. + hostlessProtocol = { + javascript: true, + "javascript:": true, }, - Z = { - parse(s) { - var r = decodeURIComponent; - return (s + "") - .replace(/\+/g, " ") - .split("&") - .filter(Boolean) - .reduce(function (t, o, a) { - var l = o.split("="), - f = r(l[0] || ""), - h = r(l[1] || ""), - g = t[f]; - return (t[f] = g === void 0 ? h : [].concat(g, h)), t; - }, {}); - }, - stringify(s) { - var r = encodeURIComponent; - return Object.keys(s || {}) - .reduce(function (t, o) { - return ( - [].concat(s[o]).forEach(function (a) { - t.push(r(o) + "=" + r(a)); - }), - t - ); - }, []) - .join("&") - .replace(/\s/g, "+"); - }, + // protocols that always contain a // bit. + slashedProtocol = { + http: true, + https: true, + ftp: true, + gopher: true, + file: true, + "http:": true, + "https:": true, + "ftp:": true, + "gopher:": true, + "file:": true, }; -function A(s, r, t) { - if (s && D(s) && s instanceof m) return s; - var o = new m(); - return o.parse(s, r, t), o; + +function urlParse(url, parseQueryString, slashesDenoteHost) { + if (url && typeof url === "object" && url instanceof Url) { + return url; + } + + var u = new Url(); + u.parse(url, parseQueryString, slashesDenoteHost); + return u; } -m.prototype.parse = function (s, r, t) { - if (!it(s)) throw new TypeError("Parameter 'url' must be a string, not " + typeof s); - var o = s.indexOf("?"), - a = o !== -1 && o < s.indexOf("#") ? "?" : "#", - l = s.split(a), - f = /\\/g; - (l[0] = l[0].replace(f, "/")), (s = l.join(a)); - var h = s; - if (((h = h.trim()), !t && s.split("#").length === 1)) { - var g = ht.exec(h); - if (g) - return ( - (this.path = h), - (this.href = h), - (this.pathname = g[1]), - g[2] - ? ((this.search = g[2]), - r ? (this.query = Z.parse(this.search.substr(1))) : (this.query = this.search.substr(1))) - : r && ((this.search = ""), (this.query = {})), - this - ); - } - var c = tt.exec(h); - if (c) { - c = c[0]; - var v = c.toLowerCase(); - (this.protocol = v), (h = h.substr(c.length)); - } - if (t || c || h.match(/^\/\/[^@\/]+@[^@\/]+/)) { - var j = h.substr(0, 2) === "//"; - j && !(c && N[c]) && ((h = h.substr(2)), (this.slashes = !0)); - } - if (!N[c] && (j || (c && !R[c]))) { - for (var u = -1, n = 0; n < J.length; n++) { - var b = h.indexOf(J[n]); - b !== -1 && (u === -1 || b < u) && (u = b); + +Url.prototype.parse = function (url, parseQueryString, slashesDenoteHost) { + if (typeof url !== "string") { + throw new TypeError("Parameter 'url' must be a string, not " + typeof url); + } + + /* + * Copy chrome, IE, opera backslash-handling behavior. + * Back slashes before the query string get converted to forward slashes + * See: https://code.google.com/p/chromium/issues/detail?id=25916 + */ + var queryIndex = url.indexOf("?"), + splitter = queryIndex !== -1 && queryIndex < url.indexOf("#") ? "?" : "#", + uSplit = url.split(splitter), + slashRegex = /\\/g; + uSplit[0] = uSplit[0].replace(slashRegex, "/"); + url = uSplit.join(splitter); + + var rest = url; + + /* + * trim before proceeding. + * This is to support parse stuff like " http://foo.com \n" + */ + rest = rest.trim(); + + if (!slashesDenoteHost && url.split("#").length === 1) { + // Try fast path regexp + var simplePath = simplePathPattern.exec(rest); + if (simplePath) { + this.path = rest; + this.href = rest; + this.pathname = simplePath[1]; + if (simplePath[2]) { + this.search = simplePath[2]; + if (parseQueryString) { + this.query = new URLSearchParams(this.search.substr(1)).toJSON(); + } else { + this.query = this.search.substr(1); + } + } else if (parseQueryString) { + this.search = ""; + this.query = {}; + } + return this; + } + } + + var proto = protocolPattern.exec(rest); + if (proto) { + proto = proto[0]; + var lowerProto = proto.toLowerCase(); + this.protocol = lowerProto; + rest = rest.substr(proto.length); + } + + /* + * figure out if it's got a host + * user@server is *always* interpreted as a hostname, and url + * resolution will treat //foo/bar as host=foo,path=bar because that's + * how the browser resolves relative URLs. + */ + if (slashesDenoteHost || proto || rest.match(/^\/\/[^@/]+@[^@/]+/)) { + var slashes = rest.substr(0, 2) === "//"; + if (slashes && !(proto && hostlessProtocol[proto])) { + rest = rest.substr(2); + this.slashes = true; + } + } + + if (!hostlessProtocol[proto] && (slashes || (proto && !slashedProtocol[proto]))) { + /* + * there's a hostname. + * the first instance of /, ?, ;, or # ends the host. + * + * If there is an @ in the hostname, then non-host chars *are* allowed + * to the left of the last @ sign, unless some host-ending character + * comes *before* the @-sign. + * URLs are obnoxious. + * + * ex: + * http://a@b@c/ => user:a@b host:c + * http://a@b?@c => user:a host:c path:/?@c + */ + + /* + * v0.12 TODO(isaacs): This is not quite how Chrome does things. + * Review our test case against browsers more comprehensively. + */ + + // find the first instance of any hostEndingChars + var hostEnd = -1; + for (var i = 0; i < hostEndingChars.length; i++) { + var hec = rest.indexOf(hostEndingChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) { + hostEnd = hec; + } + } + + /* + * at this point, either we have an explicit point where the + * auth portion cannot go past, or the last @ char is the decider. + */ + var auth, atSign; + if (hostEnd === -1) { + // atSign can be anywhere. + atSign = rest.lastIndexOf("@"); + } else { + /* + * atSign must be in auth portion. + * http://a@b/c@d => host:b auth:a path:/c@d + */ + atSign = rest.lastIndexOf("@", hostEnd); + } + + /* + * Now we have a portion which is definitely the auth. + * Pull that off. + */ + if (atSign !== -1) { + auth = rest.slice(0, atSign); + rest = rest.slice(atSign + 1); + this.auth = decodeURIComponent(auth); } - var P, p; - u === -1 ? (p = h.lastIndexOf("@")) : (p = h.lastIndexOf("@", u)), - p !== -1 && ((P = h.slice(0, p)), (h = h.slice(p + 1)), (this.auth = decodeURIComponent(P))), - (u = -1); - for (var n = 0; n < G.length; n++) { - var b = h.indexOf(G[n]); - b !== -1 && (u === -1 || b < u) && (u = b); + + // the host is the remaining to the left of the first non-host char + hostEnd = -1; + for (var i = 0; i < nonHostChars.length; i++) { + var hec = rest.indexOf(nonHostChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) { + hostEnd = hec; + } + } + // if we still have not hit it, then the entire thing is a host. + if (hostEnd === -1) { + hostEnd = rest.length; } - u === -1 && (u = h.length), - (this.host = h.slice(0, u)), - (h = h.slice(u)), - this.parseHost(), - (this.hostname = this.hostname || ""); - var C = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]"; - if (!C) - for (var e = this.hostname.split(/\./), n = 0, i = e.length; n < i; n++) { - var d = e[n]; - if (!!d && !d.match(K)) { - for (var y = "", x = 0, _ = d.length; x < _; x++) d.charCodeAt(x) > 127 ? (y += "x") : (y += d[x]); - if (!y.match(K)) { - var q = e.slice(0, n), - O = e.slice(n + 1), - U = d.match(at); - U && (q.push(U[1]), O.unshift(U[2])), - O.length && (h = "/" + O.join(".") + h), - (this.hostname = q.join(".")); + + this.host = rest.slice(0, hostEnd); + rest = rest.slice(hostEnd); + + // pull out port. + this.parseHost(); + + /* + * we've indicated that there is a hostname, + * so even if it's empty, it has to be present. + */ + this.hostname = this.hostname || ""; + + /* + * if hostname begins with [ and ends with ] + * assume that it's an IPv6 address. + */ + var ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]"; + + // validate a little. + if (!ipv6Hostname) { + var hostparts = this.hostname.split(/\./); + for (var i = 0, l = hostparts.length; i < l; i++) { + var part = hostparts[i]; + if (!part) { + continue; + } + if (!part.match(hostnamePartPattern)) { + var newpart = ""; + for (var j = 0, k = part.length; j < k; j++) { + if (part.charCodeAt(j) > 127) { + /* + * we replace non-ASCII char with a temporary placeholder + * we need this to make sure size of hostname is not + * broken by replacing non-ASCII by nothing + */ + newpart += "x"; + } else { + newpart += part[j]; + } + } + // we test again with ASCII char only + if (!newpart.match(hostnamePartPattern)) { + var validParts = hostparts.slice(0, i); + var notHost = hostparts.slice(i + 1); + var bit = part.match(hostnamePartStart); + if (bit) { + validParts.push(bit[1]); + notHost.unshift(bit[2]); + } + if (notHost.length) { + rest = "/" + notHost.join(".") + rest; + } + this.hostname = validParts.join("."); break; } } } - this.hostname.length > ot ? (this.hostname = "") : (this.hostname = this.hostname.toLowerCase()), - C || (this.hostname = new F(`https://${this.hostname}`).hostname); - var w = this.port ? ":" + this.port : "", - H = this.hostname || ""; - (this.host = H + w), - (this.href += this.host), - C && ((this.hostname = this.hostname.substr(1, this.hostname.length - 2)), h[0] !== "/" && (h = "/" + h)); - } - if (!nt[v]) - for (var n = 0, i = B.length; n < i; n++) { - var L = B[n]; - if (h.indexOf(L) !== -1) { - var z = encodeURIComponent(L); - z === L && (z = escape(L)), (h = h.split(L).join(z)); + } + + if (this.hostname.length > hostnameMaxLen) { + this.hostname = ""; + } else { + // hostnames are always lower case. + this.hostname = this.hostname.toLowerCase(); + } + + if (!ipv6Hostname) { + /* + * IDNA Support: Returns a punycoded representation of "domain". + * It only converts parts of the domain name that + * have non-ASCII characters, i.e. it doesn't matter if + * you call it with a domain that already is ASCII-only. + */ + this.hostname = new URL("http://" + this.hostname).hostname; + } + + var p = this.port ? ":" + this.port : ""; + var h = this.hostname || ""; + this.host = h + p; + this.href += this.host; + + /* + * strip [ and ] from the hostname + * the host field still retains them, though + */ + if (ipv6Hostname) { + this.hostname = this.hostname.substr(1, this.hostname.length - 2); + if (rest[0] !== "/") { + rest = "/" + rest; + } + } + } + + /* + * now rest is set to the post-host stuff. + * chop off any delim chars. + */ + if (!unsafeProtocol[lowerProto]) { + /* + * First, make 100% sure that any "autoEscape" chars get + * escaped, even if encodeURIComponent doesn't think they + * need to be. + */ + for (var i = 0, l = autoEscape.length; i < l; i++) { + var ae = autoEscape[i]; + if (rest.indexOf(ae) === -1) { + continue; + } + var esc = encodeURIComponent(ae); + if (esc === ae) { + esc = escape(ae); } + rest = rest.split(ae).join(esc); + } + } + + // chop off from the tail first. + var hash = rest.indexOf("#"); + if (hash !== -1) { + // got a fragment string. + this.hash = rest.substr(hash); + rest = rest.slice(0, hash); + } + var qm = rest.indexOf("?"); + if (qm !== -1) { + this.search = rest.substr(qm); + this.query = rest.substr(qm + 1); + if (parseQueryString) { + this.query = new URLSearchParams(this.query); } - var $ = h.indexOf("#"); - $ !== -1 && ((this.hash = h.substr($)), (h = h.slice(0, $))); - var T = h.indexOf("?"); - if ( - (T !== -1 - ? ((this.search = h.substr(T)), - (this.query = h.substr(T + 1)), - r && (this.query = Z.parse(this.query)), - (h = h.slice(0, T))) - : r && ((this.search = ""), (this.query = {})), - h && (this.pathname = h), - R[v] && this.hostname && !this.pathname && (this.pathname = "/"), - this.pathname || this.search) - ) { - var w = this.pathname || "", - Q = this.search || ""; - this.path = w + Q; - } - return (this.href = this.format()), this; + rest = rest.slice(0, qm); + } else if (parseQueryString) { + // no query string, but parseQueryString still requested + this.search = ""; + this.query = {}; + } + if (rest) { + this.pathname = rest; + } + if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) { + this.pathname = "/"; + } + + // to support http.request + if (this.pathname || this.search) { + var p = this.pathname || ""; + var s = this.search || ""; + this.path = p + s; + } + + // finally, reconstruct the href based on what has been validated. + this.href = this.format(); + return this; }; -function V(s) { - return it(s) && (s = A(s)), s instanceof m ? s.format() : m.prototype.format.call(s); + +// format a parsed object into a url string +function urlFormat(obj) { + /* + * ensure it's an object, and not a string url. + * If it's an obj, this is a no-op. + * this way, you can call url_format() on strings + * to clean up potentially wonky urls. + */ + if (typeof obj === "string") { + obj = urlParse(obj); + } + if (!(obj instanceof Url)) { + return Url.prototype.format.call(obj); + } + return obj.format(); } -m.prototype.format = function () { - var s = this.auth || ""; - s && ((s = encodeURIComponent(s)), (s = s.replace(/%3A/i, ":")), (s += "@")); - var r = this.protocol || "", - t = this.pathname || "", - o = this.hash || "", - a = !1, - l = ""; - this.host - ? (a = s + this.host) - : this.hostname && - ((a = s + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]")), - this.port && (a += ":" + this.port)), - this.query && D(this.query) && Object.keys(this.query).length && (l = Z.stringify(this.query)); - var f = this.search || (l && "?" + l) || ""; - return ( - r && r.substr(-1) !== ":" && (r += ":"), - this.slashes || ((!r || R[r]) && a !== !1) - ? ((a = "//" + (a || "")), t && t.charAt(0) !== "/" && (t = "/" + t)) - : a || (a = ""), - o && o.charAt(0) !== "#" && (o = "#" + o), - f && f.charAt(0) !== "?" && (f = "?" + f), - (t = t.replace(/[?#]/g, function (h) { - return encodeURIComponent(h); - })), - (f = f.replace("#", "%23")), - r + a + t + f + o - ); + +Url.prototype.format = function () { + var auth = this.auth || ""; + if (auth) { + auth = encodeURIComponent(auth); + auth = auth.replace(/%3A/i, ":"); + auth += "@"; + } + + var protocol = this.protocol || "", + pathname = this.pathname || "", + hash = this.hash || "", + host = false, + query = ""; + + if (this.host) { + host = auth + this.host; + } else if (this.hostname) { + host = auth + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]"); + if (this.port) { + host += ":" + this.port; + } + } + + if (this.query && typeof this.query === "object" && Object.keys(this.query).length) { + query = new URLSearchParams(this.query).toString(); + } + + var search = this.search || (query && "?" + query) || ""; + + if (protocol && protocol.substr(-1) !== ":") { + protocol += ":"; + } + + /* + * only the slashedProtocols get the //. Not mailto:, xmpp:, etc. + * unless they had them to begin with. + */ + if (this.slashes || ((!protocol || slashedProtocol[protocol]) && host !== false)) { + host = "//" + (host || ""); + if (pathname && pathname.charAt(0) !== "/") { + pathname = "/" + pathname; + } + } else if (!host) { + host = ""; + } + + if (hash && hash.charAt(0) !== "#") { + hash = "#" + hash; + } + if (search && search.charAt(0) !== "?") { + search = "?" + search; + } + + pathname = pathname.replace(/[?#]/g, function (match) { + return encodeURIComponent(match); + }); + search = search.replace("#", "%23"); + + return protocol + host + pathname + search + hash; }; -function W(s, r) { - return A(s, !1, !0).resolve(r); + +function urlResolve(source, relative) { + return urlParse(source, false, true).resolve(relative); } -m.prototype.resolve = function (s) { - return this.resolveObject(A(s, !1, !0)).format(); + +Url.prototype.resolve = function (relative) { + return this.resolveObject(urlParse(relative, false, true)).format(); }; -function X(s, r) { - return s ? A(s, !1, !0).resolveObject(r) : r; + +function urlResolveObject(source, relative) { + if (!source) { + return relative; + } + return urlParse(source, false, true).resolveObject(relative); } -(m.prototype.resolveObject = function (s) { - if (it(s)) { - var r = new m(); - r.parse(s, !1, !0), (s = r); - } - for (var t = new m(), o = Object.keys(this), a = 0; a < o.length; a++) { - var l = o[a]; - t[l] = this[l]; - } - if (((t.hash = s.hash), s.href === "")) return (t.href = t.format()), t; - if (s.slashes && !s.protocol) { - for (var f = Object.keys(s), h = 0; h < f.length; h++) { - var g = f[h]; - g !== "protocol" && (t[g] = s[g]); + +Url.prototype.resolveObject = function (relative) { + if (typeof relative === "string") { + var rel = new Url(); + rel.parse(relative, false, true); + relative = rel; + } + + var result = new Url(); + var tkeys = Object.keys(this); + for (var tk = 0; tk < tkeys.length; tk++) { + var tkey = tkeys[tk]; + result[tkey] = this[tkey]; + } + + /* + * hash is always overridden, no matter what. + * even href="" will remove it. + */ + result.hash = relative.hash; + + // if the relative url is empty, then there's nothing left to do here. + if (relative.href === "") { + result.href = result.format(); + return result; + } + + // hrefs like //foo/bar always cut to the protocol. + if (relative.slashes && !relative.protocol) { + // take everything except the protocol from relative + var rkeys = Object.keys(relative); + for (var rk = 0; rk < rkeys.length; rk++) { + var rkey = rkeys[rk]; + if (rkey !== "protocol") { + result[rkey] = relative[rkey]; + } } - return R[t.protocol] && t.hostname && !t.pathname && (t.path = t.pathname = "/"), (t.href = t.format()), t; + + // urlParse appends trailing / to urls like http://www.example.com + if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) { + result.pathname = "/"; + result.path = result.pathname; + } + + result.href = result.format(); + return result; } - if (s.protocol && s.protocol !== t.protocol) { - if (!R[s.protocol]) { - for (var c = Object.keys(s), v = 0; v < c.length; v++) { - var j = c[v]; - t[j] = s[j]; + + if (relative.protocol && relative.protocol !== result.protocol) { + /* + * if it's a known url protocol, then changing + * the protocol does weird things + * first, if it's not file:, then we MUST have a host, + * and if there was a path + * to begin with, then we MUST have a path. + * if it is file:, then the host is dropped, + * because that's known to be hostless. + * anything else is assumed to be absolute. + */ + if (!slashedProtocol[relative.protocol]) { + var keys = Object.keys(relative); + for (var v = 0; v < keys.length; v++) { + var k = keys[v]; + result[k] = relative[k]; } - return (t.href = t.format()), t; + result.href = result.format(); + return result; } - if (((t.protocol = s.protocol), !s.host && !N[s.protocol])) { - for (var i = (s.pathname || "").split("/"); i.length && !(s.host = i.shift()); ); - s.host || (s.host = ""), - s.hostname || (s.hostname = ""), - i[0] !== "" && i.unshift(""), - i.length < 2 && i.unshift(""), - (t.pathname = i.join("/")); - } else t.pathname = s.pathname; - if ( - ((t.search = s.search), - (t.query = s.query), - (t.host = s.host || ""), - (t.auth = s.auth), - (t.hostname = s.hostname || s.host), - (t.port = s.port), - t.pathname || t.search) - ) { - var u = t.pathname || "", - n = t.search || ""; - t.path = u + n; + + result.protocol = relative.protocol; + if (!relative.host && !hostlessProtocol[relative.protocol]) { + var relPath = (relative.pathname || "").split("/"); + while (relPath.length && !(relative.host = relPath.shift())) {} + if (!relative.host) { + relative.host = ""; + } + if (!relative.hostname) { + relative.hostname = ""; + } + if (relPath[0] !== "") { + relPath.unshift(""); + } + if (relPath.length < 2) { + relPath.unshift(""); + } + result.pathname = relPath.join("/"); + } else { + result.pathname = relative.pathname; } - return (t.slashes = t.slashes || s.slashes), (t.href = t.format()), t; - } - var b = t.pathname && t.pathname.charAt(0) === "/", - P = s.host || (s.pathname && s.pathname.charAt(0) === "/"), - p = P || b || (t.host && s.pathname), - C = p, - e = (t.pathname && t.pathname.split("/")) || [], - i = (s.pathname && s.pathname.split("/")) || [], - d = t.protocol && !R[t.protocol]; - if ( - (d && - ((t.hostname = ""), - (t.port = null), - t.host && (e[0] === "" ? (e[0] = t.host) : e.unshift(t.host)), - (t.host = ""), - s.protocol && - ((s.hostname = null), - (s.port = null), - s.host && (i[0] === "" ? (i[0] = s.host) : i.unshift(s.host)), - (s.host = null)), - (p = p && (i[0] === "" || e[0] === ""))), - P) - ) - (t.host = s.host || s.host === "" ? s.host : t.host), - (t.hostname = s.hostname || s.hostname === "" ? s.hostname : t.hostname), - (t.search = s.search), - (t.query = s.query), - (e = i); - else if (i.length) e || (e = []), e.pop(), (e = e.concat(i)), (t.search = s.search), (t.query = s.query); - else if (!E(s.search)) { - if (d) { - t.hostname = t.host = e.shift(); - var y = t.host && t.host.indexOf("@") > 0 ? t.host.split("@") : !1; - y && ((t.auth = y.shift()), (t.host = t.hostname = y.shift())); + result.search = relative.search; + result.query = relative.query; + result.host = relative.host || ""; + result.auth = relative.auth; + result.hostname = relative.hostname || relative.host; + result.port = relative.port; + // to support http.request + if (result.pathname || result.search) { + var p = result.pathname || ""; + var s = result.search || ""; + result.path = p + s; } - return ( - (t.search = s.search), - (t.query = s.query), - (!I(t.pathname) || !I(t.search)) && (t.path = (t.pathname ? t.pathname : "") + (t.search ? t.search : "")), - (t.href = t.format()), - t - ); - } - if (!e.length) - return (t.pathname = null), t.search ? (t.path = "/" + t.search) : (t.path = null), (t.href = t.format()), t; - for ( - var x = e.slice(-1)[0], - _ = ((t.host || s.host || e.length > 1) && (x === "." || x === "..")) || x === "", - q = 0, - O = e.length; - O >= 0; - O-- - ) - (x = e[O]), x === "." ? e.splice(O, 1) : x === ".." ? (e.splice(O, 1), q++) : q && (e.splice(O, 1), q--); - if (!p && !C) for (; q--; q) e.unshift(".."); - p && e[0] !== "" && (!e[0] || e[0].charAt(0) !== "/") && e.unshift(""), - _ && e.join("/").substr(-1) !== "/" && e.push(""); - var U = e[0] === "" || (e[0] && e[0].charAt(0) === "/"); - if (d) { - t.hostname = t.host = U ? "" : e.length ? e.shift() : ""; - var y = t.host && t.host.indexOf("@") > 0 ? t.host.split("@") : !1; - y && ((t.auth = y.shift()), (t.host = t.hostname = y.shift())); - } - return ( - (p = p || (t.host && e.length)), - p && !U && e.unshift(""), - e.length ? (t.pathname = e.join("/")) : ((t.pathname = null), (t.path = null)), - (!I(t.pathname) || !I(t.search)) && (t.path = (t.pathname ? t.pathname : "") + (t.search ? t.search : "")), - (t.auth = s.auth || t.auth), - (t.slashes = t.slashes || s.slashes), - (t.href = t.format()), - t - ); -}), - (m.prototype.parseHost = function () { - var s = this.host, - r = st.exec(s); - r && ((r = r[0]), r !== ":" && (this.port = r.substr(1)), (s = s.substr(0, s.length - r.length))), - s && (this.hostname = s); - }); -var Y, k; -S && ((Y = S("pathToFileURL")), (k = S("fileURLToPath"))); -var ut = { - parse: A, - resolve: W, - resolveObject: X, - format: V, - Url: m, - pathToFileURL: Y, - fileURLToPath: k, - URL: F, - URLSearchParams: M, + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; + } + + var isSourceAbs = result.pathname && result.pathname.charAt(0) === "/", + isRelAbs = relative.host || (relative.pathname && relative.pathname.charAt(0) === "/"), + mustEndAbs = isRelAbs || isSourceAbs || (result.host && relative.pathname), + removeAllDots = mustEndAbs, + srcPath = (result.pathname && result.pathname.split("/")) || [], + relPath = (relative.pathname && relative.pathname.split("/")) || [], + psychotic = result.protocol && !slashedProtocol[result.protocol]; + + /* + * if the url is a non-slashed url, then relative + * links like ../.. should be able + * to crawl up to the hostname, as well. This is strange. + * result.protocol has already been set by now. + * Later on, put the first path part into the host field. + */ + if (psychotic) { + result.hostname = ""; + result.port = null; + if (result.host) { + if (srcPath[0] === "") { + srcPath[0] = result.host; + } else { + srcPath.unshift(result.host); + } + } + result.host = ""; + if (relative.protocol) { + relative.hostname = null; + relative.port = null; + if (relative.host) { + if (relPath[0] === "") { + relPath[0] = relative.host; + } else { + relPath.unshift(relative.host); + } + } + relative.host = null; + } + mustEndAbs = mustEndAbs && (relPath[0] === "" || srcPath[0] === ""); + } + + if (isRelAbs) { + // it's absolute. + result.host = relative.host || relative.host === "" ? relative.host : result.host; + result.hostname = relative.hostname || relative.hostname === "" ? relative.hostname : result.hostname; + result.search = relative.search; + result.query = relative.query; + srcPath = relPath; + // fall through to the dot-handling below. + } else if (relPath.length) { + /* + * it's relative + * throw away the existing file, and take the new path instead. + */ + if (!srcPath) { + srcPath = []; + } + srcPath.pop(); + srcPath = srcPath.concat(relPath); + result.search = relative.search; + result.query = relative.query; + } else if (relative.search != null) { + /* + * just pull out the search. + * like href='?foo'. + * Put this after the other two cases because it simplifies the booleans + */ + if (psychotic) { + result.host = srcPath.shift(); + result.hostname = result.host; + /* + * occationaly the auth can get stuck only in host + * this especially happens in cases like + * url.resolveObject('mailto:local1@domain1', 'local2@domain2') + */ + var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.hostname = authInHost.shift(); + result.host = result.hostname; + } + } + result.search = relative.search; + result.query = relative.query; + // to support http.request + if (result.pathname !== null || result.search !== null) { + result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : ""); + } + result.href = result.format(); + return result; + } + + if (!srcPath.length) { + /* + * no path at all. easy. + * we've already handled the other stuff above. + */ + result.pathname = null; + // to support http.request + if (result.search) { + result.path = "/" + result.search; + } else { + result.path = null; + } + result.href = result.format(); + return result; + } + + /* + * if a url ENDs in . or .., then it must get a trailing slash. + * however, if it ends in anything else non-slashy, + * then it must NOT get a trailing slash. + */ + var last = srcPath.slice(-1)[0]; + var hasTrailingSlash = + ((result.host || relative.host || srcPath.length > 1) && (last === "." || last === "..")) || last === ""; + + /* + * strip single dots, resolve double dots to parent dir + * if the path tries to go above the root, `up` ends up > 0 + */ + var up = 0; + for (var i = srcPath.length; i >= 0; i--) { + last = srcPath[i]; + if (last === ".") { + srcPath.splice(i, 1); + } else if (last === "..") { + srcPath.splice(i, 1); + up++; + } else if (up) { + srcPath.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (!mustEndAbs && !removeAllDots) { + for (; up--; up) { + srcPath.unshift(".."); + } + } + + if (mustEndAbs && srcPath[0] !== "" && (!srcPath[0] || srcPath[0].charAt(0) !== "/")) { + srcPath.unshift(""); + } + + if (hasTrailingSlash && srcPath.join("/").substr(-1) !== "/") { + srcPath.push(""); + } + + var isAbsolute = srcPath[0] === "" || (srcPath[0] && srcPath[0].charAt(0) === "/"); + + // put the host back + if (psychotic) { + result.hostname = isAbsolute ? "" : srcPath.length ? srcPath.shift() : ""; + result.host = result.hostname; + /* + * occationaly the auth can get stuck only in host + * this especially happens in cases like + * url.resolveObject('mailto:local1@domain1', 'local2@domain2') + */ + var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.hostname = authInHost.shift(); + result.host = result.hostname; + } + } + + mustEndAbs = mustEndAbs || (result.host && srcPath.length); + + if (mustEndAbs && !isAbsolute) { + srcPath.unshift(""); + } + + if (srcPath.length > 0) { + result.pathname = srcPath.join("/"); + } else { + result.pathname = null; + result.path = null; + } + + // to support request.http + if (result.pathname !== null || result.search !== null) { + result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : ""); + } + result.auth = relative.auth || result.auth; + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; +}; + +Url.prototype.parseHost = function () { + var host = this.host; + var port = portPattern.exec(host); + if (port) { + port = port[0]; + if (port !== ":") { + this.port = port.substr(1); + } + host = host.substr(0, host.length - port.length); + } + if (host) { + this.hostname = host; + } +}; +function urlToHttpOptions(url) { + const options = { + protocol: url.protocol, + hostname: + typeof url.hostname === "string" && url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : url.hostname, + hash: url.hash, + search: url.search, + pathname: url.pathname, + path: `${url.pathname || ""}${url.search || ""}`, + href: url.href, + }; + if (url.port !== "") { + options.port = Number(url.port); + } + if (url.username || url.password) { + options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`; + } + return options; +} + +const lazy = globalThis[Symbol.for("Bun.lazy")]; +const pathToFileURL = lazy("pathToFileURL"); +const fileURLToPath = lazy("fileURLToPath"); +const defaultObject = { + parse: urlParse, + resolve: urlResolve, + resolveObject: urlResolveObject, + format: urlFormat, + Url, + URLSearchParams, + URL, + pathToFileURL, + fileURLToPath, + urlToHttpOptions, }; -("use strict"); + export { - F as URL, - M as URLSearchParams, - m as Url, - ut as default, - k as fileURLToPath, - V as format, - A as parse, - Y as pathToFileURL, - W as resolve, - X as resolveObject, + defaultObject as default, + urlParse as parse, + urlResolve as resolve, + urlResolveObject as resolveObject, + urlFormat as format, + Url, + URLSearchParams, + URL, + pathToFileURL, + fileURLToPath, + urlToHttpOptions, }; diff --git a/src/js/node/util.js b/src/js/node/util.js index 282f4b371..346f88ffb 100644 --- a/src/js/node/util.js +++ b/src/js/node/util.js @@ -1,4 +1,11 @@ // Hardcoded module "node:util" +import * as types from "node:util/types"; +export { default as types } from "node:util/types"; + +var cjs_exports = {}; + +export default cjs_exports; + var __getOwnPropNames = Object.getOwnPropertyNames; var __commonJS = (cb, mod) => function __require() { @@ -17,6 +24,10 @@ export function isBuffer(value) { ); } +function isFunction(value) { + return typeof value === "function"; +} + // node_modules/inherits/inherits_browser.js var require_inherits_browser = __commonJS({ "node_modules/inherits/inherits_browser.js"(exports, module2) { @@ -35,9 +46,6 @@ var require_inherits_browser = __commonJS({ }); const deepEquals = Bun.deepEquals; const isDeepStrictEqual = (a, b) => deepEquals(a, b, true); -const exports = { - isDeepStrictEqual, -}; var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors; var formatRegExp = /%[sdj%]/g; function format(f) { @@ -78,21 +86,19 @@ function format(f) { } return str; } -exports.format = format; -function deprecate(fn, msg) { - if (typeof process !== "undefined" && process.noDeprecation === true) { + +function deprecate(fn, msg, code) { + if (process.noDeprecation === true) { return fn; } - if (typeof process === "undefined") { - return function () { - return exports.deprecate(fn, msg).apply(this, arguments); - }; - } + var warned = false; function deprecated() { if (!warned) { if (process.throwDeprecation) { - throw new Error(msg); + var err = new Error(msg); + if (code) err.code = code; + throw err; } else if (process.traceDeprecation) { console.trace(msg); } else { @@ -104,7 +110,7 @@ function deprecate(fn, msg) { } return deprecated; } -exports.deprecate = deprecate; + var debugs = {}; var debugEnvRegex = /^$/; if (process.env.NODE_DEBUG) { @@ -123,7 +129,7 @@ function debuglog(set) { if (debugEnvRegex.test(set)) { var pid = process.pid; debugs[set] = function () { - var msg = exports.format.apply(exports, arguments); + var msg = format.apply(cjs_exports, arguments); console.error("%s %d: %s", set, pid, msg); }; } else { @@ -132,7 +138,6 @@ function debuglog(set) { } return debugs[set]; } -exports.debuglog = debuglog; function inspect(obj, opts) { var ctx = { seen: [], @@ -143,7 +148,7 @@ function inspect(obj, opts) { if (isBoolean(opts)) { ctx.showHidden = opts; } else if (opts) { - exports._extend(ctx, opts); + _extend(ctx, opts); } if (isUndefined(ctx.showHidden)) ctx.showHidden = false; if (isUndefined(ctx.depth)) ctx.depth = 2; @@ -152,7 +157,6 @@ function inspect(obj, opts) { if (ctx.colors) ctx.stylize = stylizeWithColor; return formatValue(ctx, obj, ctx.depth); } -exports.inspect = inspect; inspect.colors = { bold: [1, 22], italic: [3, 23], @@ -201,7 +205,7 @@ function formatValue(ctx, value, recurseTimes) { ctx.customInspect && value && isFunction(value.inspect) && - value.inspect !== exports.inspect && + value.inspect !== inspect && !(value.constructor && value.constructor.prototype === value) ) { var ret = value.inspect(recurseTimes, ctx); @@ -388,51 +392,42 @@ function reduceToSingleString(output, base, braces) { } return braces[0] + base + " " + output.join(", ") + " " + braces[1]; } -const types = import.meta.require("node:util/types"); -exports.types = types; + function isArray(ar) { return Array.isArray(ar); } -exports.isArray = isArray; + function isBoolean(arg) { return typeof arg === "boolean"; } -exports.isBoolean = isBoolean; + function isNull(arg) { return arg === null; } -exports.isNull = isNull; + function isNullOrUndefined(arg) { return arg == null; } -exports.isNullOrUndefined = isNullOrUndefined; + function isNumber(arg) { return typeof arg === "number"; } -exports.isNumber = isNumber; + function isString(arg) { return typeof arg === "string"; } -exports.isString = isString; function isSymbol(arg) { return typeof arg === "symbol"; } -exports.isSymbol = isSymbol; function isUndefined(arg) { return arg === void 0; } -exports.isUndefined = isUndefined; -var isRegExp = (exports.isRegExp = exports.types.isRegExp); +var isRegExp = types.isRegExp; function isObject(arg) { return typeof arg === "object" && arg !== null; } -exports.isObject = isObject; -var isDate = (exports.isDate = exports.types.isDate); -var isError = (exports.isError = exports.types.isNativeError); -function isFunction(arg) { - return typeof arg === "function"; -} -var isFunction = (exports.isFunction = isFunction); +var isDate = types.isDate; +var isError = types.isNativeError; function isPrimitive(arg) { return ( arg === null || @@ -443,8 +438,6 @@ function isPrimitive(arg) { typeof arg === "undefined" ); } -exports.isPrimitive = isPrimitive; -exports.isBuffer = isBuffer; function pad(n) { return n < 10 ? "0" + n.toString(10) : n.toString(10); } @@ -454,11 +447,11 @@ function timestamp() { var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(":"); return [d.getDate(), months[d.getMonth()], time].join(" "); } -var log = (exports.log = function () { - console.log("%s - %s", timestamp(), exports.format.apply(exports, arguments)); -}); -var inherits = (exports.inherits = require_inherits_browser()); -var _extend = (exports._extend = function (origin, add) { +var log = function log() { + console.log("%s - %s", timestamp(), format.apply(cjs_exports, arguments)); +}; +var inherits = (inherits = require_inherits_browser()); +var _extend = function (origin, add) { if (!add || !isObject(add)) return origin; var keys = Object.keys(add); var i = keys.length; @@ -466,12 +459,12 @@ var _extend = (exports._extend = function (origin, add) { origin[keys[i]] = add[keys[i]]; } return origin; -}); +}; function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } var kCustomPromisifiedSymbol = Symbol.for("util.promisify.custom"); -var promisify = (exports.promisify = function promisify(original) { +var promisify = function promisify(original) { if (typeof original !== "function") throw new TypeError('The "original" argument must be of type Function'); if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) { var fn = original[kCustomPromisifiedSymbol]; @@ -519,8 +512,8 @@ var promisify = (exports.promisify = function promisify(original) { configurable: true, }); return Object.defineProperties(fn, getOwnPropertyDescriptors(original)); -}); -exports.promisify.custom = kCustomPromisifiedSymbol; +}; +promisify.custom = kCustomPromisifiedSymbol; function callbackifyOnRejected(reason, cb) { if (!reason) { var newReason = new Error("Promise was rejected with a falsy value"); @@ -556,11 +549,40 @@ function callbackify(original) { Object.defineProperties(callbackified, getOwnPropertyDescriptors(original)); return callbackified; } -exports.callbackify = callbackify; -export var TextDecoder = (exports.TextDecoder = globalThis.TextDecoder); -export var TextEncoder = (exports.TextEncoder = globalThis.TextEncoder); -exports[Symbol.for("CommonJS")] = 0; -export default exports; +export var TextDecoder = globalThis.TextDecoder; +export var TextEncoder = globalThis.TextEncoder; + +Object.assign(cjs_exports, { + format, + deprecate, + debuglog, + _extend, + inspect, + types, + isArray, + isBoolean, + isNull, + isNullOrUndefined, + isNumber, + isString, + isSymbol, + isUndefined, + isRegExp, + isObject, + isDate, + isFunction, + isError, + isPrimitive, + isBuffer, + log, + inherits, + promisify, + callbackify, + isDeepStrictEqual, + TextDecoder, + TextEncoder, + [Symbol.for("CommonJS")]: 0, +}); export { format, diff --git a/src/js/node/zlib.js b/src/js/node/zlib.js index 1414f4664..77a9e8089 100644 --- a/src/js/node/zlib.js +++ b/src/js/node/zlib.js @@ -3,6 +3,41 @@ // This is a very slow module! // It should really be fixed. It will show up in benchmarking. It also loads // slowly. We need to fix it! +import { default as assert } from "node:assert"; +import * as AssertModule from "node:assert"; +import * as BufferModule from "node:buffer"; +import * as StreamModule from "node:stream"; +import * as Util from "node:util"; + +export var Deflate, + Inflate, + Gzip, + Gunzip, + DeflateRaw, + InflateRaw, + Unzip, + createDeflate, + createInflate, + createDeflateRaw, + createInflateRaw, + createGzip, + createGunzip, + createUnzip, + deflate, + deflateSync, + gzip, + gzipSync, + deflateRaw, + deflateRawSync, + unzip, + unzipSync, + inflate, + inflateSync, + gunzip, + gunzipSync, + inflateRaw, + inflateRawSync, + constants; var __create = Object.create; var __defProp = Object.defineProperty; @@ -38,8 +73,6 @@ var __toESM = (mod, isNodeMode, target) => ( ); var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -const require = id => import.meta.require(id); - // node_modules/pako/lib/zlib/zstream.js var require_zstream = __commonJS({ "node_modules/pako/lib/zlib/zstream.js"(exports, module2) { @@ -3593,7 +3626,7 @@ var require_constants = __commonJS({ var require_binding = __commonJS({ "node_modules/browserify-zlib/lib/binding.js"(exports) { "use strict"; - var assert = require("assert"); + var Zstream = require_zstream(); var zlib_deflate = require_deflate(); var zlib_inflate = require_inflate(); @@ -3937,12 +3970,12 @@ var require_binding = __commonJS({ var require_lib = __commonJS({ "node_modules/browserify-zlib/lib/index.js"(exports) { "use strict"; - var Buffer2 = require("buffer").Buffer; - var Transform = require("stream").Transform; + var Buffer2 = BufferModule.Buffer; + var Transform = StreamModule.Transform; var binding = require_binding(); - var util = require("util"); - var assert = require("assert").ok; - var kMaxLength = require("buffer").kMaxLength; + var util = Util; + var assert = AssertModule.ok; + var kMaxLength = BufferModule.kMaxLength; var kRangeErrorMessage = "Cannot create final Buffer. It would be larger than 0x" + kMaxLength.toString(16) + " bytes"; binding.Z_MIN_WINDOWBITS = 8; @@ -4437,36 +4470,35 @@ var require_lib = __commonJS({ // zlib.js var zlib_exports = require_lib(); zlib_exports[Symbol.for("CommonJS")] = 0; + export default zlib_exports; -export var { - Deflate, - Inflate, - Gzip, - Gunzip, - DeflateRaw, - InflateRaw, - Unzip, - createDeflate, - createInflate, - createDeflateRaw, - createInflateRaw, - createGzip, - createGunzip, - createUnzip, - deflate, - deflateSync, - gzip, - gzipSync, - deflateRaw, - deflateRawSync, - unzip, - unzipSync, - inflate, - inflateSync, - gunzip, - gunzipSync, - inflateRaw, - inflateRawSync, - constants, -} = zlib_exports; +Deflate = zlib_exports.Deflate; +Inflate = zlib_exports.Inflate; +Gzip = zlib_exports.Gzip; +Gunzip = zlib_exports.Gunzip; +DeflateRaw = zlib_exports.DeflateRaw; +InflateRaw = zlib_exports.InflateRaw; +Unzip = zlib_exports.Unzip; +createDeflate = zlib_exports.createDeflate; +createInflate = zlib_exports.createInflate; +createDeflateRaw = zlib_exports.createDeflateRaw; +createInflateRaw = zlib_exports.createInflateRaw; +createGzip = zlib_exports.createGzip; +createGunzip = zlib_exports.createGunzip; +createUnzip = zlib_exports.createUnzip; +deflate = zlib_exports.deflate; +deflateSync = zlib_exports.deflateSync; +gzip = zlib_exports.gzip; +gzipSync = zlib_exports.gzipSync; +deflateRaw = zlib_exports.deflateRaw; +deflateRawSync = zlib_exports.deflateRawSync; +unzip = zlib_exports.unzip; +unzipSync = zlib_exports.unzipSync; +inflate = zlib_exports.inflate; +inflateSync = zlib_exports.inflateSync; +gunzip = zlib_exports.gunzip; +gunzipSync = zlib_exports.gunzipSync; +inflateRaw = zlib_exports.inflateRaw; +inflateRawSync = zlib_exports.inflateRawSync; +constants = zlib_exports.constants; diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index 455a0a3a4..f494e6635 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -116,7 +116,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStream const JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 956; static const JSC::Intrinsic s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (o,w){\"use strict\";const C={};if(o===@undefined)o={};if(w===@undefined)w={};if(!@isObject(o))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in o)@throwRangeError(\"Invalid type is specified\");const E=@extractSizeAlgorithm(w),_=@extractHighWaterMark(w,1),f={};if(\"start\"in o){if(f[\"start\"]=o[\"start\"],typeof f[\"start\"]!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in o){if(f[\"write\"]=o[\"write\"],typeof f[\"write\"]!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in o){if(f[\"close\"]=o[\"close\"],typeof f[\"close\"]!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in o){if(f[\"abort\"]=o[\"abort\"],typeof f[\"abort\"]!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(C,o),@setUpWritableStreamDefaultControllerFromUnderlyingSink(C,o,f,_,E),C})\n"; +const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,o){\"use strict\";const C={};if(f===@undefined)f={};if(o===@undefined)o={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const w=@extractSizeAlgorithm(o),E=@extractHighWaterMark(o,1),_={};if(\"start\"in f){if(_[\"start\"]=f[\"start\"],typeof _[\"start\"]!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in f){if(_[\"write\"]=f[\"write\"],typeof _[\"write\"]!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in f){if(_[\"close\"]=f[\"close\"],typeof _[\"close\"]!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in f){if(_[\"abort\"]=f[\"abort\"],typeof _[\"abort\"]!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(C,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(C,f,_,E,w),C})\n"; // initializeWritableStreamSlots const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -156,7 +156,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultWr const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeLength = 887; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode = "(function (n,v){\"use strict\";if(@isWritableStreamLocked(v))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(n,\"stream\",v),@putByIdDirectPrivate(v,\"writer\",n);const g=@newPromiseCapability(@Promise),h=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"readyPromise\",g),@putByIdDirectPrivate(n,\"closedPromise\",h);const B=@getByIdDirectPrivate(v,\"state\");if(B===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(v)||!@getByIdDirectPrivate(v,\"backpressure\"))g.@resolve.@call()}else if(B===\"erroring\")g.@reject.@call(@undefined,@getByIdDirectPrivate(v,\"storedError\")),@markPromiseAsHandled(g.@promise);else if(B===\"closed\")g.@resolve.@call(),h.@resolve.@call();else{@assert(B===\"errored\");const _=@getByIdDirectPrivate(v,\"storedError\");g.@reject.@call(@undefined,_),@markPromiseAsHandled(g.@promise),h.@reject.@call(@undefined,_),@markPromiseAsHandled(h.@promise)}})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode = "(function (n,g){\"use strict\";if(@isWritableStreamLocked(g))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(n,\"stream\",g),@putByIdDirectPrivate(g,\"writer\",n);const v=@newPromiseCapability(@Promise),h=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"readyPromise\",v),@putByIdDirectPrivate(n,\"closedPromise\",h);const B=@getByIdDirectPrivate(g,\"state\");if(B===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(g)||!@getByIdDirectPrivate(g,\"backpressure\"))v.@resolve.@call()}else if(B===\"erroring\")v.@reject.@call(@undefined,@getByIdDirectPrivate(g,\"storedError\")),@markPromiseAsHandled(v.@promise);else if(B===\"closed\")v.@resolve.@call(),h.@resolve.@call();else{@assert(B===\"errored\");const _=@getByIdDirectPrivate(g,\"storedError\");v.@reject.@call(@undefined,_),@markPromiseAsHandled(v.@promise),h.@reject.@call(@undefined,_),@markPromiseAsHandled(h.@promise)}})\n"; // writableStreamAbort const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -164,7 +164,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortCodeConst const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamAbortCodeLength = 501; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAbortCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (c,h){\"use strict\";const B=@getByIdDirectPrivate(c,\"state\");if(B===\"closed\"||B===\"errored\")return @Promise.@resolve();const _=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(_!==@undefined)return _.promise.@promise;@assert(B===\"writable\"||B===\"erroring\");let f=!1;if(B===\"erroring\")f=!0,h=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:j,reason:h,wasAlreadyErroring:f}),!f)@writableStreamStartErroring(c,h);return j.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (h,B){\"use strict\";const _=@getByIdDirectPrivate(h,\"state\");if(_===\"closed\"||_===\"errored\")return @Promise.@resolve();const f=@getByIdDirectPrivate(h,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(_===\"writable\"||_===\"erroring\");let j=!1;if(_===\"erroring\")j=!0,B=@undefined;const c=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(h,\"pendingAbortRequest\",{promise:c,reason:B,wasAlreadyErroring:j}),!j)@writableStreamStartErroring(h,B);return c.@promise})\n"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -172,7 +172,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseCodeConst const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamCloseCodeLength = 642; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamCloseCode = "(function (n){\"use strict\";const _=@getByIdDirectPrivate(n,\"state\");if(_===\"closed\"||_===\"errored\")return @Promise.@reject(@makeTypeError(\"Cannot close a writable stream that is closed or errored\"));@assert(_===\"writable\"||_===\"erroring\"),@assert(!@writableStreamCloseQueuedOrInFlight(n));const u=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"closeRequest\",u);const d=@getByIdDirectPrivate(n,\"writer\");if(d!==@undefined&&@getByIdDirectPrivate(n,\"backpressure\")&&_===\"writable\")@getByIdDirectPrivate(d,\"readyPromise\").@resolve.@call();return @writableStreamDefaultControllerClose(@getByIdDirectPrivate(n,\"controller\")),u.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamCloseCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"state\");if(d===\"closed\"||d===\"errored\")return @Promise.@reject(@makeTypeError(\"Cannot close a writable stream that is closed or errored\"));@assert(d===\"writable\"||d===\"erroring\"),@assert(!@writableStreamCloseQueuedOrInFlight(_));const n=@newPromiseCapability(@Promise);@putByIdDirectPrivate(_,\"closeRequest\",n);const u=@getByIdDirectPrivate(_,\"writer\");if(u!==@undefined&&@getByIdDirectPrivate(_,\"backpressure\")&&d===\"writable\")@getByIdDirectPrivate(u,\"readyPromise\").@resolve.@call();return @writableStreamDefaultControllerClose(@getByIdDirectPrivate(_,\"controller\")),n.@promise})\n"; // writableStreamAddWriteRequest const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -204,7 +204,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishErroring const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishErroringCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishErroringCodeLength = 1058; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishErroringCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = "(function (_){\"use strict\";@assert(@getByIdDirectPrivate(_,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(_)),@putByIdDirectPrivate(_,\"state\",\"errored\");const p=@getByIdDirectPrivate(_,\"controller\");@getByIdDirectPrivate(p,\"errorSteps\").@call();const h=@getByIdDirectPrivate(_,\"storedError\"),A=@getByIdDirectPrivate(_,\"writeRequests\");for(var B=A.shift();B;B=A.shift())B.@reject.@call(@undefined,h);@putByIdDirectPrivate(_,\"writeRequests\",@createFIFO());const i=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(i===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}if(@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined),i.wasAlreadyErroring){i.promise.@reject.@call(@undefined,h),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}@getByIdDirectPrivate(p,\"abortSteps\").@call(@undefined,i.reason).@then(()=>{i.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)},(I)=>{i.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)})})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(i)),@putByIdDirectPrivate(i,\"state\",\"errored\");const _=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(_,\"errorSteps\").@call();const p=@getByIdDirectPrivate(i,\"storedError\"),h=@getByIdDirectPrivate(i,\"writeRequests\");for(var A=h.shift();A;A=h.shift())A.@reject.@call(@undefined,p);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const B=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(B===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),B.wasAlreadyErroring){B.promise.@reject.@call(@undefined,p),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(_,\"abortSteps\").@call(@undefined,B.reason).@then(()=>{B.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(I)=>{B.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -348,7 +348,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterW const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeLength = 919; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (g,P){\"use strict\";const W=@getByIdDirectPrivate(g,\"stream\");@assert(W!==@undefined);const _=@getByIdDirectPrivate(W,\"controller\");@assert(_!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(_,P);if(W!==@getByIdDirectPrivate(g,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const d=@getByIdDirectPrivate(W,\"state\");if(d===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(W,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(W)||d===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(W)||d===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(d===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(W,\"storedError\"));@assert(d===\"writable\");const f=@writableStreamAddWriteRequest(W);return @writableStreamDefaultControllerWrite(_,P,b),f})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (d,P){\"use strict\";const W=@getByIdDirectPrivate(d,\"stream\");@assert(W!==@undefined);const _=@getByIdDirectPrivate(W,\"controller\");@assert(_!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(_,P);if(W!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const f=@getByIdDirectPrivate(W,\"state\");if(f===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(W,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(W)||f===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(W)||f===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(f===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(W,\"storedError\"));@assert(f===\"writable\");const g=@writableStreamAddWriteRequest(W);return @writableStreamDefaultControllerWrite(_,P,b),g})\n"; // setUpWritableStreamDefaultController const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -356,7 +356,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeLength = 700; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (_,B,v,P,U,d,f,j){\"use strict\";@assert(@isWritableStream(_)),@assert(@getByIdDirectPrivate(_,\"controller\")===@undefined),@putByIdDirectPrivate(B,\"stream\",_),@putByIdDirectPrivate(_,\"controller\",B),@resetQueue(@getByIdDirectPrivate(B,\"queue\")),@putByIdDirectPrivate(B,\"started\",-1),@putByIdDirectPrivate(B,\"startAlgorithm\",v),@putByIdDirectPrivate(B,\"strategySizeAlgorithm\",j),@putByIdDirectPrivate(B,\"strategyHWM\",f),@putByIdDirectPrivate(B,\"writeAlgorithm\",P),@putByIdDirectPrivate(B,\"closeAlgorithm\",U),@putByIdDirectPrivate(B,\"abortAlgorithm\",d);const q=@writableStreamDefaultControllerGetBackpressure(B);@writableStreamUpdateBackpressure(_,q),@writableStreamDefaultControllerStart(B)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (B,f,j,v,P,q,_,U){\"use strict\";@assert(@isWritableStream(B)),@assert(@getByIdDirectPrivate(B,\"controller\")===@undefined),@putByIdDirectPrivate(f,\"stream\",B),@putByIdDirectPrivate(B,\"controller\",f),@resetQueue(@getByIdDirectPrivate(f,\"queue\")),@putByIdDirectPrivate(f,\"started\",-1),@putByIdDirectPrivate(f,\"startAlgorithm\",j),@putByIdDirectPrivate(f,\"strategySizeAlgorithm\",U),@putByIdDirectPrivate(f,\"strategyHWM\",_),@putByIdDirectPrivate(f,\"writeAlgorithm\",v),@putByIdDirectPrivate(f,\"closeAlgorithm\",P),@putByIdDirectPrivate(f,\"abortAlgorithm\",q);const d=@writableStreamDefaultControllerGetBackpressure(f);@writableStreamUpdateBackpressure(B,d),@writableStreamDefaultControllerStart(f)})\n"; // writableStreamDefaultControllerStart const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -460,7 +460,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeLength = 734; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode = "(function (i,d){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(_),@getByIdDirectPrivate(i,\"writeAlgorithm\").@call(@undefined,d).@then(()=>{@writableStreamFinishInFlightWrite(_);const v=@getByIdDirectPrivate(_,\"state\");if(@assert(v===\"writable\"||v===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),!@writableStreamCloseQueuedOrInFlight(_)&&v===\"writable\"){const M=@writableStreamDefaultControllerGetBackpressure(i);@writableStreamUpdateBackpressure(_,M)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(v)=>{if(@getByIdDirectPrivate(_,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(i);@writableStreamFinishInFlightWriteWithError(_,v)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode = "(function (d,_){\"use strict\";const q=@getByIdDirectPrivate(d,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(q),@getByIdDirectPrivate(d,\"writeAlgorithm\").@call(@undefined,_).@then(()=>{@writableStreamFinishInFlightWrite(q);const M=@getByIdDirectPrivate(q,\"state\");if(@assert(M===\"writable\"||M===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(d,\"queue\")),!@writableStreamCloseQueuedOrInFlight(q)&&M===\"writable\"){const i=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(q,i)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)},(M)=>{if(@getByIdDirectPrivate(q,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(d);@writableStreamFinishInFlightWriteWithError(q,M)})})\n"; // writableStreamDefaultControllerWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -468,7 +468,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength = 450; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode = "(function (y,B,D){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(y,\"queue\"),B,D);const I=@getByIdDirectPrivate(y,\"stream\"),_=@getByIdDirectPrivate(I,\"state\");if(!@writableStreamCloseQueuedOrInFlight(I)&&_===\"writable\"){const d=@writableStreamDefaultControllerGetBackpressure(y);@writableStreamUpdateBackpressure(I,d)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(y)}catch(I){@writableStreamDefaultControllerErrorIfNeeded(y,I)}})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode = "(function (d,y,B){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),y,B);const D=@getByIdDirectPrivate(d,\"stream\"),I=@getByIdDirectPrivate(D,\"state\");if(!@writableStreamCloseQueuedOrInFlight(D)&&I===\"writable\"){const _=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(D,_)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)}catch(D){@writableStreamDefaultControllerErrorIfNeeded(d,D)}})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -502,7 +502,7 @@ const JSC::ConstructorKind s_transformStreamInternalsCreateTransformStreamCodeCo const JSC::ImplementationVisibility s_transformStreamInternalsCreateTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsCreateTransformStreamCodeLength = 513; static const JSC::Intrinsic s_transformStreamInternalsCreateTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (_,B,c,j,v,x,D){\"use strict\";if(j===@undefined)j=1;if(v===@undefined)v=()=>1;if(x===@undefined)x=0;if(D===@undefined)D=()=>1;@assert(j>=0),@assert(x>=0);const E={};@putByIdDirectPrivate(E,\"TransformStream\",!0);const F=new @TransformStream(E),q=@newPromiseCapability(@Promise);@initializeTransformStream(F,q.@promise,j,v,x,D);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(F,G,B,c),_().@then(()=>{q.@resolve.@call()},(I)=>{q.@reject.@call(@undefined,I)}),F})\n"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (q,x,D,E,_,F,j){\"use strict\";if(E===@undefined)E=1;if(_===@undefined)_=()=>1;if(F===@undefined)F=0;if(j===@undefined)j=()=>1;@assert(E>=0),@assert(F>=0);const G={};@putByIdDirectPrivate(G,\"TransformStream\",!0);const I=new @TransformStream(G),v=@newPromiseCapability(@Promise);@initializeTransformStream(I,v.@promise,E,_,F,j);const B=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(I,B,x,D),q().@then(()=>{v.@resolve.@call()},(c)=>{v.@reject.@call(@undefined,c)}),I})\n"; // initializeTransformStream const JSC::ConstructAbility s_transformStreamInternalsInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -510,7 +510,7 @@ const JSC::ConstructorKind s_transformStreamInternalsInitializeTransformStreamCo const JSC::ImplementationVisibility s_transformStreamInternalsInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsInitializeTransformStreamCodeLength = 1015; static const JSC::Intrinsic s_transformStreamInternalsInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (B,T,j,I,q,J){\"use strict\";const v=()=>{return T},K=(F)=>{return @transformStreamDefaultSinkWriteAlgorithm(B,F)},x=(F)=>{return @transformStreamDefaultSinkAbortAlgorithm(B,F)},L=()=>{return @transformStreamDefaultSinkCloseAlgorithm(B)},C=@createWritableStream(v,K,L,x,j,I),f=()=>{return @transformStreamDefaultSourcePullAlgorithm(B)},D=(F)=>{return @transformStreamErrorWritableAndUnblockWrite(B,F),@Promise.@resolve()},G={};@putByIdDirectPrivate(G,\"start\",v),@putByIdDirectPrivate(G,\"pull\",f),@putByIdDirectPrivate(G,\"cancel\",D);const E={};@putByIdDirectPrivate(E,\"size\",J),@putByIdDirectPrivate(E,\"highWaterMark\",q);const N=new @ReadableStream(G,E);@putByIdDirectPrivate(B,\"writable\",C),@putByIdDirectPrivate(B,\"internalWritable\",@getInternalWritableStream(C)),@putByIdDirectPrivate(B,\"readable\",N),@putByIdDirectPrivate(B,\"backpressure\",@undefined),@putByIdDirectPrivate(B,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(B,!0),@putByIdDirectPrivate(B,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (f,K,B,T,j,J){\"use strict\";const q=()=>{return K},L=(G)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,G)},v=(G)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,G)},x=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},C=@createWritableStream(q,L,x,v,B,T),N=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},D=(G)=>{return @transformStreamErrorWritableAndUnblockWrite(f,G),@Promise.@resolve()},I={};@putByIdDirectPrivate(I,\"start\",q),@putByIdDirectPrivate(I,\"pull\",N),@putByIdDirectPrivate(I,\"cancel\",D);const E={};@putByIdDirectPrivate(E,\"size\",J),@putByIdDirectPrivate(E,\"highWaterMark\",j);const F=new @ReadableStream(I,E);@putByIdDirectPrivate(f,\"writable\",C),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(C)),@putByIdDirectPrivate(f,\"readable\",F),@putByIdDirectPrivate(f,\"backpressure\",@undefined),@putByIdDirectPrivate(f,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(f,!0),@putByIdDirectPrivate(f,\"controller\",@undefined)})\n"; // transformStreamError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -542,7 +542,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeLength = 294; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerCode = "(function (d,P,_,b){\"use strict\";@assert(@isTransformStream(d)),@assert(@getByIdDirectPrivate(d,\"controller\")===@undefined),@putByIdDirectPrivate(P,\"stream\",d),@putByIdDirectPrivate(d,\"controller\",P),@putByIdDirectPrivate(P,\"transformAlgorithm\",_),@putByIdDirectPrivate(P,\"flushAlgorithm\",b)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerCode = "(function (d,_,b,P){\"use strict\";@assert(@isTransformStream(d)),@assert(@getByIdDirectPrivate(d,\"controller\")===@undefined),@putByIdDirectPrivate(_,\"stream\",d),@putByIdDirectPrivate(d,\"controller\",_),@putByIdDirectPrivate(_,\"transformAlgorithm\",b),@putByIdDirectPrivate(_,\"flushAlgorithm\",P)})\n"; // setUpTransformStreamDefaultControllerFromTransformer const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -566,7 +566,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeLength = 622; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (S,W){\"use strict\";const f=@getByIdDirectPrivate(S,\"stream\"),g=@getByIdDirectPrivate(f,\"readable\"),i=@getByIdDirectPrivate(g,\"readableStreamController\");if(@assert(i!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(i))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(i,W)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(f,j),@getByIdDirectPrivate(g,\"storedError\")}const _=!@readableStreamDefaultControllerShouldCallPull(i);if(_!==@getByIdDirectPrivate(f,\"backpressure\"))@assert(_),@transformStreamSetBackpressure(f,!0)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (_,S){\"use strict\";const f=@getByIdDirectPrivate(_,\"stream\"),g=@getByIdDirectPrivate(f,\"readable\"),i=@getByIdDirectPrivate(g,\"readableStreamController\");if(@assert(i!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(i))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(i,S)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(f,j),@getByIdDirectPrivate(g,\"storedError\")}const W=!@readableStreamDefaultControllerShouldCallPull(i);if(W!==@getByIdDirectPrivate(f,\"backpressure\"))@assert(W),@transformStreamSetBackpressure(f,!0)})\n"; // transformStreamDefaultControllerError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -598,7 +598,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkW const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeLength = 764; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode = "(function (d,v){\"use strict\";const f=@getByIdDirectPrivate(d,\"internalWritable\");@assert(@getByIdDirectPrivate(f,\"state\")===\"writable\");const j=@getByIdDirectPrivate(d,\"controller\");if(@getByIdDirectPrivate(d,\"backpressure\")){const x=@newPromiseCapability(@Promise),_=@getByIdDirectPrivate(d,\"backpressureChangePromise\");return @assert(_!==@undefined),_.@promise.@then(()=>{const z=@getByIdDirectPrivate(f,\"state\");if(z===\"erroring\"){x.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(z===\"writable\"),@transformStreamDefaultControllerPerformTransform(j,v).@then(()=>{x.@resolve()},(q)=>{x.@reject.@call(@undefined,q)})},(z)=>{x.@reject.@call(@undefined,z)}),x.@promise}return @transformStreamDefaultControllerPerformTransform(j,v)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode = "(function (_,d){\"use strict\";const v=@getByIdDirectPrivate(_,\"internalWritable\");@assert(@getByIdDirectPrivate(v,\"state\")===\"writable\");const f=@getByIdDirectPrivate(_,\"controller\");if(@getByIdDirectPrivate(_,\"backpressure\")){const j=@newPromiseCapability(@Promise),q=@getByIdDirectPrivate(_,\"backpressureChangePromise\");return @assert(q!==@undefined),q.@promise.@then(()=>{const x=@getByIdDirectPrivate(v,\"state\");if(x===\"erroring\"){j.@reject.@call(@undefined,@getByIdDirectPrivate(v,\"storedError\"));return}@assert(x===\"writable\"),@transformStreamDefaultControllerPerformTransform(f,d).@then(()=>{j.@resolve()},(z)=>{j.@reject.@call(@undefined,z)})},(x)=>{j.@reject.@call(@undefined,x)}),j.@promise}return @transformStreamDefaultControllerPerformTransform(f,d)})\n"; // transformStreamDefaultSinkAbortAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -614,7 +614,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkC const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeLength = 789; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode = "(function (_){\"use strict\";const I=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(_,\"controller\"),f=@getByIdDirectPrivate(I,\"readableStreamController\"),u=@getByIdDirectPrivate(k,\"flushAlgorithm\");@assert(u!==@undefined);const v=@getByIdDirectPrivate(k,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(k);const q=@newPromiseCapability(@Promise);return v.@then(()=>{if(@getByIdDirectPrivate(I,\"state\")===@streamErrored){q.@reject.@call(@undefined,@getByIdDirectPrivate(I,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(f))@readableStreamDefaultControllerClose(f);q.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(k,\"stream\"),j),q.@reject.@call(@undefined,@getByIdDirectPrivate(I,\"storedError\"))}),q.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode = "(function (_){\"use strict\";const q=@getByIdDirectPrivate(_,\"readable\"),I=@getByIdDirectPrivate(_,\"controller\"),f=@getByIdDirectPrivate(q,\"readableStreamController\"),j=@getByIdDirectPrivate(I,\"flushAlgorithm\");@assert(j!==@undefined);const k=@getByIdDirectPrivate(I,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(I);const u=@newPromiseCapability(@Promise);return k.@then(()=>{if(@getByIdDirectPrivate(q,\"state\")===@streamErrored){u.@reject.@call(@undefined,@getByIdDirectPrivate(q,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(f))@readableStreamDefaultControllerClose(f);u.@resolve()},(v)=>{@transformStreamError(@getByIdDirectPrivate(I,\"stream\"),v),u.@reject.@call(@undefined,@getByIdDirectPrivate(q,\"storedError\"))}),u.@promise})\n"; // transformStreamDefaultSourcePullAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -656,7 +656,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructor const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdinStreamCodeLength = 1799; static const JSC::Intrinsic s_processObjectInternalsGetStdinStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdinStreamCode = "(function (Y,G,K){\"use strict\";var L={path:\"node:process\",require:G},M=(H)=>L.require(H),{Duplex:N,eos:P,destroy:Q}=M(\"node:stream\"),j=class H extends N{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return M(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(T){const U=this.#J;if(this.#J=null,U)U(T);else if(T)this.destroy(T);else if(!this.#z&&!this.#H)this.destroy()}_destroy(T,U){if(!T&&this.#J!==null){var I=class z extends Error{constructor(J=\"The operation was aborted\",V=void 0){if(V!==void 0&&typeof V!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(V,null,2)}`);super(J,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};T=new I}if(this.#J===null)U(T);else if(this.#J=U,this.#j)Q(this.#j,T)}setRawMode(T){}on(T,U){if(T===\"readable\")this.ref(),this.#G=!0;return super.on(T,U)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#Y\?\?=K.stdin.stream().getReader(),this.#$\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#$)clearInterval(this.#$),this.#$=null}async#M(){try{var T,U;const I=this.#Y.readMany();if(!I\?.then)({done:T,value:U}=I);else({done:T,value:U}=await I);if(!T){this.push(U[0]);const z=U.length;for(let J=1;J{if(this.#I){const I=this.#I;this.#I=null,I()}}),U.on(\"drain\",()=>{if(this.#K){const I=this.#K;this.#K=null,I()}}),P(U,(I)=>{if(this.#H=!1,I)Q(U,I);this.#L(I)}),U}_write(T,U,I){var z=this.#j;if(!z)z=this.#N();if(z.write(T,U))I();else this.#K=I}_final(T){this.#j.end(),this.#I=(...U)=>T(...U)}};return new j})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (Y,j,z){\"use strict\";var L={path:\"node:process\",require:j},G=(U)=>L.require(U),{Duplex:N,eos:H,destroy:Q}=G(\"node:stream\"),T=class U extends N{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return G(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(P){const V=this.#J;if(this.#J=null,V)V(P);else if(P)this.destroy(P);else if(!this.#z&&!this.#H)this.destroy()}_destroy(P,V){if(!P&&this.#J!==null){var I=class J extends Error{constructor(K=\"The operation was aborted\",M=void 0){if(M!==void 0&&typeof M!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(M,null,2)}`);super(K,M);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};P=new I}if(this.#J===null)V(P);else if(this.#J=V,this.#j)Q(this.#j,P)}setRawMode(P){}on(P,V){if(P===\"readable\")this.ref(),this.#G=!0;return super.on(P,V)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#Y\?\?=z.stdin.stream().getReader(),this.#$\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#$)clearInterval(this.#$),this.#$=null}async#M(){try{var P,V;const I=this.#Y.readMany();if(!I\?.then)({done:P,value:V}=I);else({done:P,value:V}=await I);if(!P){this.push(V[0]);const J=V.length;for(let K=1;K{if(this.#I){const I=this.#I;this.#I=null,I()}}),V.on(\"drain\",()=>{if(this.#K){const I=this.#K;this.#K=null,I()}}),H(V,(I)=>{if(this.#H=!1,I)Q(V,I);this.#L(I)}),V}_write(P,V,I){var J=this.#j;if(!J)J=this.#N();if(J.write(P,V))I();else this.#K=I}_final(P){this.#j.end(),this.#I=(...V)=>P(...V)}};return new T})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -674,7 +674,7 @@ const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstru const JSC::ImplementationVisibility s_transformStreamInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInitializeTransformStreamCodeLength = 1334; static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let u=arguments[0];if(@isObject(u)&&@getByIdDirectPrivate(u,\"TransformStream\"))return this;let G=arguments[1],E=arguments[2];if(u===@undefined)u=null;if(E===@undefined)E={};if(G===@undefined)G={};let j={};if(u!==null){if(\"start\"in u){if(j[\"start\"]=u[\"start\"],typeof j[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in u){if(j[\"transform\"]=u[\"transform\"],typeof j[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in u){if(j[\"flush\"]=u[\"flush\"],typeof j[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in u)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in u)@throwRangeError(\"TransformStream transformer has a writableType\")}const q=@extractHighWaterMark(E,0),J=@extractSizeAlgorithm(E),_=@extractHighWaterMark(G,1),v=@extractSizeAlgorithm(G),x=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,x.@promise,_,v,q,J),@setUpTransformStreamDefaultControllerFromTransformer(this,u,j),(\"start\"in j)){const I=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(u,j[\"start\"],[I]))().@then(()=>{x.@resolve.@call()},(B)=>{x.@reject.@call(@undefined,B)})}else x.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let u=arguments[0];if(@isObject(u)&&@getByIdDirectPrivate(u,\"TransformStream\"))return this;let j=arguments[1],q=arguments[2];if(u===@undefined)u=null;if(q===@undefined)q={};if(j===@undefined)j={};let F={};if(u!==null){if(\"start\"in u){if(F[\"start\"]=u[\"start\"],typeof F[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in u){if(F[\"transform\"]=u[\"transform\"],typeof F[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in u){if(F[\"flush\"]=u[\"flush\"],typeof F[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in u)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in u)@throwRangeError(\"TransformStream transformer has a writableType\")}const v=@extractHighWaterMark(q,0),G=@extractSizeAlgorithm(q),x=@extractHighWaterMark(j,1),I=@extractSizeAlgorithm(j),B=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,B.@promise,x,I,v,G),@setUpTransformStreamDefaultControllerFromTransformer(this,u,F),(\"start\"in F)){const J=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(u,F[\"start\"],[J]))().@then(()=>{B.@resolve.@call()},(_)=>{B.@reject.@call(@undefined,_)})}else B.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -701,6 +701,40 @@ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) #undef DEFINE_BUILTIN_GENERATOR +/* Module.ts */ +// main +const JSC::ConstructAbility s_moduleMainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_moduleMainCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_moduleMainCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_moduleMainCodeLength = 63; +static const JSC::Intrinsic s_moduleMainCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_moduleMainCode = "(function (){\"use strict\";return @requireMap.@get(@Bun.main)})\n"; + +// require +const JSC::ConstructAbility s_moduleRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_moduleRequireCodeLength = 871; +static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const y=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(y)return @evaluateCommonJSModule(y),y.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let M=@Loader.registry.@get(_);if(M\?.evaluated){const h=M.module,l=@Loader.getModuleNamespaceObject(h),r=l\?.[@commonJSSymbol]===0||l\?.default\?.[@commonJSSymbol]===0\?l.default:l;return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const b=@createCommonJSModule(_,{},!1);@requireMap.@set(_,b);var f=this.@require(_,b);if(f===-1){try{f=@requireESM(_)}catch(h){throw @requireMap.@delete(_),h}if(M=@Loader.registry.@get(_),M\?.evaluated){const h=@Loader.getModuleNamespaceObject(M.module);return b.exports=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h}}return @evaluateCommonJSModule(b),b.exports})\n"; + +// requireResolve +const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_moduleRequireResolveCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_moduleRequireResolveCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_moduleRequireResolveCodeLength = 65; +static const JSC::Intrinsic s_moduleRequireResolveCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_moduleRequireResolveCode = "(function (n){\"use strict\";return @resolveSync(n,this.path,!1)})\n"; + +#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ +JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ +{\ + JSVMClientData* clientData = static_cast(vm.clientData); \ + return clientData->builtinFunctions().moduleBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().moduleBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ +} +WEBCORE_FOREACH_MODULE_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + /* JSBufferPrototype.ts */ // setBigUint64 const JSC::ConstructAbility s_jsBufferPrototypeSetBigUint64CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -900,7 +934,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt8CodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt8CodeLength = 132; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt8Code = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(c,d),c+1})\n"; +const char* const s_jsBufferPrototypeWriteUInt8Code = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(d,c),d+1})\n"; // writeInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -948,7 +982,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt32BECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt32BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteInt32BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!1),c+4})\n"; // writeUInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -956,7 +990,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt32LECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt32LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(c,d,!0),c+4})\n"; +const char* const s_jsBufferPrototypeWriteUInt32LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!0),d+4})\n"; // writeUInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -972,7 +1006,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteIntLECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteIntLECodeLength = 573; static const JSC::Intrinsic s_jsBufferPrototypeWriteIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteIntLECode = "(function (c,j,r){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:{d.setInt8(j,c);break}case 2:{d.setInt16(j,c,!0);break}case 3:{d.setUint16(j,c&65535,!0),d.setInt8(j+2,Math.floor(c*0.0000152587890625));break}case 4:{d.setInt32(j,c,!0);break}case 5:{d.setUint32(j,c|0,!0),d.setInt8(j+4,Math.floor(c*0.00000000023283064365386964));break}case 6:{d.setUint32(j,c|0,!0),d.setInt16(j+4,Math.floor(c*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return j+r})\n"; +const char* const s_jsBufferPrototypeWriteIntLECode = "(function (d,r,c){\"use strict\";const j=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{j.setInt8(r,d);break}case 2:{j.setInt16(r,d,!0);break}case 3:{j.setUint16(r,d&65535,!0),j.setInt8(r+2,Math.floor(d*0.0000152587890625));break}case 4:{j.setInt32(r,d,!0);break}case 5:{j.setUint32(r,d|0,!0),j.setInt8(r+4,Math.floor(d*0.00000000023283064365386964));break}case 6:{j.setUint32(r,d|0,!0),j.setInt16(r+4,Math.floor(d*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+c})\n"; // writeIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -980,7 +1014,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteIntBECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteIntBECodeLength = 573; static const JSC::Intrinsic s_jsBufferPrototypeWriteIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteIntBECode = "(function (r,E,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{d.setInt8(E,r);break}case 2:{d.setInt16(E,r,!1);break}case 3:{d.setUint16(E+1,r&65535,!1),d.setInt8(E,Math.floor(r*0.0000152587890625));break}case 4:{d.setInt32(E,r,!1);break}case 5:{d.setUint32(E+1,r|0,!1),d.setInt8(E,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(E+2,r|0,!1),d.setInt16(E,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return E+c})\n"; +const char* const s_jsBufferPrototypeWriteIntBECode = "(function (d,r,E){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(E){case 1:{c.setInt8(r,d);break}case 2:{c.setInt16(r,d,!1);break}case 3:{c.setUint16(r+1,d&65535,!1),c.setInt8(r,Math.floor(d*0.0000152587890625));break}case 4:{c.setInt32(r,d,!1);break}case 5:{c.setUint32(r+1,d|0,!1),c.setInt8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{c.setUint32(r+2,d|0,!1),c.setInt16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+E})\n"; // writeUIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -988,7 +1022,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntLECodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUIntLECodeLength = 579; static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (d,c,r){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:{E.setUint8(c,d);break}case 2:{E.setUint16(c,d,!0);break}case 3:{E.setUint16(c,d&65535,!0),E.setUint8(c+2,Math.floor(d*0.0000152587890625));break}case 4:{E.setUint32(c,d,!0);break}case 5:{E.setUint32(c,d|0,!0),E.setUint8(c+4,Math.floor(d*0.00000000023283064365386964));break}case 6:{E.setUint32(c,d|0,!0),E.setUint16(c+4,Math.floor(d*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return c+r})\n"; +const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (d,r,E){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(E){case 1:{c.setUint8(r,d);break}case 2:{c.setUint16(r,d,!0);break}case 3:{c.setUint16(r,d&65535,!0),c.setUint8(r+2,Math.floor(d*0.0000152587890625));break}case 4:{c.setUint32(r,d,!0);break}case 5:{c.setUint32(r,d|0,!0),c.setUint8(r+4,Math.floor(d*0.00000000023283064365386964));break}case 6:{c.setUint32(r,d|0,!0),c.setUint16(r+4,Math.floor(d*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+E})\n"; // writeUIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1044,7 +1078,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64BECodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigInt64BECodeLength = 138; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigInt64BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,d,!1),c+8})\n"; +const char* const s_jsBufferPrototypeWriteBigInt64BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!1),d+8})\n"; // writeBigUInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1108,7 +1142,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64WriteCodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeBase64WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64WriteCodeLength = 67; static const JSC::Intrinsic s_jsBufferPrototypeBase64WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64WriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"base64\")})\n"; +const char* const s_jsBufferPrototypeBase64WriteCode = "(function (a,r,d){\"use strict\";return this.write(a,r,d,\"base64\")})\n"; // base64urlWrite const JSC::ConstructAbility s_jsBufferPrototypeBase64urlWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1164,7 +1198,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeAsciiSliceCodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeAsciiSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeAsciiSliceCodeLength = 65; static const JSC::Intrinsic s_jsBufferPrototypeAsciiSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeAsciiSliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"ascii\")})\n"; +const char* const s_jsBufferPrototypeAsciiSliceCode = "(function (r,d){\"use strict\";return this.toString(r,d,\"ascii\")})\n"; // base64Slice const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1278,7 +1312,7 @@ const JSC::ConstructorKind s_readableByteStreamControllerByobRequestCodeConstruc const JSC::ImplementationVisibility s_readableByteStreamControllerByobRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamControllerByobRequestCodeLength = 523; static const JSC::Intrinsic s_readableByteStreamControllerByobRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamControllerByobRequestCode = "(function (){\"use strict\";if(!@isReadableByteStreamController(this))throw @makeGetterTypeError(\"ReadableByteStreamController\",\"byobRequest\");var _=@getByIdDirectPrivate(this,\"byobRequest\");if(_===@undefined){var a=@getByIdDirectPrivate(this,\"pendingPullIntos\");const l=a.peek();if(l){const m=new @Uint8Array(l.buffer,l.byteOffset+l.bytesFilled,l.byteLength-l.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,m,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; +const char* const s_readableByteStreamControllerByobRequestCode = "(function (){\"use strict\";if(!@isReadableByteStreamController(this))throw @makeGetterTypeError(\"ReadableByteStreamController\",\"byobRequest\");var _=@getByIdDirectPrivate(this,\"byobRequest\");if(_===@undefined){var m=@getByIdDirectPrivate(this,\"pendingPullIntos\");const a=m.peek();if(a){const l=new @Uint8Array(a.buffer,a.byteOffset+a.bytesFilled,a.byteLength-a.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,l,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; // desiredSize const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1304,7 +1338,7 @@ const JSC::ConstructorKind s_consoleObjectAsyncIteratorCodeConstructorKind = JSC const JSC::ImplementationVisibility s_consoleObjectAsyncIteratorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectAsyncIteratorCodeLength = 577; static const JSC::Intrinsic s_consoleObjectAsyncIteratorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const j=async function*q(){var D=@Bun.stdin.stream().getReader(),F=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),G,H=@Bun.indexOfLine;try{while(!0){var J,K,w;const L=D.readMany();if(@isPromise(L))({done:J,value:K}=await L);else({done:J,value:K}=L);if(J){if(w)yield F.decode(w);return}var _;for(let M of K){if(_=M,w)_=@Buffer.concat([w,M]),w=null;var z=0,A=H(_,z);while(A!==-1)yield F.decode(_.subarray(z,A)),z=A+1,A=H(_,z);w=_.subarray(z)}}}catch(L){G=L}finally{if(D.releaseLock(),G)throw G}},m=globalThis.Symbol.asyncIterator;return this[m]=j,j()})\n"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const w=async function*_(){var A=@Bun.stdin.stream().getReader(),F=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),H,J=@Bun.indexOfLine;try{while(!0){var K,m,L;const D=A.readMany();if(@isPromise(D))({done:K,value:m}=await D);else({done:K,value:m}=D);if(K){if(L)yield F.decode(L);return}var M;for(let z of m){if(M=z,L)M=@Buffer.concat([L,z]),L=null;var q=0,B=J(M,q);while(B!==-1)yield F.decode(M.subarray(q,B)),q=B+1,B=J(M,q);L=M.subarray(q)}}}catch(D){H=D}finally{if(A.releaseLock(),H)throw H}},G=globalThis.Symbol.asyncIterator;return this[G]=w,w()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1370,7 +1404,7 @@ const JSC::ConstructorKind s_readableStreamInternalsSetupReadableStreamDefaultCo const JSC::ImplementationVisibility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength = 523; static const JSC::Intrinsic s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (_,w,f,b,q,v,x){\"use strict\";const B=new @ReadableStreamDefaultController(_,w,f,b,@isReadableStream),C=()=>@promiseInvokeOrNoopMethod(w,v,[B]),j=(D)=>@promiseInvokeOrNoopMethod(w,x,[D]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",j),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(_,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (b,j,v,w,_,x,f){\"use strict\";const B=new @ReadableStreamDefaultController(b,j,v,w,@isReadableStream),C=()=>@promiseInvokeOrNoopMethod(j,x,[B]),D=(q)=>@promiseInvokeOrNoopMethod(j,f,[q]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",D),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1386,7 +1420,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerStartCodeLength = 465; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerStartCode = "(function (m){\"use strict\";if(@getByIdDirectPrivate(m,\"started\")!==-1)return;const B=@getByIdDirectPrivate(m,\"underlyingSource\"),a=B.start;@putByIdDirectPrivate(m,\"started\",0),@promiseInvokeOrNoopMethodNoCatch(B,a,[m]).@then(()=>{@putByIdDirectPrivate(m,\"started\",1),@assert(!@getByIdDirectPrivate(m,\"pulling\")),@assert(!@getByIdDirectPrivate(m,\"pullAgain\")),@readableStreamDefaultControllerCallPullIfNeeded(m)},(p)=>{@readableStreamDefaultControllerError(m,p)})})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerStartCode = "(function (m){\"use strict\";if(@getByIdDirectPrivate(m,\"started\")!==-1)return;const B=@getByIdDirectPrivate(m,\"underlyingSource\"),p=B.start;@putByIdDirectPrivate(m,\"started\",0),@promiseInvokeOrNoopMethodNoCatch(B,p,[m]).@then(()=>{@putByIdDirectPrivate(m,\"started\",1),@assert(!@getByIdDirectPrivate(m,\"pulling\")),@assert(!@getByIdDirectPrivate(m,\"pullAgain\")),@readableStreamDefaultControllerCallPullIfNeeded(m)},(a)=>{@readableStreamDefaultControllerError(m,a)})})\n"; // readableStreamPipeToWritableStream const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1394,7 +1428,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToWritable const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeLength = 1631; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (f,k,D,q,w,x){\"use strict\";if(@assert(@isReadableStream(f)),@assert(@isWritableStream(k)),@assert(!@isReadableStreamLocked(f)),@assert(!@isWritableStreamLocked(k)),@assert(x===@undefined||@isAbortSignal(x)),@getByIdDirectPrivate(f,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let z={source:f,destination:k,preventAbort:q,preventCancel:w,preventClose:D,signal:x};if(z.reader=@acquireReadableStreamDefaultReader(f),z.writer=@acquireWritableStreamDefaultWriter(k),@putByIdDirectPrivate(f,\"disturbed\",!0),z.finalized=!1,z.shuttingDown=!1,z.promiseCapability=@newPromiseCapability(@Promise),z.pendingReadPromiseCapability=@newPromiseCapability(@Promise),z.pendingReadPromiseCapability.@resolve.@call(),z.pendingWritePromise=@Promise.@resolve(),x!==@undefined){const B=(F)=>{if(z.finalized)return;@pipeToShutdownWithAction(z,()=>{const _=!z.preventAbort&&@getByIdDirectPrivate(z.destination,\"state\")===\"writable\"\?@writableStreamAbort(z.destination,F):@Promise.@resolve(),H=!z.preventCancel&&@getByIdDirectPrivate(z.source,\"state\")===@streamReadable\?@readableStreamCancel(z.source,F):@Promise.@resolve();let E=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}E.@resolve.@call()},K=(L)=>{E.@reject.@call(@undefined,L)};return _.@then(J,K),H.@then(J,K),E.@promise},F)};if(@whenSignalAborted(x,B))return z.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(z),@pipeToErrorsMustBePropagatedBackward(z),@pipeToClosingMustBePropagatedForward(z),@pipeToClosingMustBePropagatedBackward(z),@pipeToLoop(z),z.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (_,z,k,f,q,B){\"use strict\";if(@assert(@isReadableStream(_)),@assert(@isWritableStream(z)),@assert(!@isReadableStreamLocked(_)),@assert(!@isWritableStreamLocked(z)),@assert(B===@undefined||@isAbortSignal(B)),@getByIdDirectPrivate(_,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let H={source:_,destination:z,preventAbort:f,preventCancel:q,preventClose:k,signal:B};if(H.reader=@acquireReadableStreamDefaultReader(_),H.writer=@acquireWritableStreamDefaultWriter(z),@putByIdDirectPrivate(_,\"disturbed\",!0),H.finalized=!1,H.shuttingDown=!1,H.promiseCapability=@newPromiseCapability(@Promise),H.pendingReadPromiseCapability=@newPromiseCapability(@Promise),H.pendingReadPromiseCapability.@resolve.@call(),H.pendingWritePromise=@Promise.@resolve(),B!==@undefined){const I=(J)=>{if(H.finalized)return;@pipeToShutdownWithAction(H,()=>{const K=!H.preventAbort&&@getByIdDirectPrivate(H.destination,\"state\")===\"writable\"\?@writableStreamAbort(H.destination,J):@Promise.@resolve(),E=!H.preventCancel&&@getByIdDirectPrivate(H.source,\"state\")===@streamReadable\?@readableStreamCancel(H.source,J):@Promise.@resolve();let w=@newPromiseCapability(@Promise),x=!0,T=()=>{if(x){x=!1;return}w.@resolve.@call()},F=(G)=>{w.@reject.@call(@undefined,G)};return K.@then(T,F),E.@then(T,F),w.@promise},J)};if(@whenSignalAborted(B,I))return H.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(H),@pipeToErrorsMustBePropagatedBackward(H),@pipeToClosingMustBePropagatedForward(H),@pipeToClosingMustBePropagatedBackward(H),@pipeToLoop(H),H.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1410,7 +1444,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToDoReadWriteCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsPipeToDoReadWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToDoReadWriteCodeLength = 731; static const JSC::Intrinsic s_readableStreamInternalsPipeToDoReadWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToDoReadWriteCode = "(function (_){\"use strict\";return @assert(!_.shuttingDown),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),@getByIdDirectPrivate(_.writer,\"readyPromise\").@promise.@then(()=>{if(_.shuttingDown){_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);return}@readableStreamDefaultReaderRead(_.reader).@then((m)=>{const d=!m.done&&@getByIdDirectPrivate(_.writer,\"stream\")!==@undefined;if(_.pendingReadPromiseCapability.@resolve.@call(@undefined,d),!d)return;_.pendingWritePromise=@writableStreamDefaultWriterWrite(_.writer,m.value)},(m)=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)})},(m)=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)}),_.pendingReadPromiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsPipeToDoReadWriteCode = "(function (m){\"use strict\";return @assert(!m.shuttingDown),m.pendingReadPromiseCapability=@newPromiseCapability(@Promise),@getByIdDirectPrivate(m.writer,\"readyPromise\").@promise.@then(()=>{if(m.shuttingDown){m.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);return}@readableStreamDefaultReaderRead(m.reader).@then((_)=>{const d=!_.done&&@getByIdDirectPrivate(m.writer,\"stream\")!==@undefined;if(m.pendingReadPromiseCapability.@resolve.@call(@undefined,d),!d)return;m.pendingWritePromise=@writableStreamDefaultWriterWrite(m.writer,_.value)},(_)=>{m.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)})},(_)=>{m.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)}),m.pendingReadPromiseCapability.@promise})\n"; // pipeToErrorsMustBePropagatedForward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1418,7 +1452,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagated const JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeLength = 438; static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode = "(function (_){\"use strict\";const b=()=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const d=@getByIdDirectPrivate(_.source,\"storedError\");if(!_.preventAbort){@pipeToShutdownWithAction(_,()=>@writableStreamAbort(_.destination,d),d);return}@pipeToShutdown(_,d)};if(@getByIdDirectPrivate(_.source,\"state\")===@streamErrored){b();return}@getByIdDirectPrivate(_.reader,\"closedPromiseCapability\").@promise.@then(@undefined,b)})\n"; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode = "(function (d){\"use strict\";const _=()=>{d.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const b=@getByIdDirectPrivate(d.source,\"storedError\");if(!d.preventAbort){@pipeToShutdownWithAction(d,()=>@writableStreamAbort(d.destination,b),b);return}@pipeToShutdown(d,b)};if(@getByIdDirectPrivate(d.source,\"state\")===@streamErrored){_();return}@getByIdDirectPrivate(d.reader,\"closedPromiseCapability\").@promise.@then(@undefined,_)})\n"; // pipeToErrorsMustBePropagatedBackward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1450,7 +1484,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownWithActionCode const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownWithActionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToShutdownWithActionCodeLength = 458; static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownWithActionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (m,b){\"use strict\";if(m.shuttingDown)return;m.shuttingDown=!0;const d=arguments.length>2,g=arguments[2],h=()=>{b().@then(()=>{if(d)@pipeToFinalize(m,g);else @pipeToFinalize(m)},(j)=>{@pipeToFinalize(m,j)})};if(@getByIdDirectPrivate(m.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(m.destination)){m.pendingReadPromiseCapability.@promise.@then(()=>{m.pendingWritePromise.@then(h,h)},(_)=>@pipeToFinalize(m,_));return}h()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (_,m){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const b=arguments.length>2,d=arguments[2],g=()=>{m().@then(()=>{if(b)@pipeToFinalize(_,d);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(g,g)},(h)=>@pipeToFinalize(_,h));return}g()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1482,7 +1516,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeePullFunctio const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeePullFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeePullFunctionCodeLength = 764; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeePullFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode = "(function (i,_,f){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(_),function(m){if(@assert(@isObject(m)),@assert(typeof m.done===\"boolean\"),m.done&&!i.closedOrErrored){if(!i.canceled1)@readableStreamDefaultControllerClose(i.branch1.@readableStreamController);if(!i.canceled2)@readableStreamDefaultControllerClose(i.branch2.@readableStreamController);if(i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}if(i.closedOrErrored)return;if(!i.canceled1)@readableStreamDefaultControllerEnqueue(i.branch1.@readableStreamController,m.value);if(!i.canceled2)@readableStreamDefaultControllerEnqueue(i.branch2.@readableStreamController,f\?@structuredCloneForStream(m.value):m.value)})}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode = "(function (i,f,m){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(f),function(_){if(@assert(@isObject(_)),@assert(typeof _.done===\"boolean\"),_.done&&!i.closedOrErrored){if(!i.canceled1)@readableStreamDefaultControllerClose(i.branch1.@readableStreamController);if(!i.canceled2)@readableStreamDefaultControllerClose(i.branch2.@readableStreamController);if(i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}if(i.closedOrErrored)return;if(!i.canceled1)@readableStreamDefaultControllerEnqueue(i.branch1.@readableStreamController,_.value);if(!i.canceled2)@readableStreamDefaultControllerEnqueue(i.branch2.@readableStreamController,m\?@structuredCloneForStream(_.value):_.value)})}})\n"; // readableStreamTeeBranch1CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1530,7 +1564,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadDirectStreamCodeConstruc const JSC::ImplementationVisibility s_readableStreamInternalsReadDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadDirectStreamCodeLength = 900; static const JSC::Intrinsic s_readableStreamInternalsReadDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (j,w,_){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function x(q,A){if(A&&_\?.cancel){try{var B=_.cancel(A);@markPromiseAsHandled(B)}catch(v){}_=@undefined}if(q){if(@putByIdDirectPrivate(q,\"readableStreamController\",@undefined),@putByIdDirectPrivate(q,\"reader\",@undefined),A)@putByIdDirectPrivate(q,\"state\",@streamErrored),@putByIdDirectPrivate(q,\"storedError\",A);else @putByIdDirectPrivate(q,\"state\",@streamClosed);q=@undefined}}if(!_.pull){x();return}if(!@isCallable(_.pull)){x(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",w);const f=@getByIdDirectPrivate(j,\"highWaterMark\");w.start({highWaterMark:!f||f<64\?64:f}),@startDirectStream.@call(w,j,_.pull,x),@putByIdDirectPrivate(j,\"reader\",{});var z=_.pull(w);if(w=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (_,f,j){\"use strict\";@putByIdDirectPrivate(_,\"underlyingSource\",@undefined),@putByIdDirectPrivate(_,\"start\",@undefined);function q(x,z){if(z&&j\?.cancel){try{var A=j.cancel(z);@markPromiseAsHandled(A)}catch(B){}j=@undefined}if(x){if(@putByIdDirectPrivate(x,\"readableStreamController\",@undefined),@putByIdDirectPrivate(x,\"reader\",@undefined),z)@putByIdDirectPrivate(x,\"state\",@streamErrored),@putByIdDirectPrivate(x,\"storedError\",z);else @putByIdDirectPrivate(x,\"state\",@streamClosed);x=@undefined}}if(!j.pull){q();return}if(!@isCallable(j.pull)){q(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(_,\"readableStreamController\",f);const v=@getByIdDirectPrivate(_,\"highWaterMark\");f.start({highWaterMark:!v||v<64\?64:v}),@startDirectStream.@call(f,_,j.pull,q),@putByIdDirectPrivate(_,\"reader\",{});var w=j.pull(f);if(f=@undefined,w&&@isPromise(w))return w.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1546,7 +1580,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadStreamIntoSinkCodeConstr const JSC::ImplementationVisibility s_readableStreamInternalsReadStreamIntoSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadStreamIntoSinkCodeLength = 1395; static const JSC::Intrinsic s_readableStreamInternalsReadStreamIntoSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadStreamIntoSinkCode = "(async function (c,G,f){\"use strict\";var I=!1,z=!1;try{var E=c.getReader(),H=E.readMany();if(H&&@isPromise(H))H=await H;if(H.done)return I=!0,G.end();var J=H.value.length;const x=@getByIdDirectPrivate(c,\"highWaterMark\");if(f)@startDirectStream.@call(G,c,@undefined,()=>!z&&@markPromiseAsHandled(c.cancel()));G.start({highWaterMark:x||0});for(var K=0,P=H.value,A=H.value.length;K!x&&@markPromiseAsHandled(_.cancel()));D.start({highWaterMark:P||0});for(var H=0,f=F.value,J=F.value.length;H{var B=@createFulfilledPromise({value:S,done:!1});return S=@undefined,@readableStreamClose(C),C=@undefined,B}}else if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(y,{value:@undefined,done:!0})}@readableStreamClose(C)})\n"; +const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (c){\"use strict\";var v=this.@controlledReadableStream;if(!v||@getByIdDirectPrivate(v,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=c;return}if(@putByIdDirectPrivate(v,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,c)}catch(j){}var b;try{b=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(j){if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(y,j)}@readableStreamError(v,j);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var B=@getByIdDirectPrivate(v,\"reader\");if(B&&@isReadableStreamDefaultReader(B)){var C=this._pendingRead;if(C&&@isPromise(C)&&b\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(C,{value:b,done:!1}),@readableStreamClose(v);return}}if(b\?.byteLength){var S=@getByIdDirectPrivate(B,\"readRequests\");if(S\?.isNotEmpty()){@readableStreamFulfillReadRequest(v,b,!1),@readableStreamClose(v);return}@putByIdDirectPrivate(v,\"state\",@streamReadable),this.@pull=()=>{var j=@createFulfilledPromise({value:b,done:!1});return b=@undefined,@readableStreamClose(v),v=@undefined,j}}else if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(y,{value:@undefined,done:!0})}@readableStreamClose(v)})\n"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1610,7 +1644,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateTextStreamCodeConstruc const JSC::ImplementationVisibility s_readableStreamInternalsCreateTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateTextStreamCodeLength = 984; static const JSC::Intrinsic s_readableStreamInternalsCreateTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (v){\"use strict\";var x,A=[],C=!1,_=!1,E=\"\",q=@toLength(0),F=@newPromiseCapability(@Promise),G=!1;return x={start(){},write(w){if(typeof w===\"string\"){var z=@toLength(w.length);if(z>0)E+=w,C=!0,q+=z;return z}if(!w||!(@ArrayBuffer.@isView(w)||w instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const j=@toLength(w.byteLength);if(j>0)if(_=!0,E.length>0)@arrayPush(A,E,w),E=\"\";else @arrayPush(A,w);return q+=j,j},flush(){return 0},end(){if(G)return\"\";return x.fulfill()},fulfill(){G=!0;const w=x.finishInternal();return @fulfillPromise(F.@promise,w),w},finishInternal(){if(!C&&!_)return\"\";if(C&&!_)return E;if(_&&!C)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(A));var w=new @Bun.ArrayBufferSink;w.start({highWaterMark:q,asUint8Array:!0});for(let z of A)w.write(z);if(A.length=0,E.length>0)w.write(E),E=\"\";return new globalThis.TextDecoder().decode(w.end())},close(){try{if(!G)G=!0,x.fulfill()}catch(w){}}},[x,F]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (_){\"use strict\";var z,j=[],q=!1,w=!1,x=\"\",A=@toLength(0),C=@newPromiseCapability(@Promise),E=!1;return z={start(){},write(v){if(typeof v===\"string\"){var F=@toLength(v.length);if(F>0)x+=v,q=!0,A+=F;return F}if(!v||!(@ArrayBuffer.@isView(v)||v instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const G=@toLength(v.byteLength);if(G>0)if(w=!0,x.length>0)@arrayPush(j,x,v),x=\"\";else @arrayPush(j,v);return A+=G,G},flush(){return 0},end(){if(E)return\"\";return z.fulfill()},fulfill(){E=!0;const v=z.finishInternal();return @fulfillPromise(C.@promise,v),v},finishInternal(){if(!q&&!w)return\"\";if(q&&!w)return x;if(w&&!q)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(j));var v=new @Bun.ArrayBufferSink;v.start({highWaterMark:A,asUint8Array:!0});for(let F of j)v.write(F);if(j.length=0,x.length>0)v.write(x),x=\"\";return new globalThis.TextDecoder().decode(v.end())},close(){try{if(!E)E=!0,z.fulfill()}catch(v){}}},[z,C]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1626,7 +1660,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayStreamCodeCon const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeArrayStreamCodeLength = 797; static const JSC::Intrinsic s_readableStreamInternalsInitializeArrayStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (t,p){\"use strict\";var _=[],b=@newPromiseCapability(@Promise),d=!1;function j(){return d=!0,b.@resolve.@call(@undefined,_),_}var m={start(){},write(v){return @arrayPush(_,v),v.byteLength||v.length},flush(){return 0},end(){if(d)return[];return j()},close(){if(!d)j()}},q={@underlyingSource:t,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:m,close:@onCloseDirectStream,write:m.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",q),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (_,t){\"use strict\";var p=[],b=@newPromiseCapability(@Promise),d=!1;function j(){return d=!0,b.@resolve.@call(@undefined,p),p}var m={start(){},write(v){return @arrayPush(p,v),v.byteLength||v.length},flush(){return 0},end(){if(d)return[];return j()},close(){if(!d)j()}},q={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:m,close:@onCloseDirectStream,write:m.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",q),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1634,7 +1668,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayBufferStreamC const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayBufferStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeArrayBufferStreamCodeLength = 690; static const JSC::Intrinsic s_readableStreamInternalsInitializeArrayBufferStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = "(function (_,m){\"use strict\";var D=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},w=new @Bun.ArrayBufferSink;w.start(D);var b={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:w,close:@onCloseDirectStream,write:w.write.bind(w),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; +const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = "(function (_,m){\"use strict\";var w=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},D=new @Bun.ArrayBufferSink;D.start(w);var b={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:D,close:@onCloseDirectStream,write:D.write.bind(D),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; // readableStreamError const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1698,7 +1732,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeLength = 146; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerCancelCode = "(function (_,d){\"use strict\";return @putByIdDirectPrivate(_,\"queue\",@newQueue()),@getByIdDirectPrivate(_,\"cancelAlgorithm\").@call(@undefined,d)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerCancelCode = "(function (d,_){\"use strict\";return @putByIdDirectPrivate(d,\"queue\",@newQueue()),@getByIdDirectPrivate(d,\"cancelAlgorithm\").@call(@undefined,_)})\n"; // readableStreamDefaultControllerPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1754,7 +1788,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamAddReadRequest const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamAddReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamAddReadRequestCodeLength = 274; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamAddReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamAddReadRequestCode = "(function (h){\"use strict\";@assert(@isReadableStreamDefaultReader(@getByIdDirectPrivate(h,\"reader\"))),@assert(@getByIdDirectPrivate(h,\"state\")==@streamReadable);const i=@newPromise();return @getByIdDirectPrivate(@getByIdDirectPrivate(h,\"reader\"),\"readRequests\").push(i),i})\n"; +const char* const s_readableStreamInternalsReadableStreamAddReadRequestCode = "(function (i){\"use strict\";@assert(@isReadableStreamDefaultReader(@getByIdDirectPrivate(i,\"reader\"))),@assert(@getByIdDirectPrivate(i,\"state\")==@streamReadable);const h=@newPromise();return @getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").push(h),h})\n"; // isReadableStreamDisturbed const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1770,7 +1804,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeLength = 813; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericReleaseCode = "(function (c){\"use strict\";if(@assert(!!@getByIdDirectPrivate(c,\"ownerReadableStream\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(c,\"ownerReadableStream\"),\"reader\")===c),@getByIdDirectPrivate(@getByIdDirectPrivate(c,\"ownerReadableStream\"),\"state\")===@streamReadable)@getByIdDirectPrivate(c,\"closedPromiseCapability\").@reject.@call(@undefined,@makeTypeError(\"releasing lock of reader whose stream is still in readable state\"));else @putByIdDirectPrivate(c,\"closedPromiseCapability\",{@promise:@newHandledRejectedPromise(@makeTypeError(\"reader released lock\"))});const _=@getByIdDirectPrivate(c,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(_),@putByIdDirectPrivate(@getByIdDirectPrivate(c,\"ownerReadableStream\"),\"reader\",@undefined),@putByIdDirectPrivate(c,\"ownerReadableStream\",@undefined)})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericReleaseCode = "(function (_){\"use strict\";if(@assert(!!@getByIdDirectPrivate(_,\"ownerReadableStream\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"ownerReadableStream\"),\"reader\")===_),@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"ownerReadableStream\"),\"state\")===@streamReadable)@getByIdDirectPrivate(_,\"closedPromiseCapability\").@reject.@call(@undefined,@makeTypeError(\"releasing lock of reader whose stream is still in readable state\"));else @putByIdDirectPrivate(_,\"closedPromiseCapability\",{@promise:@newHandledRejectedPromise(@makeTypeError(\"reader released lock\"))});const c=@getByIdDirectPrivate(_,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(c),@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"ownerReadableStream\"),\"reader\",@undefined),@putByIdDirectPrivate(_,\"ownerReadableStream\",@undefined)})\n"; // readableStreamDefaultControllerCanCloseOrEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1786,7 +1820,7 @@ const JSC::ConstructorKind s_readableStreamInternalsLazyLoadStreamCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsLazyLoadStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsLazyLoadStreamCodeLength = 1589; static const JSC::Intrinsic s_readableStreamInternalsLazyLoadStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (W,I){\"use strict\";var N=@getByIdDirectPrivate(W,\"bunNativeType\"),J=@getByIdDirectPrivate(W,\"bunNativePtr\"),K=@lazyStreamPrototypeMap.@get(N);if(K===@undefined){let m=function(F){var{c:p,v:z}=this;this.c=@undefined,this.v=@undefined,f(F,p,z)},U=function(F){try{F.close()}catch(p){globalThis.reportError(p)}},M=function(F,p,z,A){A[0]=!1;var G;try{G=b(F,z,A)}catch(H){return p.error(H)}return f(G,p,z)};var j=m,Q=U,q=M,[b,x,X,y,O,Y,Z]=@lazyLoad(N),P=[!1],f;f=function F(p,z,A){if(p&&@isPromise(p))return p.then(m.bind({c:z,v:A}),(G)=>z.error(G));else if(typeof p===\"number\")if(A&&A.byteLength===p&&A.buffer===z.byobRequest\?.view\?.buffer)z.byobRequest.respondWithNewView(A);else z.byobRequest.respond(p);else if(p.constructor===@Uint8Array)z.enqueue(p);if(P[0]||p===!1)@enqueueJob(U,z),P[0]=!1};const E=O\?new FinalizationRegistry(O):null;K=class F{constructor(p,z,A){if(this.#f=p,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=z,A!==@undefined)this.start=(G)=>{G.enqueue(A)};if(E)E.register(this,p,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=x;#j(p){var z=this.#f;if(!z){p.close();return}M(z,p,p.byobRequest.view,P)}#m(p){var z=this.#f;E&&E.unregister(this.#b),Y&&Y(z,!1),X(z,p)}static deinit=O;static drain=Z},@lazyStreamPrototypeMap.@set(N,K)}const B=K.startSync(J,I);var _;const{drain:D,deinit:L}=K;if(D)_=D(J);if(B===0){if(O&&J&&@enqueueJob(O,J),(_\?.byteLength\?\?0)>0)return{start(m){m.enqueue(_),m.close()},type:\"bytes\"};return{start(m){m.close()},type:\"bytes\"}}return new K(J,B,_)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (E,m){\"use strict\";var y=@getByIdDirectPrivate(E,\"bunNativeType\"),q=@getByIdDirectPrivate(E,\"bunNativePtr\"),x=@lazyStreamPrototypeMap.@get(y);if(x===@undefined){let U=function(Y){var{c:Z,v:_}=this;this.c=@undefined,this.v=@undefined,K(Y,Z,_)},W=function(Y){try{Y.close()}catch(Z){globalThis.reportError(Z)}},X=function(Y,Z,_,p){p[0]=!1;var z;try{z=F(Y,_,p)}catch(A){return Z.error(A)}return K(z,Z,_)};var P=U,Q=W,O=X,[F,G,H,b,B,D,I]=@lazyLoad(y),J=[!1],K;K=function Y(Z,_,p){if(Z&&@isPromise(Z))return Z.then(U.bind({c:_,v:p}),(z)=>_.error(z));else if(typeof Z===\"number\")if(p&&p.byteLength===Z&&p.buffer===_.byobRequest\?.view\?.buffer)_.byobRequest.respondWithNewView(p);else _.byobRequest.respond(Z);else if(Z.constructor===@Uint8Array)_.enqueue(Z);if(J[0]||Z===!1)@enqueueJob(W,_),J[0]=!1};const j=B\?new FinalizationRegistry(B):null;x=class Y{constructor(Z,_,p){if(this.#f=Z,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=_,p!==@undefined)this.start=(z)=>{z.enqueue(p)};if(j)j.register(this,Z,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=G;#j(Z){var _=this.#f;if(!_){Z.close();return}X(_,Z,Z.byobRequest.view,J)}#m(Z){var _=this.#f;j&&j.unregister(this.#b),D&&D(_,!1),H(_,Z)}static deinit=B;static drain=I},@lazyStreamPrototypeMap.@set(y,x)}const L=x.startSync(q,m);var M;const{drain:f,deinit:N}=x;if(f)M=f(q);if(L===0){if(B&&q&&@enqueueJob(B,q),(M\?.byteLength\?\?0)>0)return{start(U){U.enqueue(M),U.close()},type:\"bytes\"};return{start(U){U.close()},type:\"bytes\"}}return new x(q,L,M)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1810,7 +1844,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayBufferD const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength = 727; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (j,q){\"use strict\";var x=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(j,\"underlyingSource\",@undefined);var z=@getByIdDirectPrivate(j,\"highWaterMark\");x.start(z\?{highWaterMark:z}:{});var A=@newPromiseCapability(@Promise),B=!1,C=q.pull,D=q.close,F={start(){},close(_){if(!B){if(B=!0,D)D();@fulfillPromise(A.@promise,x.end())}},end(){if(!B){if(B=!0,D)D();@fulfillPromise(A.@promise,x.end())}},flush(){return 0},write:x.write.bind(x)},G=!1;try{const _=C(F);if(_&&@isObject(_)&&@isPromise(_))return async function(O,v,w){while(!B)await w(O);return await v}(F,promise,C);return A.@promise}catch(_){return G=!0,@readableStreamError(j,_),@Promise.@reject(_)}finally{if(!G&&j)@readableStreamClose(j);F=D=x=C=j=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (O,_){\"use strict\";var q=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var z=@getByIdDirectPrivate(O,\"highWaterMark\");q.start(z\?{highWaterMark:z}:{});var v=@newPromiseCapability(@Promise),A=!1,x=_.pull,B=_.close,C={start(){},close(F){if(!A){if(A=!0,B)B();@fulfillPromise(v.@promise,q.end())}},end(){if(!A){if(A=!0,B)B();@fulfillPromise(v.@promise,q.end())}},flush(){return 0},write:q.write.bind(q)},D=!1;try{const F=x(C);if(F&&@isObject(F)&&@isPromise(F))return async function(G,j,w){while(!A)await w(G);return await j}(C,promise,x);return v.@promise}catch(F){return D=!0,@readableStreamError(O,F),@Promise.@reject(F)}finally{if(!D&&O)@readableStreamClose(O);C=B=q=x=O=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1834,7 +1868,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIter const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength = 516; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (h){\"use strict\";var x=globalThis.Symbol.asyncIterator,k=async function*w(z,B){var D=z.getReader(),i;try{while(!0){var F,G;const j=D.readMany();if(@isPromise(j))({done:F,value:G}=await j);else({done:F,value:G}=j);if(F)return;yield*G}}catch(j){i=j}finally{if(D.releaseLock(),!B)z.cancel(i);if(i)throw i}},g=function w(){return k(this,!1)},q=function w({preventCancel:z=!1}={preventCancel:!1}){return k(this,z)};return @Object.@defineProperty(h,x,{value:g}),@Object.@defineProperty(h,\"values\",{value:q}),h})\n"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (k){\"use strict\";var B=globalThis.Symbol.asyncIterator,g=async function*z(D,F){var G=D.getReader(),j;try{while(!0){var x,h;const q=G.readMany();if(@isPromise(q))({done:x,value:h}=await q);else({done:x,value:h}=q);if(x)return;yield*h}}catch(q){j=q}finally{if(G.releaseLock(),!F)D.cancel(j);if(j)throw j}},i=function z(){return g(this,!1)},w=function z({preventCancel:D=!1}={preventCancel:!1}){return g(this,D)};return @Object.@defineProperty(k,B,{value:i}),@Object.@defineProperty(k,\"values\",{value:w}),k})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1986,7 +2020,7 @@ const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorK const JSC::ImplementationVisibility s_readableStreamDefaultReaderReadManyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamDefaultReaderReadManyCodeLength = 2598; static const JSC::Intrinsic s_readableStreamDefaultReaderReadManyCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamDefaultReaderReadManyCode = "(function (){\"use strict\";if(!@isReadableStreamDefaultReader(this))@throwTypeError(\"ReadableStreamDefaultReader.readMany() should not be called directly\");const K=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!K)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const k=@getByIdDirectPrivate(K,\"state\");if(@putByIdDirectPrivate(K,\"disturbed\",!0),k===@streamClosed)return{value:[],size:0,done:!0};else if(k===@streamErrored)throw @getByIdDirectPrivate(K,\"storedError\");var E=@getByIdDirectPrivate(K,\"readableStreamController\"),x=@getByIdDirectPrivate(E,\"queue\");if(!x)return E.@pull(E).@then(function({done:S,value:T}){return S\?{done:!0,value:[],size:0}:{value:[T],size:1,done:!1}});const C=x.content;var _=x.size,A=C.toArray(!1),N=A.length;if(N>0){var D=@newArrayWithSize(N);if(@isReadableByteStreamController(E)){{const S=A[0];if(!(@ArrayBuffer.@isView(S)||S instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(S.buffer,S.byteOffset,S.byteLength));else @putByValDirect(D,0,S)}for(var F=1;F{if(S.done)return{value:[],size:0,done:!0};var T=@getByIdDirectPrivate(K,\"readableStreamController\"),U=@getByIdDirectPrivate(T,\"queue\"),W=[S.value].concat(U.content.toArray(!1)),j=W.length;if(@isReadableByteStreamController(T))for(var G=0;G0){var K=@newArrayWithSize(J);if(@isReadableByteStreamController(F)){{const w=E[0];if(!(@ArrayBuffer.@isView(w)||w instanceof @ArrayBuffer))@putByValDirect(K,0,new @Uint8Array(w.buffer,w.byteOffset,w.byteLength));else @putByValDirect(K,0,w)}for(var d=1;d{if(w.done)return{value:[],size:0,done:!0};var C=@getByIdDirectPrivate(_,\"readableStreamController\"),N=@getByIdDirectPrivate(C,\"queue\"),Q=[w.value].concat(N.content.toArray(!1)),S=Q.length;if(@isReadableByteStreamController(C))for(var T=0;T0}shift(){var{_head:v,_tail:x,_list:k,_capacityMask:w}=this;if(v===x)return @undefined;var A=k[v];if(@putByValDirect(k,v,@undefined),v=this._head=v+1&w,v<2&&x>1e4&&x<=k.length>>>2)this._shrinkArray();return A}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(v){var x=this._tail;if(@putByValDirect(this._list,x,v),this._tail=x+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(v){var x=this._list,k=@toLength(x.length);if(v||this._head>this._tail){var w=@toLength(this._head),A=@toLength(this._tail),B=@toLength(k-w+A),E=@newArrayWithSize(B),g=0;for(var F=w;F>>=1,this._capacityMask>>>=1}}return new z})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var b=@Array.prototype.slice;class k{constructor(){this._head=0,this._tail=0,this._capacityMask=3,this._list=@newArrayWithSize(4)}_head;_tail;_capacityMask;_list;size(){if(this._head===this._tail)return 0;if(this._head0}shift(){var{_head:z,_tail:v,_list:g,_capacityMask:w}=this;if(z===v)return @undefined;var A=g[z];if(@putByValDirect(g,z,@undefined),z=this._head=z+1&w,z<2&&v>1e4&&v<=g.length>>>2)this._shrinkArray();return A}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(z){var v=this._tail;if(@putByValDirect(this._list,v,z),this._tail=v+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(z){var v=this._list,g=@toLength(v.length);if(z||this._head>this._tail){var w=@toLength(this._head),A=@toLength(this._tail),B=@toLength(g-w+A),E=@newArrayWithSize(B),x=0;for(var F=w;F>>=1,this._capacityMask>>>=1}}return new k})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2116,7 +2150,7 @@ const JSC::ConstructorKind s_streamInternalsEnqueueValueWithSizeCodeConstructorK const JSC::ImplementationVisibility s_streamInternalsEnqueueValueWithSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsEnqueueValueWithSizeCodeLength = 161; static const JSC::Intrinsic s_streamInternalsEnqueueValueWithSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsEnqueueValueWithSizeCode = "(function (n,d,o){\"use strict\";if(o=@toNumber(o),!@isFinite(o)||o<0)@throwRangeError(\"size has an incorrect value\");n.content.push({value:d,size:o}),n.size+=o})\n"; +const char* const s_streamInternalsEnqueueValueWithSizeCode = "(function (n,o,d){\"use strict\";if(d=@toNumber(d),!@isFinite(d)||d<0)@throwRangeError(\"size has an incorrect value\");n.content.push({value:o,size:d}),n.size+=d})\n"; // peekQueueValue const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2140,7 +2174,7 @@ const JSC::ConstructorKind s_streamInternalsExtractSizeAlgorithmCodeConstructorK const JSC::ImplementationVisibility s_streamInternalsExtractSizeAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsExtractSizeAlgorithmCodeLength = 176; static const JSC::Intrinsic s_streamInternalsExtractSizeAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsExtractSizeAlgorithmCode = "(function (d){\"use strict\";const w=d.size;if(w===@undefined)return()=>1;if(typeof w!==\"function\")@throwTypeError(\"strategy.size must be a function\");return(p)=>{return w(p)}})\n"; +const char* const s_streamInternalsExtractSizeAlgorithmCode = "(function (d){\"use strict\";const p=d.size;if(p===@undefined)return()=>1;if(typeof p!==\"function\")@throwTypeError(\"strategy.size must be a function\");return(w)=>{return p(w)}})\n"; // extractHighWaterMark const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2172,7 +2206,7 @@ const JSC::ConstructorKind s_streamInternalsToDictionaryCodeConstructorKind = JS const JSC::ImplementationVisibility s_streamInternalsToDictionaryCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsToDictionaryCodeLength = 115; static const JSC::Intrinsic s_streamInternalsToDictionaryCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsToDictionaryCode = "(function (c,n,p){\"use strict\";if(c===@undefined||c===null)return n;if(!@isObject(c))@throwTypeError(p);return c})\n"; +const char* const s_streamInternalsToDictionaryCode = "(function (c,p,n){\"use strict\";if(c===@undefined||c===null)return p;if(!@isObject(c))@throwTypeError(n);return c})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2188,41 +2222,41 @@ WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) const JSC::ConstructAbility s_importMetaObjectLoadCJS2ESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectLoadCJS2ESMCodeLength = 1337; +const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (x){\"use strict\";var I=@Loader,_=@createFIFO(),J=x;while(J){var w=I.registry.@get(J);if(!w||!w.state||w.state<=@ModuleFetch)@fulfillModuleSync(J),w=I.registry.@get(J);var L=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),z=I.parseModule(J,L),Q=w.module;if(!Q&&z&&@isPromise(z)){var T=@getPromiseInternalField(z,@promiseFieldReactionsOrResult),B=@getPromiseInternalField(z,@promiseFieldFlags),U=B&@promiseStateMask;if(U===@promiseStatePending||T&&@isPromise(T))@throwTypeError(`require() async module \"${J}\" is unsupported`);else if(U===@promiseStateRejected){if(!T\?.message)@throwTypeError(`${T+\"\"\?T:\"An error occurred\"} occurred while parsing module \\\"${J}\\\"`);throw T}w.module=Q=T}else if(z&&!Q)w.module=Q=z;@setStateToMax(w,@ModuleLink);var V=Q.dependenciesMap,W=I.requestedModules(Q),X=@newArrayWithSize(W.length);for(var Y=0,Z=W.length;Y=@ModuleLink)J=_.shift()}var H=I.linkAndEvaluateModule(x,@undefined);if(H&&@isPromise(H))@throwTypeError(`require() async module \\\"${x}\\\" is unsupported`);return I.registry.@get(x)})\n"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (_){\"use strict\";var x=@Loader,z=@createFIFO(),w=_;while(w){var G=x.registry.@get(w);if((G\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(w),G=x.registry.@get(w);var D=@getPromiseInternalField(G.fetch,@promiseFieldReactionsOrResult),H=x.parseModule(w,D),I=G.module;if(H&&@isPromise(H)){var J=@getPromiseInternalField(H,@promiseFieldReactionsOrResult),B=@getPromiseInternalField(H,@promiseFieldFlags),F=B&@promiseStateMask;if(F===@promiseStatePending||J&&@isPromise(J))@throwTypeError(`require() async module \"${w}\" is unsupported. use \"await import()\" instead.`);else if(F===@promiseStateRejected){if(!J\?.message)@throwTypeError(`${J+\"\"\?J:\"An error occurred\"} occurred while parsing module \\\"${w}\\\"`);throw J}G.module=I=J}else if(H&&!I)G.module=I=H;@setStateToMax(G,@ModuleLink);var L=I.dependenciesMap,Q=x.requestedModules(I),T=@newArrayWithSize(Q.length);for(var U=0,V=Q.length;U=@ModuleLink)w=z.shift()}var Z=x.linkAndEvaluateModule(_,@undefined);if(Z&&@isPromise(Z))@throwTypeError(`require() async module \\\"${_}\\\" is unsupported. use \"await import()\" instead.`);return x.registry.@get(_)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectRequireESMCodeLength = 419; +const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var f=@Loader.registry.@get(a);if(!f||!f.evaluated)f=@loadCJS2ESM(a);if(!f||!f.evaluated||!f.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var g=@Loader.getModuleNamespaceObject(f.module);if(g[@commonJSSymbol]===0)return;var _=g.default,u=_\?.[@commonJSSymbol];if(u===0)return _;else if(u&&@isCallable(_))return _();return g})\n"; +const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var c=@Loader.registry.@get(a);if(!c||!c.evaluated)c=@loadCJS2ESM(a);if(!c||!c.evaluated||!c.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var _=@Loader.getModuleNamespaceObject(c.module);if(_[@commonJSSymbol]===0)return;return _})\n"; // internalRequire const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectInternalRequireCodeLength = 611; +const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = "(function (n){\"use strict\";var _=@requireMap.@get(n);const q=n.substring(n.length-5);if(_){if(q===\".node\")return _.exports;return _}if(q===\".json\"){var b=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),j=JSON.parse(b.readFileSync(n,\"utf8\"));return @requireMap.@set(n,j),j}else if(q===\".node\"){var i={exports:{}};return process.dlopen(i,n),@requireMap.@set(n,i),i.exports}else if(q===\".toml\"){var b=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),j=@Bun.TOML.parse(b.readFileSync(n,\"utf8\"));return @requireMap.@set(n,j),j}else{var j=@requireESM(n);const g=@requireMap.@get(n);if(g)return g;return @requireMap.@set(n,j),j}})\n"; +const char* const s_importMetaObjectInternalRequireCode = "(function (b){\"use strict\";var g=@requireMap.@get(b);const j=b.substring(b.length-5);if(g)return g.exports;if(j===\".json\"){var k=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=JSON.parse(k.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,q,!0)),q}else if(j===\".node\"){const v=@createCommonJSModule(b,{},!0);return process.dlopen(v,b),@requireMap.@set(b,v),v.exports}else if(j===\".toml\"){var k=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=@Bun.TOML.parse(k.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,q,!0)),q}else{var q=@requireESM(b);const n=@requireMap.@get(b);if(n)return n.exports;var _=q\?.default;if(_\?.[@commonJSSymbol]===0)q=_;return @requireMap.@set(b,@createCommonJSModule(b,q,!0)),q}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectCreateRequireCacheCodeLength = 891; +const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";class _{id;parent;filename;children=[];paths=[];constructor(c){this.id=c;const q=c.lastIndexOf(\"/\");if(q!==-1&&c.length>q+1)this.filename=c.substring(q+1);else this.filename=c}get loaded(){return!0}require(c){return @internalRequire(@resolveSync(c,this.id))}get exports(){return @requireMap.@get(this.id)\?\?{}}set exports(c){@requireMap.@set(this.id,c)}}var P=new Map;return new Proxy({},{get(c,q){if(@requireMap.@get(q)){var r=P.@get(q);if(!r)r=new _(q),P.@set(q,r);return r}},set(c,q,K){if(!P.@has(q))P.@set(q,new _(q));return @requireMap.@set(q,K\?.exports),!0},has(c,q){return @requireMap.@has(q)},deleteProperty(c,q){return P.@delete(q),@requireMap.@delete(q),@Loader.registry.@delete(q),!0},ownKeys(c){return[...@requireMap.@keys()]},getPrototypeOf(c){return null},getOwnPropertyDescriptor(c,q){if(@requireMap.@has(q))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,u={};return new Proxy(u,{get(h,f){const t=@requireMap.@get(f);if(t)return t;const L=@Loader.registry.@get(f);if(L\?.evaluated){const b=@Loader.getModuleNamespaceObject(L.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(f,c,!0);return @requireMap.@set(f,g),g}return u[f]},set(h,f,t){return @requireMap.@set(f,t),!0},has(h,f){return @requireMap.@has(f)||@Loader.registry.@has(f)},deleteProperty(h,f){return _.@delete(f),@requireMap.@delete(f),@Loader.registry.@delete(f),!0},ownKeys(h){var f=[...@requireMap.@keys()];const t=[...@Loader.registry.@keys()];for(let L of t)if(!f.includes(L))@arrayPush(f,L);return f},getPrototypeOf(h){return null},getOwnPropertyDescriptor(h,f){if(@requireMap.@has(f)||@Loader.registry.@has(f))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_importMetaObjectRequireCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_importMetaObjectRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectRequireCodeLength = 172; +const int s_importMetaObjectRequireCodeLength = 173; static const JSC::Intrinsic s_importMetaObjectRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireCode = "(function (l){var i=this\?.path\?\?arguments.callee.path;if(typeof l!==\"string\")@throwTypeError(\"require(name) must be a string\");return @internalRequire(@resolveSync(l,i))})\n"; +const char* const s_importMetaObjectRequireCode = "(function (c){var l=this\?.path\?\?arguments.callee\?.path;if(typeof c!==\"string\")@throwTypeError(\"require(name) must be a string\");return @internalRequire(@resolveSync(c,l))})\n"; // main const JSC::ConstructAbility s_importMetaObjectMainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2446,7 +2480,7 @@ const JSC::ConstructorKind s_readableStreamConsumeReadableStreamCodeConstructorK const JSC::ImplementationVisibility s_readableStreamConsumeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamConsumeReadableStreamCodeLength = 1603; static const JSC::Intrinsic s_readableStreamConsumeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamConsumeReadableStreamCode = "(function (j,k,w){\"use strict\";const B=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var D=globalThis[B];if(!D)D=globalThis[B]=[];var G=D[k];if(G===@undefined){var[H,I,J,K,_,F]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](k);G=class A{handleError;handleClosed;processResult;constructor(L,N){this.#_=N,this.#F=L,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),L.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var L=this.#_;this.#_=0,K(L),F(L)}_handleError(L){if(this.#$)return;this.#$=!0;var N=this.#_;this.#_=0,I(N,L),F(N)}#_;#$=!1;#F;_handleReadMany({value:L,done:N,size:q}){if(N){this.handleClosed();return}if(this.#$)return;J(this.#_,L,N,q)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(L){if(L&&@isPromise(L)){if(@getPromiseInternalField(L,@promiseFieldFlags)&@promiseStateFulfilled){const q=@getPromiseInternalField(L,@promiseFieldReactionsOrResult);if(q)L=q}}if(L&&@isPromise(L))return L.then(this.processResult,this.handleError),null;if(L.done)return this.handleClosed(),0;else if(L.value)return L.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const x=k+1;if(D.length_.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===_),@readableByteStreamControllerInvalidateBYOBRequest(w),_.bytesFilled+=R,_.bytesFilled<_.elementSize)return;@readableByteStreamControllerShiftPendingDescriptor(w);const g=_.bytesFilled%_.elementSize;if(g>0){const h=_.byteOffset+_.bytesFilled,f=@cloneArrayBuffer(_.buffer,h-g,g);@readableByteStreamControllerEnqueueChunk(w,f,0,f.byteLength)}_.buffer=@transferBufferToCurrentRealm(_.buffer),_.bytesFilled-=g,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),_),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (f,w,R){\"use strict\";if(R.bytesFilled+w>R.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(f,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(f,\"pendingPullIntos\").peek()===R),@readableByteStreamControllerInvalidateBYOBRequest(f),R.bytesFilled+=w,R.bytesFilled0){const g=R.byteOffset+R.bytesFilled,h=@cloneArrayBuffer(R.buffer,g-_,_);@readableByteStreamControllerEnqueueChunk(f,h,0,h.byteLength)}R.buffer=@transferBufferToCurrentRealm(R.buffer),R.bytesFilled-=_,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(f,\"controlledReadableStream\"),R),@readableByteStreamControllerProcessPullDescriptors(f)})\n"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2794,7 +2828,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeLength = 502; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode = "(function (a,d){\"use strict\";if(d.buffer=@transferBufferToCurrentRealm(d.buffer),@assert(d.bytesFilled===0),@readableStreamHasBYOBReader(@getByIdDirectPrivate(a,\"controlledReadableStream\")))while(@getByIdDirectPrivate(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"reader\"),\"readIntoRequests\")\?.isNotEmpty()){let _=@readableByteStreamControllerShiftPendingDescriptor(a);@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(a,\"controlledReadableStream\"),_)}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode = "(function (a,_){\"use strict\";if(_.buffer=@transferBufferToCurrentRealm(_.buffer),@assert(_.bytesFilled===0),@readableStreamHasBYOBReader(@getByIdDirectPrivate(a,\"controlledReadableStream\")))while(@getByIdDirectPrivate(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"reader\"),\"readIntoRequests\")\?.isNotEmpty()){let d=@readableByteStreamControllerShiftPendingDescriptor(a);@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(a,\"controlledReadableStream\"),d)}})\n"; // readableByteStreamControllerProcessPullDescriptors const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2810,7 +2844,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength = 970; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode = "(function (_,z){\"use strict\";const q=z.bytesFilled-z.bytesFilled%z.elementSize,j=@getByIdDirectPrivate(_,\"queue\").sizeq)E=w-z.bytesFilled,G=!0;while(E>0){let H=@getByIdDirectPrivate(_,\"queue\").content.peek();const k=E0),@assert(z.bytesFilled_)k=E-w.bytesFilled,G=!0;while(k>0){let H=@getByIdDirectPrivate(j,\"queue\").content.peek();const v=k0),@assert(w.bytesFilled0){if(@readableByteStreamControllerFillDescriptorFromQueue(_,E)){const R=@readableByteStreamControllerConvertDescriptor(E);return @readableByteStreamControllerHandleQueueDrain(_),@createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(_,\"closeRequested\")){const R=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(_,R),@Promise.@reject(R)}}E.buffer=@transferBufferToCurrentRealm(E.buffer),@getByIdDirectPrivate(_,\"pendingPullIntos\").push(E);const N=@readableStreamAddReadIntoRequest(d);return @readableByteStreamControllerCallPullIfNeeded(_),N})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (_,k){\"use strict\";const L=@getByIdDirectPrivate(_,\"controlledReadableStream\");let d=1;if(k.BYTES_PER_ELEMENT!==@undefined)d=k.BYTES_PER_ELEMENT;const N=k.constructor,A={buffer:k.buffer,byteOffset:k.byteOffset,byteLength:k.byteLength,bytesFilled:0,elementSize:d,ctor:N,readerType:\"byob\"};var R=@getByIdDirectPrivate(_,\"pendingPullIntos\");if(R\?.isNotEmpty())return A.buffer=@transferBufferToCurrentRealm(A.buffer),R.push(A),@readableStreamAddReadIntoRequest(L);if(@getByIdDirectPrivate(L,\"state\")===@streamClosed){const b=new N(A.buffer,A.byteOffset,0);return @createFulfilledPromise({value:b,done:!0})}if(@getByIdDirectPrivate(_,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(_,A)){const b=@readableByteStreamControllerConvertDescriptor(A);return @readableByteStreamControllerHandleQueueDrain(_),@createFulfilledPromise({value:b,done:!1})}if(@getByIdDirectPrivate(_,\"closeRequested\")){const b=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(_,b),@Promise.@reject(b)}}A.buffer=@transferBufferToCurrentRealm(A.buffer),@getByIdDirectPrivate(_,\"pendingPullIntos\").push(A);const E=@readableStreamAddReadIntoRequest(L);return @readableByteStreamControllerCallPullIfNeeded(_),E})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2918,7 +2952,7 @@ const JSC::ConstructorKind s_eventSourceGetEventSourceCodeConstructorKind = JSC: const JSC::ImplementationVisibility s_eventSourceGetEventSourceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_eventSourceGetEventSourceCodeLength = 5477; static const JSC::Intrinsic s_eventSourceGetEventSourceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class j extends EventTarget{#K;#w;#G;#A;#B;#L=!1;#M=null;#O=\"\";#$=\"\";#F=\"\";#J=!0;#Q=0;#U=0;#V=0;#W=null;static#X(V){V.#H()}static#j(V,w){const W=V.data,A=W.#F\?`Last-Event-ID: ${W.#F}\\r\\n`:\"\",X=`GET ${w.pathname}${w.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${A}\\r\\n`,B=V.write(X);if(B!==X.length)W.#$=X.substring(B)}static#Y(V,w,W){for(;;){if(W>=w.length)return;let A=-1,X=w.indexOf(\"\\r\\n\",W);const B=X+2;if(X>0)if(V.#Q===0){const Z=parseInt(w.substring(W,X),16);if(Z===0){V.#w=2,V.#M\?.end();return}A=B+Z}else A=w.length;else{if(V.#O.length===0){V.#O+=w.substring(W);return}A=w.length}let Y=w.substring(B,A);W=A+2;let F=0,G=Y.indexOf(\"\\n\\n\");if(G==-1){V.#O+=w.substring(B);return}if(V.#O.length)V.#O+=Y,Y=V.#O,V.#O=\"\";let J=!0;while(J){const Z=Y.substring(F,G);let K,z=\"\",L,H=0,M=-1;for(;;){let O=Z.indexOf(\"\\n\",H);if(O===-1){if(H>=Z.length)break;O=Z.length}const U=Z.substring(H,O);if(U.startsWith(\"data:\"))if(z.length)z+=`\\n${U.substring(5).trim()}`;else z=U.substring(5).trim();else if(U.startsWith(\"event:\"))K=U.substring(6).trim();else if(U.startsWith(\"id:\"))L=U.substring(3).trim();else if(U.startsWith(\"retry:\")){if(M=parseInt(U.substring(6).trim(),10),@isNaN(M))M=-1}H=O+1}if(V.#F=L||\"\",M>=0)V.#V=M;if(z||L||K)V.dispatchEvent(new MessageEvent(K||\"message\",{data:z||\"\",origin:V.#K.origin,source:V,lastEventId:L}));if(Y.length===G+2){J=!1;break}const Q=Y.indexOf(\"\\n\\n\",G+1);if(Q===-1)break;F=G,G=Q}}}static#Z={open(V){const w=V.data;if(w.#M=V,!w.#L)j.#j(V,w.#K)},handshake(V,w,W){const A=V.data;if(w)j.#j(V,A.#K);else A.#w=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:W})),V.end()},data(V,w){const W=V.data;switch(W.#w){case 0:{let A=w.toString();const X=A.indexOf(\"\\r\\n\\r\\n\");if(X===-1){W.#O+=A;return}if(W.#O.length)W.#O+=A,A=W.#O,W.#O=\"\";const B=A.substring(0,X),Y=B.indexOf(\"\\r\\n\");if(Y===-1){W.#w=2,W.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),V.end();return}const F=B.substring(0,Y);if(F!==\"HTTP/1.1 200 OK\"){W.#w=2,W.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(F)})),V.end();return}let G=Y+1,J=!1,Z=-1;for(;;){let z=B.indexOf(\"\\r\\n\",G);if(z===-1){if(G>=B.length){if(!J)W.#w=2,W.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),V.end();return}z=B.length}const L=B.substring(G+1,z),H=L.indexOf(\":\"),M=L.substring(0,H),Q=M.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(G=z+1,Q)if(L.endsWith(\" text/event-stream\"))J=!0;else{W.#w=2,W.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),V.end();return}else if(M.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(Z=parseInt(L.substring(H+1).trim(),10),@isNaN(Z)||Z<=0){W.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),V.end();return}if(J)break}else if(M.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(L.substring(H+1).trim()!==\"chunked\"){W.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),V.end();return}if(Z=0,J)break}}W.#Q=Z,W.#w=1,W.dispatchEvent(new Event(\"open\"));const K=A.substring(X+4);if(j.#Y(W,K,0),W.#Q>0){if(W.#U+=K.length,W.#U>=W.#Q)W.#w=2,V.end()}return}case 1:if(j.#Y(W,w.toString(),2),W.#Q>0){if(W.#U+=w.byteLength,W.#U>=W.#Q)W.#w=2,V.end()}return;default:break}},drain(V){const w=V.data;if(w.#w===0){const W=w.#O;if(W.length){const A=V.write(W);if(A!==W.length)V.data.#$=W.substring(A);else V.data.#$=\"\"}}},close:j.#z,end(V){j.#z(V).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(V){j.#z(V).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(V){const w=V.data;if(w.#M=null,w.#U=0,w.#w=2,w.#J){if(w.#W)clearTimeout(w.#W);w.#W=setTimeout(j.#X,w.#V,w)}return w}constructor(V,w=@undefined){super();const W=new URL(V);this.#L=W.protocol===\"https:\",this.#K=W,this.#w=2,process.nextTick(j.#X,this)}ref(){this.#W\?.ref(),this.#M\?.ref()}unref(){this.#W\?.unref(),this.#M\?.unref()}#H(){if(this.#w!==2)return;const V=this.#K,w=this.#L;this.#w=0,@Bun.connect({data:this,socket:j.#Z,hostname:V.hostname,port:parseInt(V.port||(w\?\"443\":\"80\"),10),tls:w\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((W)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:W})),this.#J){if(this.#W)this.#W.unref\?.();this.#W=setTimeout(j.#X,1000,this)}})}get url(){return this.#K.href}get readyState(){return this.#w}close(){this.#J=!1,this.#w=2,this.#M\?.unref(),this.#M\?.end()}get onopen(){return this.#B}get onerror(){return this.#G}get onmessage(){return this.#A}set onopen(V){if(this.#B)super.removeEventListener(\"close\",this.#B);super.addEventListener(\"open\",V),this.#B=V}set onerror(V){if(this.#G)super.removeEventListener(\"error\",this.#G);super.addEventListener(\"error\",V),this.#G=V}set onmessage(V){if(this.#A)super.removeEventListener(\"message\",this.#A);super.addEventListener(\"message\",V),this.#A=V}}return Object.defineProperty(j.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(j.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(j.prototype,\"CLOSED\",{enumerable:!0,value:2}),j[Symbol.for(\"CommonJS\")]=0,j})\n"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class j extends EventTarget{#$;#j;#w;#A;#B;#F=!1;#G=null;#J=\"\";#K=\"\";#L=\"\";#M=!0;#O=0;#Q=0;#U=0;#V=null;static#W(w){w.#H()}static#X(w,A){const B=w.data,F=B.#L\?`Last-Event-ID: ${B.#L}\\r\\n`:\"\",G=`GET ${A.pathname}${A.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${F}\\r\\n`,J=w.write(G);if(J!==G.length)B.#K=G.substring(J)}static#Y(w,A,B){for(;;){if(B>=A.length)return;let F=-1,G=A.indexOf(\"\\r\\n\",B);const J=G+2;if(G>0)if(w.#O===0){const Q=parseInt(A.substring(B,G),16);if(Q===0){w.#j=2,w.#G\?.end();return}F=J+Q}else F=A.length;else{if(w.#J.length===0){w.#J+=A.substring(B);return}F=A.length}let K=A.substring(J,F);B=F+2;let L=0,M=K.indexOf(\"\\n\\n\");if(M==-1){w.#J+=A.substring(J);return}if(w.#J.length)w.#J+=K,K=w.#J,w.#J=\"\";let O=!0;while(O){const Q=K.substring(L,M);let U,V=\"\",W,X=0,Y=-1;for(;;){let z=Q.indexOf(\"\\n\",X);if(z===-1){if(X>=Q.length)break;z=Q.length}const H=Q.substring(X,z);if(H.startsWith(\"data:\"))if(V.length)V+=`\\n${H.substring(5).trim()}`;else V=H.substring(5).trim();else if(H.startsWith(\"event:\"))U=H.substring(6).trim();else if(H.startsWith(\"id:\"))W=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(Y=parseInt(H.substring(6).trim(),10),@isNaN(Y))Y=-1}X=z+1}if(w.#L=W||\"\",Y>=0)w.#U=Y;if(V||W||U)w.dispatchEvent(new MessageEvent(U||\"message\",{data:V||\"\",origin:w.#$.origin,source:w,lastEventId:W}));if(K.length===M+2){O=!1;break}const Z=K.indexOf(\"\\n\\n\",M+1);if(Z===-1)break;L=M,M=Z}}}static#Z={open(w){const A=w.data;if(A.#G=w,!A.#F)j.#X(w,A.#$)},handshake(w,A,B){const F=w.data;if(A)j.#X(w,F.#$);else F.#j=2,F.dispatchEvent(new ErrorEvent(\"error\",{error:B})),w.end()},data(w,A){const B=w.data;switch(B.#j){case 0:{let F=A.toString();const G=F.indexOf(\"\\r\\n\\r\\n\");if(G===-1){B.#J+=F;return}if(B.#J.length)B.#J+=F,F=B.#J,B.#J=\"\";const J=F.substring(0,G),K=J.indexOf(\"\\r\\n\");if(K===-1){B.#j=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),w.end();return}const L=J.substring(0,K);if(L!==\"HTTP/1.1 200 OK\"){B.#j=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(L)})),w.end();return}let M=K+1,O=!1,Q=-1;for(;;){let V=J.indexOf(\"\\r\\n\",M);if(V===-1){if(M>=J.length){if(!O)B.#j=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),w.end();return}V=J.length}const W=J.substring(M+1,V),X=W.indexOf(\":\"),Y=W.substring(0,X),Z=Y.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(M=V+1,Z)if(W.endsWith(\" text/event-stream\"))O=!0;else{B.#j=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),w.end();return}else if(Y.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(Q=parseInt(W.substring(X+1).trim(),10),@isNaN(Q)||Q<=0){B.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),w.end();return}if(O)break}else if(Y.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(W.substring(X+1).trim()!==\"chunked\"){B.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),w.end();return}if(Q=0,O)break}}B.#O=Q,B.#j=1,B.dispatchEvent(new Event(\"open\"));const U=F.substring(G+4);if(j.#Y(B,U,0),B.#O>0){if(B.#Q+=U.length,B.#Q>=B.#O)B.#j=2,w.end()}return}case 1:if(j.#Y(B,A.toString(),2),B.#O>0){if(B.#Q+=A.byteLength,B.#Q>=B.#O)B.#j=2,w.end()}return;default:break}},drain(w){const A=w.data;if(A.#j===0){const B=A.#J;if(B.length){const F=w.write(B);if(F!==B.length)w.data.#K=B.substring(F);else w.data.#K=\"\"}}},close:j.#z,end(w){j.#z(w).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(w){j.#z(w).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(w){const A=w.data;if(A.#G=null,A.#Q=0,A.#j=2,A.#M){if(A.#V)clearTimeout(A.#V);A.#V=setTimeout(j.#W,A.#U,A)}return A}constructor(w,A=@undefined){super();const B=new URL(w);this.#F=B.protocol===\"https:\",this.#$=B,this.#j=2,process.nextTick(j.#W,this)}ref(){this.#V\?.ref(),this.#G\?.ref()}unref(){this.#V\?.unref(),this.#G\?.unref()}#H(){if(this.#j!==2)return;const w=this.#$,A=this.#F;this.#j=0,@Bun.connect({data:this,socket:j.#Z,hostname:w.hostname,port:parseInt(w.port||(A\?\"443\":\"80\"),10),tls:A\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((B)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:B})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(j.#W,1000,this)}})}get url(){return this.#$.href}get readyState(){return this.#j}close(){this.#M=!1,this.#j=2,this.#G\?.unref(),this.#G\?.end()}get onopen(){return this.#B}get onerror(){return this.#w}get onmessage(){return this.#A}set onopen(w){if(this.#B)super.removeEventListener(\"close\",this.#B);super.addEventListener(\"open\",w),this.#B=w}set onerror(w){if(this.#w)super.removeEventListener(\"error\",this.#w);super.addEventListener(\"error\",w),this.#w=w}set onmessage(w){if(this.#A)super.removeEventListener(\"message\",this.#A);super.addEventListener(\"message\",w),this.#A=w}}return Object.defineProperty(j.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(j.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(j.prototype,\"CLOSED\",{enumerable:!0,value:2}),j[Symbol.for(\"CommonJS\")]=0,j})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/src/js/out/WebCoreJSBuiltins.h b/src/js/out/WebCoreJSBuiltins.h index e79dc1922..d17918af2 100644 --- a/src/js/out/WebCoreJSBuiltins.h +++ b/src/js/out/WebCoreJSBuiltins.h @@ -1354,6 +1354,106 @@ inline void TransformStreamBuiltinsWrapper::exportNames() WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) #undef EXPORT_FUNCTION_NAME } +/* Module.ts */ +// main +#define WEBCORE_BUILTIN_MODULE_MAIN 1 +extern const char* const s_moduleMainCode; +extern const int s_moduleMainCodeLength; +extern const JSC::ConstructAbility s_moduleMainCodeConstructAbility; +extern const JSC::ConstructorKind s_moduleMainCodeConstructorKind; +extern const JSC::ImplementationVisibility s_moduleMainCodeImplementationVisibility; + +// require +#define WEBCORE_BUILTIN_MODULE_REQUIRE 1 +extern const char* const s_moduleRequireCode; +extern const int s_moduleRequireCodeLength; +extern const JSC::ConstructAbility s_moduleRequireCodeConstructAbility; +extern const JSC::ConstructorKind s_moduleRequireCodeConstructorKind; +extern const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility; + +// requireResolve +#define WEBCORE_BUILTIN_MODULE_REQUIRERESOLVE 1 +extern const char* const s_moduleRequireResolveCode; +extern const int s_moduleRequireResolveCodeLength; +extern const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility; +extern const JSC::ConstructorKind s_moduleRequireResolveCodeConstructorKind; +extern const JSC::ImplementationVisibility s_moduleRequireResolveCodeImplementationVisibility; + +#define WEBCORE_FOREACH_MODULE_BUILTIN_DATA(macro) \ + macro(main, moduleMain, 0) \ + macro(require, moduleRequire, 1) \ + macro(requireResolve, moduleRequireResolve, 1) \ + +#define WEBCORE_FOREACH_MODULE_BUILTIN_CODE(macro) \ + macro(moduleMainCode, main, "get main"_s, s_moduleMainCodeLength) \ + macro(moduleRequireCode, require, ASCIILiteral(), s_moduleRequireCodeLength) \ + macro(moduleRequireResolveCode, requireResolve, ASCIILiteral(), s_moduleRequireResolveCodeLength) \ + +#define WEBCORE_FOREACH_MODULE_BUILTIN_FUNCTION_NAME(macro) \ + macro(main) \ + macro(require) \ + macro(requireResolve) \ + +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_MODULE_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class ModuleBuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit ModuleBuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_MODULE_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES) +#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { })) + WEBCORE_FOREACH_MODULE_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS) +#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS + { + } + +#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ + JSC::UnlinkedFunctionExecutable* name##Executable(); \ + const JSC::SourceCode& name##Source() const { return m_##name##Source; } + WEBCORE_FOREACH_MODULE_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_MODULE_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_MODULE_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES) + +#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \ + JSC::SourceCode m_##name##Source;\ + JSC::Weak m_##name##Executable; + WEBCORE_FOREACH_MODULE_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ +inline JSC::UnlinkedFunctionExecutable* ModuleBuiltinsWrapper::name##Executable() \ +{\ + if (!m_##name##Executable) {\ + JSC::Identifier executableName = functionName##PublicName();\ + if (overriddenName)\ + executableName = JSC::Identifier::fromString(m_vm, overriddenName);\ + m_##name##Executable = JSC::Weak(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ + }\ + return m_##name##Executable.get();\ +} +WEBCORE_FOREACH_MODULE_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void ModuleBuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_MODULE_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} /* JSBufferPrototype.ts */ // setBigUint64 #define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_SETBIGUINT64 1 @@ -5488,6 +5588,7 @@ public: , m_transformStreamInternalsBuiltins(m_vm) , m_processObjectInternalsBuiltins(m_vm) , m_transformStreamBuiltins(m_vm) + , m_moduleBuiltins(m_vm) , m_jsBufferPrototypeBuiltins(m_vm) , m_readableByteStreamControllerBuiltins(m_vm) , m_consoleObjectBuiltins(m_vm) @@ -5520,6 +5621,7 @@ public: TransformStreamInternalsBuiltinsWrapper& transformStreamInternalsBuiltins() { return m_transformStreamInternalsBuiltins; } ProcessObjectInternalsBuiltinsWrapper& processObjectInternalsBuiltins() { return m_processObjectInternalsBuiltins; } TransformStreamBuiltinsWrapper& transformStreamBuiltins() { return m_transformStreamBuiltins; } + ModuleBuiltinsWrapper& moduleBuiltins() { return m_moduleBuiltins; } JSBufferPrototypeBuiltinsWrapper& jsBufferPrototypeBuiltins() { return m_jsBufferPrototypeBuiltins; } ReadableByteStreamControllerBuiltinsWrapper& readableByteStreamControllerBuiltins() { return m_readableByteStreamControllerBuiltins; } ConsoleObjectBuiltinsWrapper& consoleObjectBuiltins() { return m_consoleObjectBuiltins; } @@ -5547,6 +5649,7 @@ private: TransformStreamInternalsBuiltinsWrapper m_transformStreamInternalsBuiltins; ProcessObjectInternalsBuiltinsWrapper m_processObjectInternalsBuiltins; TransformStreamBuiltinsWrapper m_transformStreamBuiltins; + ModuleBuiltinsWrapper m_moduleBuiltins; JSBufferPrototypeBuiltinsWrapper m_jsBufferPrototypeBuiltins; ReadableByteStreamControllerBuiltinsWrapper m_readableByteStreamControllerBuiltins; ConsoleObjectBuiltinsWrapper m_consoleObjectBuiltins; diff --git a/src/js/out/modules/node/assert.js b/src/js/out/modules/node/assert.js index 172a95445..4086ef8d5 100644 --- a/src/js/out/modules/node/assert.js +++ b/src/js/out/modules/node/assert.js @@ -1,53 +1,53 @@ -var V0=function(){throw new Error("CallTracker is not supported yet")},{Bun:$0}=import.meta.primordials,X0=$0.deepEquals;var U0=(H,Q)=>function(){return Q||(0,H[Object.keys(H)[0]])((Q={exports:{}}).exports,Q),Q.exports};var K0=(H)=>import.meta.require(H),W0=U0({"assert/build/internal/errors.js"(H,Q){function Z(v){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Z=function(T){return typeof T}:Z=function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T},Z(v)}function J(v,T){if(!(v instanceof T))throw new TypeError("Cannot call a class as a function")}function z(v,T){return T&&(Z(T)==="object"||typeof T=="function")?T:X(v)}function X(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function K(v){return K=Object.setPrototypeOf?Object.getPrototypeOf:function(T){return T.__proto__||Object.getPrototypeOf(T)},K(v)}function Y(v,T){if(typeof T!="function"&&T!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(T&&T.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),T&&$(v,T)}function $(v,T){return $=Object.setPrototypeOf||function(w,F){return w.__proto__=F,w},$(v,T)}var U={},W,B;function D(v,T,w){w||(w=Error);function F(N,A,I){return typeof T=="string"?T:T(N,A,I)}var O=function(N){Y(A,N);function A(I,P,S){var j;return J(this,A),j=z(this,K(A).call(this,F(I,P,S))),j.code=v,j}return A}(w);U[v]=O}function V(v,T){if(Array.isArray(v)){var w=v.length;return v=v.map(function(F){return String(F)}),w>2?"one of ".concat(T," ").concat(v.slice(0,w-1).join(", "),", or ")+v[w-1]:w===2?"one of ".concat(T," ").concat(v[0]," or ").concat(v[1]):"of ".concat(T," ").concat(v[0])}else return"of ".concat(T," ").concat(String(v))}function M(v,T,w){return v.substr(!w||w<0?0:+w,T.length)===T}function G(v,T,w){return(w===void 0||w>v.length)&&(w=v.length),v.substring(w-T.length,w)===T}function q(v,T,w){return typeof w!="number"&&(w=0),w+T.length>v.length?!1:v.indexOf(T,w)!==-1}D("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),D("ERR_INVALID_ARG_TYPE",function(v,T,w){W===void 0&&(W=Y0()),W(typeof v=="string","'name' must be a string");var F;typeof T=="string"&&M(T,"not ")?(F="must not be",T=T.replace(/^not /,"")):F="must be";var O;if(G(v," argument"))O="The ".concat(v," ").concat(F," ").concat(V(T,"type"));else{var N=q(v,".")?"property":"argument";O='The "'.concat(v,'" ').concat(N," ").concat(F," ").concat(V(T,"type"))}return O+=". Received type ".concat(Z(w)),O},TypeError),D("ERR_INVALID_ARG_VALUE",function(v,T){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";B===void 0&&(B=K0("util"));var F=B.inspect(T);return F.length>128&&(F="".concat(F.slice(0,128),"...")),"The argument '".concat(v,"' ").concat(w,". Received ").concat(F)},TypeError,RangeError),D("ERR_INVALID_RETURN_VALUE",function(v,T,w){var F;return w&&w.constructor&&w.constructor.name?F="instance of ".concat(w.constructor.name):F="type ".concat(Z(w)),"Expected ".concat(v,' to be returned from the "').concat(T,'"')+" function but got ".concat(F,".")},TypeError),D("ERR_MISSING_ARGS",function(){for(var v=arguments.length,T=new Array(v),w=0;w0,"At least one arg needs to be specified");var F="The ",O=T.length;switch(T=T.map(function(N){return'"'.concat(N,'"')}),O){case 1:F+="".concat(T[0]," argument");break;case 2:F+="".concat(T[0]," and ").concat(T[1]," arguments");break;default:F+=T.slice(0,O-1).join(", "),F+=", and ".concat(T[O-1]," arguments");break}return"".concat(F," must be specified")},TypeError),Q.exports.codes=U}}),B0=U0({"assert/build/internal/assert/assertion_error.js"(H,Q){function Z(b){for(var h=1;hb.length)&&(k=b.length),b.substring(k-h.length,k)===h}function N(b,h){if(h=Math.floor(h),b.length==0||h==0)return"";var k=b.length*h;for(h=Math.floor(Math.log(h)/Math.log(2));h;)b+=b,h--;return b+=b.substring(0,k-b.length),b}var A="",I="",P="",S="",j={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},R=10;function f(b){var h=Object.keys(b),k=Object.create(Object.getPrototypeOf(b));return h.forEach(function(x){k[x]=b[x]}),Object.defineProperty(k,"message",{value:b.message}),k}function C(b){return T(b,{compact:!1,customInspect:!1,depth:1000,maxArrayLength:Infinity,showHidden:!1,breakLength:Infinity,showProxy:!1,sorted:!0,getters:!0})}function E(b,h,k){var x="",y="",m=0,g="",d=!1,_=C(b),u=_.split(` -`),i=C(h).split(` -`),p=0,n="";if(k==="strictEqual"&&q(b)==="object"&&q(h)==="object"&&b!==null&&h!==null&&(k="strictEqualObject"),u.length===1&&i.length===1&&u[0]!==i[0]){var l=u[0].length+i[0].length;if(l<=R){if((q(b)!=="object"||b===null)&&(q(h)!=="object"||h===null)&&(b!==0||h!==0))return"".concat(j[k],` +import X1 from"node:util";var D1=function(){throw new Error("CallTracker is not supported yet")},{Bun:$1}=globalThis[Symbol.for("Bun.lazy")]("primordials"),z1=$1.deepEquals,W1=(H,Q)=>function(){return Q||(0,H[Object.keys(H)[0]])((Q={exports:{}}).exports,Q),Q.exports},Y1=W1({"assert/build/internal/errors.js"(H,Q){function Z(G){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Z=function(T){return typeof T}:Z=function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T},Z(G)}function J(G,T){if(!(G instanceof T))throw new TypeError("Cannot call a class as a function")}function z(G,T){return T&&(Z(T)==="object"||typeof T=="function")?T:X(G)}function X(G){if(G===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return G}function U(G){return U=Object.setPrototypeOf?Object.getPrototypeOf:function(T){return T.__proto__||Object.getPrototypeOf(T)},U(G)}function $(G,T){if(typeof T!="function"&&T!==null)throw new TypeError("Super expression must either be null or a function");G.prototype=Object.create(T&&T.prototype,{constructor:{value:G,writable:!0,configurable:!0}}),T&&K(G,T)}function K(G,T){return K=Object.setPrototypeOf||function(w,O){return w.__proto__=O,w},K(G,T)}var W={},Y,B;function V(G,T,w){w||(w=Error);function O(N,I,P){return typeof T=="string"?T:T(N,I,P)}var F=function(N){$(I,N);function I(P,A,S){var j;return J(this,I),j=z(this,U(I).call(this,O(P,A,S))),j.code=G,j}return I}(w);W[G]=F}function D(G,T){if(Array.isArray(G)){var w=G.length;return G=G.map(function(O){return String(O)}),w>2?"one of ".concat(T," ").concat(G.slice(0,w-1).join(", "),", or ")+G[w-1]:w===2?"one of ".concat(T," ").concat(G[0]," or ").concat(G[1]):"of ".concat(T," ").concat(G[0])}else return"of ".concat(T," ").concat(String(G))}function M(G,T,w){return G.substr(!w||w<0?0:+w,T.length)===T}function q(G,T,w){return(w===void 0||w>G.length)&&(w=G.length),G.substring(w-T.length,w)===T}function v(G,T,w){return typeof w!="number"&&(w=0),w+T.length>G.length?!1:G.indexOf(T,w)!==-1}V("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),V("ERR_INVALID_ARG_TYPE",function(G,T,w){Y===void 0&&(Y=U1()),Y(typeof G=="string","'name' must be a string");var O;typeof T=="string"&&M(T,"not ")?(O="must not be",T=T.replace(/^not /,"")):O="must be";var F;if(q(G," argument"))F="The ".concat(G," ").concat(O," ").concat(D(T,"type"));else{var N=v(G,".")?"property":"argument";F='The "'.concat(G,'" ').concat(N," ").concat(O," ").concat(D(T,"type"))}return F+=". Received type ".concat(Z(w)),F},TypeError),V("ERR_INVALID_ARG_VALUE",function(G,T){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid",O=B.inspect(T);return O.length>128&&(O="".concat(O.slice(0,128),"...")),"The argument '".concat(G,"' ").concat(w,". Received ").concat(O)},TypeError,RangeError),V("ERR_INVALID_RETURN_VALUE",function(G,T,w){var O;return w&&w.constructor&&w.constructor.name?O="instance of ".concat(w.constructor.name):O="type ".concat(Z(w)),"Expected ".concat(G,' to be returned from the "').concat(T,'"')+" function but got ".concat(O,".")},TypeError),V("ERR_MISSING_ARGS",function(){for(var G=arguments.length,T=new Array(G),w=0;w0,"At least one arg needs to be specified");var O="The ",F=T.length;switch(T=T.map(function(N){return'"'.concat(N,'"')}),F){case 1:O+="".concat(T[0]," argument");break;case 2:O+="".concat(T[0]," and ").concat(T[1]," arguments");break;default:O+=T.slice(0,F-1).join(", "),O+=", and ".concat(T[F-1]," arguments");break}return"".concat(O," must be specified")},TypeError),Q.exports.codes=W}}),B1=W1({"assert/build/internal/assert/assertion_error.js"(H,Q){function Z(L){for(var b=1;bL.length)&&(h=L.length),L.substring(h-b.length,h)===b}function F(L,b){if(b=Math.floor(b),L.length==0||b==0)return"";var h=L.length*b;for(b=Math.floor(Math.log(b)/Math.log(2));b;)L+=L,b--;return L+=L.substring(0,h-L.length),L}var N="",I="",P="",A="",S={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},j=10;function R(L){var b=Object.keys(L),h=Object.create(Object.getPrototypeOf(L));return b.forEach(function(k){h[k]=L[k]}),Object.defineProperty(h,"message",{value:L.message}),h}function f(L){return G(L,{compact:!1,customInspect:!1,depth:1000,maxArrayLength:Infinity,showHidden:!1,breakLength:Infinity,showProxy:!1,sorted:!0,getters:!0})}function C(L,b,h){var k="",m="",x=0,y="",g=!1,d=f(L),_=d.split(` +`),u=f(b).split(` +`),n=0,i="";if(h==="strictEqual"&&v(L)==="object"&&v(b)==="object"&&L!==null&&b!==null&&(h="strictEqualObject"),_.length===1&&u.length===1&&_[0]!==u[0]){var p=_[0].length+u[0].length;if(p<=j){if((v(L)!=="object"||L===null)&&(v(b)!=="object"||b===null)&&(L!==0||b!==0))return"".concat(S[h],` -`)+"".concat(u[0]," !== ").concat(i[0],` -`)}else if(k!=="strictEqualObject"){var c=process.stderr&&process.stderr.isTTY?process.stderr.columns:80;if(l2&&(n=` - `.concat(N(" ",p),"^"),p=0)}}}for(var o=u[u.length-1],a=i[i.length-1];o===a&&(p++<2?g=` - `.concat(o).concat(g):x=o,u.pop(),i.pop(),!(u.length===0||i.length===0));)o=u[u.length-1],a=i[i.length-1];var t=Math.max(u.length,i.length);if(t===0){var s=_.split(` -`);if(s.length>30)for(s[26]="".concat(A,"...").concat(S);s.length>27;)s.pop();return"".concat(j.notIdentical,` +`)+"".concat(_[0]," !== ").concat(u[0],` +`)}else if(h!=="strictEqualObject"){var l=process.stderr&&process.stderr.isTTY?process.stderr.columns:80;if(p2&&(i=` + `.concat(F(" ",n),"^"),n=0)}}}for(var c=_[_.length-1],o=u[u.length-1];c===o&&(n++<2?y=` + `.concat(c).concat(y):k=c,_.pop(),u.pop(),!(_.length===0||u.length===0));)c=_[_.length-1],o=u[u.length-1];var a=Math.max(_.length,u.length);if(a===0){var t=d.split(` +`);if(t.length>30)for(t[26]="".concat(N,"...").concat(A);t.length>27;)t.pop();return"".concat(S.notIdentical,` -`).concat(s.join(` +`).concat(t.join(` `),` -`)}p>3&&(g=` -`.concat(A,"...").concat(S).concat(g),d=!0),x!==""&&(g=` - `.concat(x).concat(g),x="");var r=0,e=j[k]+` -`.concat(I,"+ actual").concat(S," ").concat(P,"- expected").concat(S),H0=" ".concat(A,"...").concat(S," Lines skipped");for(p=0;p1&&p>2&&(Q0>4?(y+=` -`.concat(A,"...").concat(S),d=!0):Q0>3&&(y+=` - `.concat(i[p-2]),r++),y+=` - `.concat(i[p-1]),r++),m=p,x+=` -`.concat(P,"-").concat(S," ").concat(i[p]),r++;else if(i.length1&&p>2&&(Q0>4?(y+=` -`.concat(A,"...").concat(S),d=!0):Q0>3&&(y+=` - `.concat(u[p-2]),r++),y+=` - `.concat(u[p-1]),r++),m=p,y+=` -`.concat(I,"+").concat(S," ").concat(u[p]),r++;else{var Z0=i[p],J0=u[p],z0=J0!==Z0&&(!O(J0,",")||J0.slice(0,-1)!==Z0);z0&&O(Z0,",")&&Z0.slice(0,-1)===J0&&(z0=!1,J0+=","),z0?(Q0>1&&p>2&&(Q0>4?(y+=` -`.concat(A,"...").concat(S),d=!0):Q0>3&&(y+=` - `.concat(u[p-2]),r++),y+=` - `.concat(u[p-1]),r++),m=p,y+=` -`.concat(I,"+").concat(S," ").concat(J0),x+=` -`.concat(P,"-").concat(S," ").concat(Z0),r+=2):(y+=x,x="",(Q0===1||p===0)&&(y+=` - `.concat(J0),r++))}if(r>20&&p30)for(p[26]="".concat(A,"...").concat(S);p.length>27;)p.pop();p.length===1?x=Y(this,G(h).call(this,"".concat(i," ").concat(p[0]))):x=Y(this,G(h).call(this,"".concat(i,` +`)}n>3&&(y=` +`.concat(N,"...").concat(A).concat(y),g=!0),k!==""&&(y=` + `.concat(k).concat(y),k="");var r=0,s=S[h]+` +`.concat(I,"+ actual").concat(A," ").concat(P,"- expected").concat(A),e=" ".concat(N,"...").concat(A," Lines skipped");for(n=0;n1&&n>2&&(H1>4?(m+=` +`.concat(N,"...").concat(A),g=!0):H1>3&&(m+=` + `.concat(u[n-2]),r++),m+=` + `.concat(u[n-1]),r++),x=n,k+=` +`.concat(P,"-").concat(A," ").concat(u[n]),r++;else if(u.length1&&n>2&&(H1>4?(m+=` +`.concat(N,"...").concat(A),g=!0):H1>3&&(m+=` + `.concat(_[n-2]),r++),m+=` + `.concat(_[n-1]),r++),x=n,m+=` +`.concat(I,"+").concat(A," ").concat(_[n]),r++;else{var Q1=u[n],Z1=_[n],J1=Z1!==Q1&&(!O(Z1,",")||Z1.slice(0,-1)!==Q1);J1&&O(Q1,",")&&Q1.slice(0,-1)===Z1&&(J1=!1,Z1+=","),J1?(H1>1&&n>2&&(H1>4?(m+=` +`.concat(N,"...").concat(A),g=!0):H1>3&&(m+=` + `.concat(_[n-2]),r++),m+=` + `.concat(_[n-1]),r++),x=n,m+=` +`.concat(I,"+").concat(A," ").concat(Z1),k+=` +`.concat(P,"-").concat(A," ").concat(Q1),r+=2):(m+=k,k="",(H1===1||n===0)&&(m+=` + `.concat(Z1),r++))}if(r>20&&n30)for(n[26]="".concat(N,"...").concat(A);n.length>27;)n.pop();n.length===1?k=$(this,q(b).call(this,"".concat(u," ").concat(n[0]))):k=$(this,q(b).call(this,"".concat(u,` -`).concat(p.join(` +`).concat(n.join(` `),` -`)))}else{var n=C(d),l="",c=j[m];m==="notDeepEqual"||m==="notEqual"?(n="".concat(j[m],` +`)))}else{var i=f(g),p="",l=S[x];x==="notDeepEqual"||x==="notEqual"?(i="".concat(S[x],` -`).concat(n),n.length>1024&&(n="".concat(n.slice(0,1021),"..."))):(l="".concat(C(_)),n.length>512&&(n="".concat(n.slice(0,509),"...")),l.length>512&&(l="".concat(l.slice(0,509),"...")),m==="deepEqual"||m==="equal"?n="".concat(c,` +`).concat(i),i.length>1024&&(i="".concat(i.slice(0,1021),"..."))):(p="".concat(f(d)),i.length>512&&(i="".concat(i.slice(0,509),"...")),p.length>512&&(p="".concat(p.slice(0,509),"...")),x==="deepEqual"||x==="equal"?i="".concat(l,` -`).concat(n,` +`).concat(i,` should equal -`):l=" ".concat(m," ").concat(l)),x=Y(this,G(h).call(this,"".concat(n).concat(l)))}return Error.stackTraceLimit=u,x.generatedMessage=!y,Object.defineProperty($(x),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),x.code="ERR_ASSERTION",x.actual=d,x.expected=_,x.operator=m,Error.captureStackTrace&&Error.captureStackTrace($(x),g),x.stack,x.name="AssertionError",Y(x)}return K(h,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:T.custom,value:function(k,x){return T(this,Z({},x,{customInspect:!1,depth:0}))}}]),h}(W(Error));Q.exports=L}}),Y0=U0({"assert/build/assert.js"(H,Q){function Z(y){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Z=function(m){return typeof m}:Z=function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},Z(y)}function J(y,m){if(!(y instanceof m))throw new TypeError("Cannot call a class as a function")}var z=W0(),X=z.codes,K=X.ERR_AMBIGUOUS_ARGUMENT,Y=X.ERR_INVALID_ARG_TYPE,$=X.ERR_INVALID_ARG_VALUE,U=X.ERR_INVALID_RETURN_VALUE,W=X.ERR_MISSING_ARGS,B=B0(),D=K0("util"),V=D.inspect,M=K0("util").types,G=M.isPromise,q=M.isRegExp,v=Object.assign,T=Object.is,w=new Map,F=!1,O=Q.exports=S,N={};function A(y){throw y.message instanceof Error?y.message:new B(y)}function I(y,m,g,d,_){var u=arguments.length,i;if(u===0)i="Failed";else if(u===1)g=y,y=void 0;else{if(F===!1){F=!0;var p=process.emitWarning?process.emitWarning:console.warn.bind(console);p("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}u===2&&(d="!=")}if(g instanceof Error)throw g;var n={actual:y,expected:m,operator:d===void 0?"fail":d,stackStartFn:_||I};g!==void 0&&(n.message=g);var l=new B(n);throw i&&(l.message=i,l.generatedMessage=!0),l}O.fail=I,O.AssertionError=B;function P(y,m,g,d){if(!g){var _=!1;if(m===0)_=!0,d="No value argument passed to `assert.ok()`";else if(d instanceof Error)throw d;var u=new B({actual:g,expected:!0,message:d,operator:"==",stackStartFn:y});throw u.generatedMessage=_,u}}function S(){for(var y=arguments.length,m=new Array(y),g=0;g1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_ { - ({ drainMicrotasks } = import.meta.require("bun:jsc")), drainMicrotasks(); }, notImplemented = () => { console.warn("[bun] Warning: async_hooks has not been implemented yet. See https://github.com/oven-sh/bun/issues/1832"), notImplemented = () => { }; diff --git a/src/js/out/modules/node/child_process.js b/src/js/out/modules/node/child_process.js index ddc16e9e9..84bf59e83 100644 --- a/src/js/out/modules/node/child_process.js +++ b/src/js/out/modules/node/child_process.js @@ -1,3 +1,7 @@ +import {EventEmitter} from "node:events"; +import * as StreamModule from "node:stream"; +import {constants} from "node:os"; +import {promisify} from "node:util"; function spawn(file, args, options) { options = normalizeSpawnArguments(file, args, options), validateTimeout(options.timeout), validateAbortSignal(options.signal, "options.signal"); const killSignal2 = sanitizeKillSignal(options.killSignal), child = new ChildProcess; @@ -449,19 +453,14 @@ var validateFunction = function(value, name) { return new TypeError(`The value "${value}" is invalid for option "${name}"`); }, ERR_INVALID_ARG_VALUE = function(name, value, reason) { return new Error(`The value "${value}" is invalid for argument '${name}'. Reason: ${reason}`); -}, EventEmitter = import.meta.require("node:events"), { - Readable: { fromWeb: ReadableFromWeb }, - NativeWritable -} = import.meta.require("node:stream"), { - constants: { signals } -} = import.meta.require("node:os"), { promisify } = import.meta.require("node:util"), { ArrayBuffer, Uint8Array, String, Object, Buffer, Promise: Promise2 } = import.meta.primordials, ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty, ObjectCreate = Object.create, ObjectAssign = Object.assign, ObjectDefineProperty = Object.defineProperty, BufferConcat = Buffer.concat, BufferIsEncoding = Buffer.isEncoding, kEmptyObject = ObjectCreate(null), ArrayPrototypePush = Array.prototype.push, ArrayPrototypeReduce = Array.prototype.reduce, ArrayPrototypeFilter = Array.prototype.filter, ArrayPrototypeJoin = Array.prototype.join, ArrayPrototypeMap = Array.prototype.map, ArrayPrototypeIncludes = Array.prototype.includes, ArrayPrototypeSlice = Array.prototype.slice, ArrayPrototypeUnshift = Array.prototype.unshift, ArrayIsArray = Array.isArray, ArrayBufferIsView = ArrayBuffer.isView, NumberIsInteger = Number.isInteger; +}, signals = constants.signals, { ArrayBuffer, Uint8Array, String, Object, Buffer, Promise: Promise2 } = globalThis[Symbol.for("Bun.lazy")]("primordials"), ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty, ObjectCreate = Object.create, ObjectAssign = Object.assign, ObjectDefineProperty = Object.defineProperty, BufferConcat = Buffer.concat, BufferIsEncoding = Buffer.isEncoding, kEmptyObject = ObjectCreate(null), ArrayPrototypePush = Array.prototype.push, ArrayPrototypeJoin = Array.prototype.join, ArrayPrototypeMap = Array.prototype.map, ArrayPrototypeIncludes = Array.prototype.includes, ArrayPrototypeSlice = Array.prototype.slice, ArrayPrototypeUnshift = Array.prototype.unshift, ArrayIsArray = Array.isArray, ArrayBufferIsView = ArrayBuffer.isView, NumberIsInteger = Number.isInteger; var StringPrototypeToUpperCase = String.prototype.toUpperCase, StringPrototypeIncludes = String.prototype.includes, StringPrototypeSlice = String.prototype.slice, Uint8ArrayPrototypeIncludes = Uint8Array.prototype.includes, MAX_BUFFER = 1048576, __DEBUG__ = process.env.DEBUG || !1, __TRACK_STDIO__ = process.env.DEBUG_STDIO, debug = __DEBUG__ ? console.log : () => { }; if (__TRACK_STDIO__) debug("child_process: debug mode on"), globalThis.__lastId = null, globalThis.__getId = () => { return globalThis.__lastId !== null ? globalThis.__lastId++ : 0; }; -var customPromiseExecFunction = (orig) => { +var NativeWritable2, ReadableFromWeb, customPromiseExecFunction = (orig) => { return (...args) => { let resolve, reject; const promise = new Promise2((res, rej) => { @@ -520,12 +519,13 @@ class ChildProcess extends EventEmitter { debug("ChildProcess: getBunSpawnIo: this.#handle is null. This means the subprocess already exited"); else debug("ChildProcess: getBunSpawnIo: this.#handle is undefined"); + NativeWritable2 ||= StreamModule.NativeWritable, ReadableFromWeb ||= StreamModule.Readable.fromWeb; const io = this.#stdioOptions[i]; switch (i) { case 0: switch (io) { case "pipe": - return new NativeWritable(this.#handle.stdin); + return new NativeWritable2(this.#handle.stdin); case "inherit": return process.stdin || null; case "destroyed": @@ -537,10 +537,7 @@ class ChildProcess extends EventEmitter { case 1: switch (io) { case "pipe": - return ReadableFromWeb(this.#handle[fdToStdioName(i)], __TRACK_STDIO__ ? { - encoding, - __id: `PARENT_${fdToStdioName(i).toUpperCase()}-${globalThis.__getId()}` - } : { encoding }); + return ReadableFromWeb(this.#handle[fdToStdioName(i)], { encoding }); case "inherit": return process[fdToStdioName(i)] || null; case "destroyed": diff --git a/src/js/out/modules/node/cluster.js b/src/js/out/modules/node/cluster.js index 871fe0338..036e80380 100644 --- a/src/js/out/modules/node/cluster.js +++ b/src/js/out/modules/node/cluster.js @@ -1,4 +1,4 @@ -var EventEmitter = import.meta.require("node:events"); +import EventEmitter from "node:events"; // src/js/shared.ts function throwNotImplemented(feature, issue) { diff --git a/src/js/out/modules/node/crypto.js b/src/js/out/modules/node/crypto.js index 7968a8eef..503647e7c 100644 --- a/src/js/out/modules/node/crypto.js +++ b/src/js/out/modules/node/crypto.js @@ -1,4 +1,4 @@ -var T$=Object.defineProperty;var D$=Object.getOwnPropertyNames;var C$=536870888,L$=(bZ)=>import.meta.require(bZ),O$=globalThis.crypto,R$=O$;var P$=(bZ,$)=>function(){return $||(0,bZ[D$(bZ)[0]])(($={exports:{}}).exports,$),$.exports},z$=(bZ,$)=>{for(var Q in $)T$(bZ,Q,{get:$[Q],enumerable:!0})};var M$=P$({"node_modules/safe-buffer/index.js"(bZ,$){var Q=L$("buffer"),Y=Q.Buffer;function Z(V,U){for(var X in V)U[X]=V[X]}Y.from&&Y.alloc&&Y.allocUnsafe&&Y.allocUnsafeSlow?$.exports=Q:(Z(Q,bZ),bZ.Buffer=G);function G(V,U,X){return Y(V,U,X)}G.prototype=Object.create(Y.prototype),Z(Y,G),G.from=function(V,U,X){if(typeof V=="number")throw new TypeError("Argument must not be a number");return Y(V,U,X)},G.alloc=function(V,U,X){if(typeof V!="number")throw new TypeError("Argument must be a number");var K=Y(V);return U!==void 0?typeof X=="string"?K.fill(U,X):K.fill(U):K.fill(0),K},G.allocUnsafe=function(V){if(typeof V!="number")throw new TypeError("Argument must be a number");return Y(V)},G.allocUnsafeSlow=function(V){if(typeof V!="number")throw new TypeError("Argument must be a number");return Q.SlowBuffer(V)}}}),S$=P$({"node_modules/randombytes/browser.js"(bZ,$){var Q=65536,Y=4294967295;function Z(){throw new Error(`Secure random number generation is not supported by this browser. -Use Chrome, Firefox or Internet Explorer 11`)}var G=M$().Buffer,V=R$;V&&V.getRandomValues?$.exports=U:$.exports=Z;function U(X,K){if(X>Y)throw new RangeError("requested too many random bytes");var I=G.allocUnsafe(X);if(X>0)if(X>Q)for(var J=0;J=this._blockSize;){for(var J=this._blockOffset;J0;++O)this._length[O]+=F,F=this._length[O]/4294967296|0,F>0&&(this._length[O]-=4294967296*F);return this},V.prototype._update=function(){throw new Error("_update is not implemented")},V.prototype.digest=function(U){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var X=this._digest();U!==void 0&&(X=X.toString(U)),this._block.fill(0),this._blockOffset=0;for(var K=0;K<4;++K)this._length[K]=0;return X},V.prototype._digest=function(){throw new Error("_digest is not implemented")},$.exports=V}}),j$=P$({"node_modules/md5.js/index.js"(bZ,$){var Q=v$(),Y=q$(),Z=M$().Buffer,G=new Array(16);function V(){Y.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}Q(V,Y),V.prototype._update=function(){for(var O=G,F=0;F<16;++F)O[F]=this._block.readInt32LE(F*4);var A=this._a,W=this._b,H=this._c,E=this._d;A=X(A,W,H,E,O[0],3614090360,7),E=X(E,A,W,H,O[1],3905402710,12),H=X(H,E,A,W,O[2],606105819,17),W=X(W,H,E,A,O[3],3250441966,22),A=X(A,W,H,E,O[4],4118548399,7),E=X(E,A,W,H,O[5],1200080426,12),H=X(H,E,A,W,O[6],2821735955,17),W=X(W,H,E,A,O[7],4249261313,22),A=X(A,W,H,E,O[8],1770035416,7),E=X(E,A,W,H,O[9],2336552879,12),H=X(H,E,A,W,O[10],4294925233,17),W=X(W,H,E,A,O[11],2304563134,22),A=X(A,W,H,E,O[12],1804603682,7),E=X(E,A,W,H,O[13],4254626195,12),H=X(H,E,A,W,O[14],2792965006,17),W=X(W,H,E,A,O[15],1236535329,22),A=K(A,W,H,E,O[1],4129170786,5),E=K(E,A,W,H,O[6],3225465664,9),H=K(H,E,A,W,O[11],643717713,14),W=K(W,H,E,A,O[0],3921069994,20),A=K(A,W,H,E,O[5],3593408605,5),E=K(E,A,W,H,O[10],38016083,9),H=K(H,E,A,W,O[15],3634488961,14),W=K(W,H,E,A,O[4],3889429448,20),A=K(A,W,H,E,O[9],568446438,5),E=K(E,A,W,H,O[14],3275163606,9),H=K(H,E,A,W,O[3],4107603335,14),W=K(W,H,E,A,O[8],1163531501,20),A=K(A,W,H,E,O[13],2850285829,5),E=K(E,A,W,H,O[2],4243563512,9),H=K(H,E,A,W,O[7],1735328473,14),W=K(W,H,E,A,O[12],2368359562,20),A=I(A,W,H,E,O[5],4294588738,4),E=I(E,A,W,H,O[8],2272392833,11),H=I(H,E,A,W,O[11],1839030562,16),W=I(W,H,E,A,O[14],4259657740,23),A=I(A,W,H,E,O[1],2763975236,4),E=I(E,A,W,H,O[4],1272893353,11),H=I(H,E,A,W,O[7],4139469664,16),W=I(W,H,E,A,O[10],3200236656,23),A=I(A,W,H,E,O[13],681279174,4),E=I(E,A,W,H,O[0],3936430074,11),H=I(H,E,A,W,O[3],3572445317,16),W=I(W,H,E,A,O[6],76029189,23),A=I(A,W,H,E,O[9],3654602809,4),E=I(E,A,W,H,O[12],3873151461,11),H=I(H,E,A,W,O[15],530742520,16),W=I(W,H,E,A,O[2],3299628645,23),A=J(A,W,H,E,O[0],4096336452,6),E=J(E,A,W,H,O[7],1126891415,10),H=J(H,E,A,W,O[14],2878612391,15),W=J(W,H,E,A,O[5],4237533241,21),A=J(A,W,H,E,O[12],1700485571,6),E=J(E,A,W,H,O[3],2399980690,10),H=J(H,E,A,W,O[10],4293915773,15),W=J(W,H,E,A,O[1],2240044497,21),A=J(A,W,H,E,O[8],1873313359,6),E=J(E,A,W,H,O[15],4264355552,10),H=J(H,E,A,W,O[6],2734768916,15),W=J(W,H,E,A,O[13],1309151649,21),A=J(A,W,H,E,O[4],4149444226,6),E=J(E,A,W,H,O[11],3174756917,10),H=J(H,E,A,W,O[2],718787259,15),W=J(W,H,E,A,O[9],3951481745,21),this._a=this._a+A|0,this._b=this._b+W|0,this._c=this._c+H|0,this._d=this._d+E|0},V.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var O=Z.allocUnsafe(16);return O.writeInt32LE(this._a,0),O.writeInt32LE(this._b,4),O.writeInt32LE(this._c,8),O.writeInt32LE(this._d,12),O};function U(O,F){return O<>>32-F}function X(O,F,A,W,H,E,T){return U(O+(F&A|~F&W)+H+E|0,T)+F|0}function K(O,F,A,W,H,E,T){return U(O+(F&W|A&~W)+H+E|0,T)+F|0}function I(O,F,A,W,H,E,T){return U(O+(F^A^W)+H+E|0,T)+F|0}function J(O,F,A,W,H,E,T){return U(O+(A^(F|~W))+H+E|0,T)+F|0}$.exports=V}}),k$=P$({"node_modules/ripemd160/index.js"(bZ,$){var Q=L$("buffer").Buffer,Y=v$(),Z=q$(),G=new Array(16),V=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],U=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],X=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],K=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],I=[0,1518500249,1859775393,2400959708,2840853838],J=[1352829926,1548603684,1836072691,2053994217,0];function O(){Z.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}Y(O,Z),O.prototype._update=function(){for(var D=G,C=0;C<16;++C)D[C]=this._block.readInt32LE(C*4);for(var L=this._a|0,R=this._b|0,P=this._c|0,z=this._d|0,M=this._e|0,S=this._a|0,v=this._b|0,q=this._c|0,j=this._d|0,k=this._e|0,g=0;g<80;g+=1){var N,x;g<16?(N=A(L,R,P,z,M,D[V[g]],I[0],X[g]),x=T(S,v,q,j,k,D[U[g]],J[0],K[g])):g<32?(N=W(L,R,P,z,M,D[V[g]],I[1],X[g]),x=E(S,v,q,j,k,D[U[g]],J[1],K[g])):g<48?(N=H(L,R,P,z,M,D[V[g]],I[2],X[g]),x=H(S,v,q,j,k,D[U[g]],J[2],K[g])):g<64?(N=E(L,R,P,z,M,D[V[g]],I[3],X[g]),x=W(S,v,q,j,k,D[U[g]],J[3],K[g])):(N=T(L,R,P,z,M,D[V[g]],I[4],X[g]),x=A(S,v,q,j,k,D[U[g]],J[4],K[g])),L=M,M=z,z=F(P,10),P=R,R=N,S=k,k=j,j=F(q,10),q=v,v=x}var _=this._b+P+j|0;this._b=this._c+z+k|0,this._c=this._d+M+S|0,this._d=this._e+L+v|0,this._e=this._a+R+q|0,this._a=_},O.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var D=Q.alloc?Q.alloc(20):new Q(20);return D.writeInt32LE(this._a,0),D.writeInt32LE(this._b,4),D.writeInt32LE(this._c,8),D.writeInt32LE(this._d,12),D.writeInt32LE(this._e,16),D};function F(D,C){return D<>>32-C}function A(D,C,L,R,P,z,M,S){return F(D+(C^L^R)+z+M|0,S)+P|0}function W(D,C,L,R,P,z,M,S){return F(D+(C&L|~C&R)+z+M|0,S)+P|0}function H(D,C,L,R,P,z,M,S){return F(D+((C|~L)^R)+z+M|0,S)+P|0}function E(D,C,L,R,P,z,M,S){return F(D+(C&R|L&~R)+z+M|0,S)+P|0}function T(D,C,L,R,P,z,M,S){return F(D+(C^(L|~R))+z+M|0,S)+P|0}$.exports=O}}),g$=P$({"node_modules/sha.js/hash.js"(bZ,$){var Q=M$().Buffer;function Y(Z,G){this._block=Q.alloc(Z),this._finalSize=G,this._blockSize=Z,this._len=0}Y.prototype.update=function(Z,G){typeof Z=="string"&&(G=G||"utf8",Z=Q.from(Z,G));for(var V=this._block,U=this._blockSize,X=Z.length,K=this._len,I=0;I=this._finalSize&&(this._update(this._block),this._block.fill(0));var V=this._len*8;if(V<=4294967295)this._block.writeUInt32BE(V,this._blockSize-4);else{var U=(V&4294967295)>>>0,X=(V-U)/4294967296;this._block.writeUInt32BE(X,this._blockSize-8),this._block.writeUInt32BE(U,this._blockSize-4)}this._update(this._block);var K=this._hash();return Z?K.toString(Z):K},Y.prototype._update=function(){throw new Error("_update must be implemented by subclass")},$.exports=Y}}),N$=P$({"node_modules/sha.js/sha.js"(bZ,$){var Q=v$(),Y=g$(),Z=M$().Buffer,G=[1518500249,1859775393,-1894007588,-899497514],V=new Array(80);function U(){this.init(),this._w=V,Y.call(this,64,56)}Q(U,Y),U.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function X(J){return J<<5|J>>>27}function K(J){return J<<30|J>>>2}function I(J,O,F,A){return J===0?O&F|~O&A:J===2?O&F|O&A|F&A:O^F^A}U.prototype._update=function(J){for(var O=this._w,F=this._a|0,A=this._b|0,W=this._c|0,H=this._d|0,E=this._e|0,T=0;T<16;++T)O[T]=J.readInt32BE(T*4);for(;T<80;++T)O[T]=O[T-3]^O[T-8]^O[T-14]^O[T-16];for(var D=0;D<80;++D){var C=~~(D/20),L=X(F)+I(C,A,W,H)+E+O[D]+G[C]|0;E=H,H=W,W=K(A),A=F,F=L}this._a=F+this._a|0,this._b=A+this._b|0,this._c=W+this._c|0,this._d=H+this._d|0,this._e=E+this._e|0},U.prototype._hash=function(){var J=Z.allocUnsafe(20);return J.writeInt32BE(this._a|0,0),J.writeInt32BE(this._b|0,4),J.writeInt32BE(this._c|0,8),J.writeInt32BE(this._d|0,12),J.writeInt32BE(this._e|0,16),J},$.exports=U}}),x$=P$({"node_modules/sha.js/sha1.js"(bZ,$){var Q=v$(),Y=g$(),Z=M$().Buffer,G=[1518500249,1859775393,-1894007588,-899497514],V=new Array(80);function U(){this.init(),this._w=V,Y.call(this,64,56)}Q(U,Y),U.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function X(O){return O<<1|O>>>31}function K(O){return O<<5|O>>>27}function I(O){return O<<30|O>>>2}function J(O,F,A,W){return O===0?F&A|~F&W:O===2?F&A|F&W|A&W:F^A^W}U.prototype._update=function(O){for(var F=this._w,A=this._a|0,W=this._b|0,H=this._c|0,E=this._d|0,T=this._e|0,D=0;D<16;++D)F[D]=O.readInt32BE(D*4);for(;D<80;++D)F[D]=X(F[D-3]^F[D-8]^F[D-14]^F[D-16]);for(var C=0;C<80;++C){var L=~~(C/20),R=K(A)+J(L,W,H,E)+T+F[C]+G[L]|0;T=E,E=H,H=I(W),W=A,A=R}this._a=A+this._a|0,this._b=W+this._b|0,this._c=H+this._c|0,this._d=E+this._d|0,this._e=T+this._e|0},U.prototype._hash=function(){var O=Z.allocUnsafe(20);return O.writeInt32BE(this._a|0,0),O.writeInt32BE(this._b|0,4),O.writeInt32BE(this._c|0,8),O.writeInt32BE(this._d|0,12),O.writeInt32BE(this._e|0,16),O},$.exports=U}}),_$=P$({"node_modules/sha.js/sha256.js"(bZ,$){var Q=v$(),Y=g$(),Z=M$().Buffer,G=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],V=new Array(64);function U(){this.init(),this._w=V,Y.call(this,64,56)}Q(U,Y),U.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function X(A,W,H){return H^A&(W^H)}function K(A,W,H){return A&W|H&(A|W)}function I(A){return(A>>>2|A<<30)^(A>>>13|A<<19)^(A>>>22|A<<10)}function J(A){return(A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7)}function O(A){return(A>>>7|A<<25)^(A>>>18|A<<14)^A>>>3}function F(A){return(A>>>17|A<<15)^(A>>>19|A<<13)^A>>>10}U.prototype._update=function(A){for(var W=this._w,H=this._a|0,E=this._b|0,T=this._c|0,D=this._d|0,C=this._e|0,L=this._f|0,R=this._g|0,P=this._h|0,z=0;z<16;++z)W[z]=A.readInt32BE(z*4);for(;z<64;++z)W[z]=F(W[z-2])+W[z-7]+O(W[z-15])+W[z-16]|0;for(var M=0;M<64;++M){var S=P+J(C)+X(C,L,R)+G[M]+W[M]|0,v=I(H)+K(H,E,T)|0;P=R,R=L,L=C,C=D+S|0,D=T,T=E,E=H,H=S+v|0}this._a=H+this._a|0,this._b=E+this._b|0,this._c=T+this._c|0,this._d=D+this._d|0,this._e=C+this._e|0,this._f=L+this._f|0,this._g=R+this._g|0,this._h=P+this._h|0},U.prototype._hash=function(){var A=Z.allocUnsafe(32);return A.writeInt32BE(this._a,0),A.writeInt32BE(this._b,4),A.writeInt32BE(this._c,8),A.writeInt32BE(this._d,12),A.writeInt32BE(this._e,16),A.writeInt32BE(this._f,20),A.writeInt32BE(this._g,24),A.writeInt32BE(this._h,28),A},$.exports=U}}),B$=P$({"node_modules/sha.js/sha224.js"(bZ,$){var Q=v$(),Y=_$(),Z=g$(),G=M$().Buffer,V=new Array(64);function U(){this.init(),this._w=V,Z.call(this,64,56)}Q(U,Y),U.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},U.prototype._hash=function(){var X=G.allocUnsafe(28);return X.writeInt32BE(this._a,0),X.writeInt32BE(this._b,4),X.writeInt32BE(this._c,8),X.writeInt32BE(this._d,12),X.writeInt32BE(this._e,16),X.writeInt32BE(this._f,20),X.writeInt32BE(this._g,24),X},$.exports=U}}),y$=P$({"node_modules/sha.js/sha512.js"(bZ,$){var Q=v$(),Y=g$(),Z=M$().Buffer,G=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],V=new Array(160);function U(){this.init(),this._w=V,Y.call(this,128,112)}Q(U,Y),U.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function X(E,T,D){return D^E&(T^D)}function K(E,T,D){return E&T|D&(E|T)}function I(E,T){return(E>>>28|T<<4)^(T>>>2|E<<30)^(T>>>7|E<<25)}function J(E,T){return(E>>>14|T<<18)^(E>>>18|T<<14)^(T>>>9|E<<23)}function O(E,T){return(E>>>1|T<<31)^(E>>>8|T<<24)^E>>>7}function F(E,T){return(E>>>1|T<<31)^(E>>>8|T<<24)^(E>>>7|T<<25)}function A(E,T){return(E>>>19|T<<13)^(T>>>29|E<<3)^E>>>6}function W(E,T){return(E>>>19|T<<13)^(T>>>29|E<<3)^(E>>>6|T<<26)}function H(E,T){return E>>>0>>0?1:0}U.prototype._update=function(E){for(var T=this._w,D=this._ah|0,C=this._bh|0,L=this._ch|0,R=this._dh|0,P=this._eh|0,z=this._fh|0,M=this._gh|0,S=this._hh|0,v=this._al|0,q=this._bl|0,j=this._cl|0,k=this._dl|0,g=this._el|0,N=this._fl|0,x=this._gl|0,_=this._hl|0,B=0;B<32;B+=2)T[B]=E.readInt32BE(B*4),T[B+1]=E.readInt32BE(B*4+4);for(;B<160;B+=2){var y=T[B-30],w=T[B-30+1],f=O(y,w),p=F(w,y);y=T[B-4],w=T[B-4+1];var c=A(y,w),h=W(w,y),d=T[B-14],b=T[B-14+1],l=T[B-32],o=T[B-32+1],u=p+b|0,n=f+d+H(u,p)|0;u=u+h|0,n=n+c+H(u,h)|0,u=u+o|0,n=n+l+H(u,o)|0,T[B]=n,T[B+1]=u}for(var s=0;s<160;s+=2){n=T[s],u=T[s+1];var t=K(D,C,L),m=K(v,q,j),a=I(D,v),r=I(v,D),e=J(P,g),i=J(g,P),$0=G[s],Q0=G[s+1],Y0=X(P,z,M),Z0=X(g,N,x),G0=_+i|0,V0=S+e+H(G0,_)|0;G0=G0+Z0|0,V0=V0+Y0+H(G0,Z0)|0,G0=G0+Q0|0,V0=V0+$0+H(G0,Q0)|0,G0=G0+u|0,V0=V0+n+H(G0,u)|0;var U0=r+m|0,X0=a+t+H(U0,r)|0;S=M,_=x,M=z,x=N,z=P,N=g,g=k+G0|0,P=R+V0+H(g,k)|0,R=L,k=j,L=C,j=q,C=D,q=v,v=G0+U0|0,D=V0+X0+H(v,G0)|0}this._al=this._al+v|0,this._bl=this._bl+q|0,this._cl=this._cl+j|0,this._dl=this._dl+k|0,this._el=this._el+g|0,this._fl=this._fl+N|0,this._gl=this._gl+x|0,this._hl=this._hl+_|0,this._ah=this._ah+D+H(this._al,v)|0,this._bh=this._bh+C+H(this._bl,q)|0,this._ch=this._ch+L+H(this._cl,j)|0,this._dh=this._dh+R+H(this._dl,k)|0,this._eh=this._eh+P+H(this._el,g)|0,this._fh=this._fh+z+H(this._fl,N)|0,this._gh=this._gh+M+H(this._gl,x)|0,this._hh=this._hh+S+H(this._hl,_)|0},U.prototype._hash=function(){var E=Z.allocUnsafe(64);function T(D,C,L){E.writeInt32BE(D,L),E.writeInt32BE(C,L+4)}return T(this._ah,this._al,0),T(this._bh,this._bl,8),T(this._ch,this._cl,16),T(this._dh,this._dl,24),T(this._eh,this._el,32),T(this._fh,this._fl,40),T(this._gh,this._gl,48),T(this._hh,this._hl,56),E},$.exports=U}}),w$=P$({"node_modules/sha.js/sha384.js"(bZ,$){var Q=v$(),Y=y$(),Z=g$(),G=M$().Buffer,V=new Array(160);function U(){this.init(),this._w=V,Z.call(this,128,112)}Q(U,Y),U.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},U.prototype._hash=function(){var X=G.allocUnsafe(48);function K(I,J,O){X.writeInt32BE(I,O),X.writeInt32BE(J,O+4)}return K(this._ah,this._al,0),K(this._bh,this._bl,8),K(this._ch,this._cl,16),K(this._dh,this._dl,24),K(this._eh,this._el,32),K(this._fh,this._fl,40),X},$.exports=U}}),f$=P$({"node_modules/sha.js/index.js"(Q,$){var Q=$.exports=function(Y){Y=Y.toLowerCase();var Z=Q[Y];if(!Z)throw new Error(Y+" is not supported (we accept pull requests)");return new Z};Q.sha=N$(),Q.sha1=x$(),Q.sha224=B$(),Q.sha256=_$(),Q.sha384=w$(),Q.sha512=y$()}}),p$=import.meta.require("node:stream"),c$=P$({"node_modules/cipher-base/index.js"(bZ,$){var Q=M$().Buffer,Y=p$.Transform,Z=L$("string_decoder").StringDecoder,G=v$();function V(U){Y.call(this),this.hashMode=typeof U=="string",this.hashMode?this[U]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}G(V,Y),V.prototype.update=function(U,X,K){typeof U=="string"&&(U=Q.from(U,X));var I=this._update(U);return this.hashMode?this:(K&&(I=this._toString(I,K)),I)},V.prototype.setAutoPadding=function(){},V.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},V.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},V.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},V.prototype._transform=function(U,X,K){var I;try{this.hashMode?this._update(U):this.push(this._update(U))}catch(J){I=J}finally{K(I)}},V.prototype._flush=function(U){var X;try{this.push(this.__final())}catch(K){X=K}U(X)},V.prototype._finalOrDigest=function(U){var X=this.__final()||Q.alloc(0);return U&&(X=this._toString(X,U,!0)),X},V.prototype._toString=function(U,X,K){if(this._decoder||(this._decoder=new Z(X),this._encoding=X),this._encoding!==X)throw new Error("can't switch encodings");var I=this._decoder.write(U);return K&&(I+=this._decoder.end()),I},$.exports=V}}),h$=P$({"node_modules/create-hash/browser.js"(bZ,$){const{Transform:Q}=p$,Y=function V(U,X){this._options=X,this._hasher=new lY(U,X),this._finalized=!1};Y.prototype=Object.create(Q.prototype),Y.prototype.update=function V(U,X){return this._checkFinalized(),this._hasher.update(U,X),this},Y.prototype.digest=function V(U,X){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(U,X)},Y.prototype._checkFinalized=function V(){if(this._finalized){var U=new Error("Digest already called");throw U.code="ERR_CRYPTO_HASH_FINALIZED",U}},Y.prototype.copy=function V(){const U=Object.create(Y.prototype);return U._options=this._options,U._hasher=this._hasher.copy(),U._finalized=this._finalized,U};const Z={__proto__:Q.prototype,...Y.prototype,_transform(V,U,X){this.update(V,U),X&&X()},_flush(V){this.push(this.digest()),V()}},G=["_events","_eventsCount","_final","_maxListeners","_maxListeners","_read","_undestroy","_writableState","_write","_writev","addListener","asIndexedPairs","closed","compose","constructor","cork","destroy","destroyed","drop","emit","end","errored","eventNames","every","filter","find","flatMap","forEach","getMaxListeners","hasOwnProperty","isPaused","isPrototypeOf","iterator","listenerCount","listeners","map","off","on","once","pause","pipe","prependListener","prependOnceListener","propertyIsEnumerable","push","rawListeners","read","readable","readableAborted","readableBuffer","readableDidRead","readableEncoding","readableEnded","readableFlowing","readableHighWaterMark","readableLength","readableObjectMode","reduce","removeAllListeners","removeListener","resume","setDefaultEncoding","setEncoding","setMaxListeners","some","take","toArray","toLocaleString","toString","uncork","unpipe","unshift","valueOf","wrap","writable","writableBuffer","writableCorked","writableEnded","writableFinished","writableHighWaterMark","writableLength","writableNeedDrain","writableObjectMode","write"];for(let V of G)Object.defineProperty(Y.prototype,V,{get(){return Object.setPrototypeOf(this,Z),Q.call(this,this._options),this[V]},enumerable:!1,configurable:!0});$.exports=function V(U){return new Y(U)},$.exports.createHash=$.exports,$.exports.Hash=Y}}),d$=P$({"node_modules/create-hmac/legacy.js"(bZ,$){var Q=v$(),Y=M$().Buffer,Z=c$(),G=Y.alloc(128),V=64;function U(X,K){Z.call(this,"digest"),typeof K=="string"&&(K=Y.from(K)),this._alg=X,this._key=K,K.length>V?K=X(K):K.lengthF){var A=J==="rmd160"?new U:X(J);O=A.update(O).digest()}else O.lengthQ||Z!==Z)throw new TypeError("Bad key length")}}}),s$=P$({"node_modules/pbkdf2/lib/default-encoding.js"(bZ,$){var Q;global.process&&global.process.browser?Q="utf-8":global.process&&global.process.version?(Y=parseInt(process.version.split(".")[0].slice(1),10),Q=Y>=6?"utf-8":"binary"):Q="utf-8";var Y;$.exports=Q}}),t$=P$({"node_modules/pbkdf2/lib/to-buffer.js"(bZ,$){var Q=M$().Buffer;$.exports=function(Y,Z,G){if(Q.isBuffer(Y))return Y;if(typeof Y=="string")return Q.from(Y,Z);if(ArrayBuffer.isView(Y))return Q.from(Y.buffer);throw new TypeError(G+" must be a string, a Buffer, a typed array or a DataView")}}}),m$=P$({"node_modules/pbkdf2/lib/sync-browser.js"(bZ,$){var Q=b$(),Y=k$(),Z=f$(),G=M$().Buffer,V=n$(),U=s$(),X=t$(),K=G.alloc(128),I={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function J(A,W,H){var E=O(A),T=A==="sha512"||A==="sha384"?128:64;W.length>T?W=E(W):W.length>>0},bZ.writeUInt32BE=function(Z,G,V){Z[0+V]=G>>>24,Z[1+V]=G>>>16&255,Z[2+V]=G>>>8&255,Z[3+V]=G&255},bZ.ip=function(Z,G,V,U){for(var X=0,K=0,I=6;I>=0;I-=2){for(var J=0;J<=24;J+=8)X<<=1,X|=G>>>J+I&1;for(var J=0;J<=24;J+=8)X<<=1,X|=Z>>>J+I&1}for(var I=6;I>=0;I-=2){for(var J=1;J<=25;J+=8)K<<=1,K|=G>>>J+I&1;for(var J=1;J<=25;J+=8)K<<=1,K|=Z>>>J+I&1}V[U+0]=X>>>0,V[U+1]=K>>>0},bZ.rip=function(Z,G,V,U){for(var X=0,K=0,I=0;I<4;I++)for(var J=24;J>=0;J-=8)X<<=1,X|=G>>>J+I&1,X<<=1,X|=Z>>>J+I&1;for(var I=4;I<8;I++)for(var J=24;J>=0;J-=8)K<<=1,K|=G>>>J+I&1,K<<=1,K|=Z>>>J+I&1;V[U+0]=X>>>0,V[U+1]=K>>>0},bZ.pc1=function(Z,G,V,U){for(var X=0,K=0,I=7;I>=5;I--){for(var J=0;J<=24;J+=8)X<<=1,X|=G>>J+I&1;for(var J=0;J<=24;J+=8)X<<=1,X|=Z>>J+I&1}for(var J=0;J<=24;J+=8)X<<=1,X|=G>>J+I&1;for(var I=1;I<=3;I++){for(var J=0;J<=24;J+=8)K<<=1,K|=G>>J+I&1;for(var J=0;J<=24;J+=8)K<<=1,K|=Z>>J+I&1}for(var J=0;J<=24;J+=8)K<<=1,K|=Z>>J+I&1;V[U+0]=X>>>0,V[U+1]=K>>>0},bZ.r28shl=function(Z,G){return Z<>>28-G};var $=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];bZ.pc2=function(Z,G,V,U){for(var X=0,K=0,I=$.length>>>1,J=0;J>>$[J]&1;for(var J=I;J<$.length;J++)K<<=1,K|=G>>>$[J]&1;V[U+0]=X>>>0,V[U+1]=K>>>0},bZ.expand=function(Z,G,V){var U=0,X=0;U=(Z&1)<<5|Z>>>27;for(var K=23;K>=15;K-=4)U<<=6,U|=Z>>>K&63;for(var K=11;K>=3;K-=4)X|=Z>>>K&63,X<<=6;X|=(Z&31)<<1|Z>>>31,G[V+0]=U>>>0,G[V+1]=X>>>0};var Q=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];bZ.substitute=function(Z,G){for(var V=0,U=0;U<4;U++){var X=Z>>>18-U*6&63,K=Q[U*64+X];V<<=4,V|=K}for(var U=0;U<4;U++){var X=G>>>18-U*6&63,K=Q[256+U*64+X];V<<=4,V|=K}return V>>>0};var Y=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];bZ.permute=function(Z){for(var G=0,V=0;V>>Y[V]&1;return G>>>0},bZ.padSplit=function(Z,G,V){for(var U=Z.toString(2);U.length0;U--)G+=this._buffer(Z,G),V+=this._flushBuffer(X,V);return G+=this._buffer(Z,G),X},Y.prototype.final=function(Z){var G;Z&&(G=this.update(Z));var V;return this.type==="encrypt"?V=this._finalEncrypt():V=this._finalDecrypt(),G?G.concat(V):V},Y.prototype._pad=function(Z,G){if(G===0)return!1;for(;G>>1];J=Z.r28shl(J,A),O=Z.r28shl(O,A),Z.pc2(J,O,K.keys,F)}},U.prototype._update=function(K,I,J,O){var F=this._desState,A=Z.readUInt32BE(K,I),W=Z.readUInt32BE(K,I+4);Z.ip(A,W,F.tmp,0),A=F.tmp[0],W=F.tmp[1],this.type==="encrypt"?this._encrypt(F,A,W,F.tmp,0):this._decrypt(F,A,W,F.tmp,0),A=F.tmp[0],W=F.tmp[1],Z.writeUInt32BE(J,A,O),Z.writeUInt32BE(J,W,O+4)},U.prototype._pad=function(K,I){for(var J=K.length-I,O=I;O>>0,A=L}Z.rip(W,A,O,F)},U.prototype._decrypt=function(K,I,J,O,F){for(var A=J,W=I,H=K.keys.length-2;H>=0;H-=2){var E=K.keys[H],T=K.keys[H+1];Z.expand(A,K.tmp,0),E^=K.tmp[0],T^=K.tmp[1];var D=Z.substitute(E,T),C=Z.permute(D),L=A;A=(W^C)>>>0,W=L}Z.rip(A,W,O,F)}}}),YQ=P$({"node_modules/des.js/lib/des/cbc.js"(bZ){var $=i$(),Q=v$(),Y={};function Z(V){$.equal(V.length,8,"Invalid IV length"),this.iv=new Array(8);for(var U=0;U>X%8,Z._prev=Y(Z._prev,V?J:O);return I}function Y(Z,G){var V=Z.length,U=-1,X=$.allocUnsafe(Z.length);for(Z=$.concat([Z,$.from([G])]);++U>7;return X}bZ.encrypt=function(Z,G,V){for(var U=G.length,X=$.allocUnsafe(U),K=-1;++K>>24]^W[D>>>16&255]^H[C>>>8&255]^E[L&255]^I[S++],P=A[D>>>24]^W[C>>>16&255]^H[L>>>8&255]^E[T&255]^I[S++],z=A[C>>>24]^W[L>>>16&255]^H[T>>>8&255]^E[D&255]^I[S++],M=A[L>>>24]^W[T>>>16&255]^H[D>>>8&255]^E[C&255]^I[S++],T=R,D=P,C=z,L=M;return R=(O[T>>>24]<<24|O[D>>>16&255]<<16|O[C>>>8&255]<<8|O[L&255])^I[S++],P=(O[D>>>24]<<24|O[C>>>16&255]<<16|O[L>>>8&255]<<8|O[T&255])^I[S++],z=(O[C>>>24]<<24|O[L>>>16&255]<<16|O[T>>>8&255]<<8|O[D&255])^I[S++],M=(O[L>>>24]<<24|O[T>>>16&255]<<16|O[D>>>8&255]<<8|O[C&255])^I[S++],R=R>>>0,P=P>>>0,z=z>>>0,M=M>>>0,[R,P,z,M]}var V=[0,1,2,4,8,16,32,64,128,27,54],U=function(){for(var K=new Array(256),I=0;I<256;I++)I<128?K[I]=I<<1:K[I]=I<<1^283;for(var J=[],O=[],F=[[],[],[],[]],A=[[],[],[],[]],W=0,H=0,E=0;E<256;++E){var T=H^H<<1^H<<2^H<<3^H<<4;T=T>>>8^T&255^99,J[W]=T,O[T]=W;var D=K[W],C=K[D],L=K[C],R=K[T]*257^T*16843008;F[0][W]=R<<24|R>>>8,F[1][W]=R<<16|R>>>16,F[2][W]=R<<8|R>>>24,F[3][W]=R,R=L*16843009^C*65537^D*257^W*16843008,A[0][T]=R<<24|R>>>8,A[1][T]=R<<16|R>>>16,A[2][T]=R<<8|R>>>24,A[3][T]=R,W===0?W=H=1:(W=D^K[K[K[L^D]]],H^=K[K[H]])}return{SBOX:J,INV_SBOX:O,SUB_MIX:F,INV_SUB_MIX:A}}();function X(K){this._key=Y(K),this._reset()}X.blockSize=16,X.keySize=32,X.prototype.blockSize=X.blockSize,X.prototype.keySize=X.keySize,X.prototype._reset=function(){for(var K=this._key,I=K.length,J=I+6,O=(J+1)*4,F=[],A=0;A>>24,W=U.SBOX[W>>>24]<<24|U.SBOX[W>>>16&255]<<16|U.SBOX[W>>>8&255]<<8|U.SBOX[W&255],W^=V[A/I|0]<<24):I>6&&A%I===4&&(W=U.SBOX[W>>>24]<<24|U.SBOX[W>>>16&255]<<16|U.SBOX[W>>>8&255]<<8|U.SBOX[W&255]),F[A]=F[A-I]^W}for(var H=[],E=0;E>>24]]^U.INV_SUB_MIX[1][U.SBOX[D>>>16&255]]^U.INV_SUB_MIX[2][U.SBOX[D>>>8&255]]^U.INV_SUB_MIX[3][U.SBOX[D&255]]}this._nRounds=J,this._keySchedule=F,this._invKeySchedule=H},X.prototype.encryptBlockRaw=function(K){return K=Y(K),G(K,this._keySchedule,U.SUB_MIX,U.SBOX,this._nRounds)},X.prototype.encryptBlock=function(K){var I=this.encryptBlockRaw(K),J=Q.allocUnsafe(16);return J.writeUInt32BE(I[0],0),J.writeUInt32BE(I[1],4),J.writeUInt32BE(I[2],8),J.writeUInt32BE(I[3],12),J},X.prototype.decryptBlock=function(K){K=Y(K);var I=K[1];K[1]=K[3],K[3]=I;var J=G(K,this._invKeySchedule,U.INV_SUB_MIX,U.INV_SBOX,this._nRounds),O=Q.allocUnsafe(16);return O.writeUInt32BE(J[0],0),O.writeUInt32BE(J[3],4),O.writeUInt32BE(J[2],8),O.writeUInt32BE(J[1],12),O},X.prototype.scrub=function(){Z(this._keySchedule),Z(this._invKeySchedule),Z(this._key)},$.exports.AES=X}}),TQ=P$({"node_modules/browserify-aes/ghash.js"(bZ,$){var Q=M$().Buffer,Y=Q.alloc(16,0);function Z(U){return[U.readUInt32BE(0),U.readUInt32BE(4),U.readUInt32BE(8),U.readUInt32BE(12)]}function G(U){var X=Q.allocUnsafe(16);return X.writeUInt32BE(U[0]>>>0,0),X.writeUInt32BE(U[1]>>>0,4),X.writeUInt32BE(U[2]>>>0,8),X.writeUInt32BE(U[3]>>>0,12),X}function V(U){this.h=U,this.state=Q.alloc(16,0),this.cache=Q.allocUnsafe(0)}V.prototype.ghash=function(U){for(var X=-1;++X0;K--)U[K]=U[K]>>>1|(U[K-1]&1)<<31;U[0]=U[0]>>>1,J&&(U[0]=U[0]^225<<24)}this.state=G(X)},V.prototype.update=function(U){this.cache=Q.concat([this.cache,U]);for(var X;this.cache.length>=16;)X=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(X)},V.prototype.final=function(U,X){return this.cache.length&&this.ghash(Q.concat([this.cache,Y],16)),this.ghash(G([0,U,0,X])),this.state},$.exports=V}}),DQ=P$({"node_modules/browserify-aes/authCipher.js"(bZ,$){var Q=EQ(),Y=M$().Buffer,Z=c$(),G=v$(),V=TQ(),U=XQ(),X=AQ();function K(O,F){var A=0;O.length!==F.length&&A++;for(var W=Math.min(O.length,F.length),H=0;H0||X>0;){var F=new Y;F.update(O),F.update(G),V&&F.update(V),O=F.digest();var A=0;if(K>0){var W=I.length-K;A=Math.min(K,O.length),O.copy(I,W,0,A),K-=A}if(A0){var H=J.length-X,E=Math.min(X,O.length-A);O.copy(J,H,A,A+E),X-=E}}return O.fill(0),{key:I,iv:J}}$.exports=Z}}),RQ=P$({"node_modules/browserify-aes/encrypter.js"(bZ){var $=HQ(),Q=DQ(),Y=M$().Buffer,Z=CQ(),G=c$(),V=EQ(),U=LQ(),X=v$();function K(A,W,H){G.call(this),this._cache=new J,this._cipher=new V.AES(W),this._prev=Y.from(H),this._mode=A,this._autopadding=!0}X(K,G),K.prototype._update=function(A){this._cache.add(A);for(var W,H,E=[];W=this._cache.get();)H=this._mode.encrypt(this,W),E.push(H);return Y.concat(E)};var I=Y.alloc(16,16);K.prototype._final=function(){var A=this._cache.flush();if(this._autopadding)return A=this._mode.encrypt(this,A),this._cipher.scrub(),A;if(!A.equals(I))throw this._cipher.scrub(),new Error("data not multiple of block length")},K.prototype.setAutoPadding=function(A){return this._autopadding=!!A,this};function J(){this.cache=Y.allocUnsafe(0)}J.prototype.add=function(A){this.cache=Y.concat([this.cache,A])},J.prototype.get=function(){if(this.cache.length>15){var A=this.cache.slice(0,16);return this.cache=this.cache.slice(16),A}return null},J.prototype.flush=function(){for(var A=16-this.cache.length,W=Y.allocUnsafe(A),H=-1;++H16)return W=this.cache.slice(0,16),this.cache=this.cache.slice(16),W}else if(this.cache.length>=16)return W=this.cache.slice(0,16),this.cache=this.cache.slice(16),W;return null},I.prototype.flush=function(){if(this.cache.length)return this.cache};function J(A){var W=A[15];if(W<1||W>16)throw new Error("unable to decrypt data");for(var H=-1;++H0?q:j},V.min=function(q,j){return q.cmp(j)<0?q:j},V.prototype._init=function(q,j,k){if(typeof q=="number")return this._initNumber(q,j,k);if(typeof q=="object")return this._initArray(q,j,k);j==="hex"&&(j=16),Z(j===(j|0)&&j>=2&&j<=36),q=q.toString().replace(/\s+/g,"");var g=0;q[0]==="-"&&(g++,this.negative=1),g=0;g-=3)x=q[g]|q[g-1]<<8|q[g-2]<<16,this.words[N]|=x<<_&67108863,this.words[N+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);else if(k==="le")for(g=0,N=0;g>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);return this.strip()};function X(q,j){var k=q.charCodeAt(j);return k>=65&&k<=70?k-55:k>=97&&k<=102?k-87:k-48&15}function K(q,j,k){var g=X(q,k);return k-1>=j&&(g|=X(q,k-1)<<4),g}V.prototype._parseHex=function(q,j,k){this.length=Math.ceil((q.length-j)/6),this.words=new Array(this.length);for(var g=0;g=j;g-=2)_=K(q,j,g)<=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8;else{var B=q.length-j;for(g=B%2===0?j+1:j;g=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8}this.strip()};function I(q,j,k,g){for(var N=0,x=Math.min(q.length,k),_=j;_=49?N+=B-49+10:B>=17?N+=B-17+10:N+=B}return N}V.prototype._parseBase=function(q,j,k){this.words=[0],this.length=1;for(var g=0,N=1;N<=67108863;N*=j)g++;g--,N=N/j|0;for(var x=q.length-k,_=x%g,B=Math.min(x,x-_)+k,y=0,w=k;w1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},V.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},V.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],O=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],F=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];V.prototype.toString=function(q,j){q=q||10,j=j|0||1;var k;if(q===16||q==="hex"){k="";for(var g=0,N=0,x=0;x>>24-g&16777215,N!==0||x!==this.length-1?k=J[6-B.length]+B+k:k=B+k,g+=2,g>=26&&(g-=26,x--)}for(N!==0&&(k=N.toString(16)+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}if(q===(q|0)&&q>=2&&q<=36){var y=O[q],w=F[q];k="";var f=this.clone();for(f.negative=0;!f.isZero();){var p=f.modn(w).toString(q);f=f.idivn(w),f.isZero()?k=p+k:k=J[y-p.length]+p+k}for(this.isZero()&&(k="0"+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}Z(!1,"Base should be between 2 and 36")},V.prototype.toNumber=function(){var q=this.words[0];return this.length===2?q+=this.words[1]*67108864:this.length===3&&this.words[2]===1?q+=4503599627370496+this.words[1]*67108864:this.length>2&&Z(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-q:q},V.prototype.toJSON=function(){return this.toString(16)},V.prototype.toBuffer=function(q,j){return Z(typeof U<"u"),this.toArrayLike(U,q,j)},V.prototype.toArray=function(q,j){return this.toArrayLike(Array,q,j)},V.prototype.toArrayLike=function(q,j,k){var g=this.byteLength(),N=k||Math.max(1,g);Z(g<=N,"byte array longer than desired length"),Z(N>0,"Requested array length <= 0"),this.strip();var x=j==="le",_=new q(N),B,y,w=this.clone();if(x){for(y=0;!w.isZero();y++)B=w.andln(255),w.iushrn(8),_[y]=B;for(;y=4096&&(k+=13,j>>>=13),j>=64&&(k+=7,j>>>=7),j>=8&&(k+=4,j>>>=4),j>=2&&(k+=2,j>>>=2),k+j},V.prototype._zeroBits=function(q){if(q===0)return 26;var j=q,k=0;return(j&8191)===0&&(k+=13,j>>>=13),(j&127)===0&&(k+=7,j>>>=7),(j&15)===0&&(k+=4,j>>>=4),(j&3)===0&&(k+=2,j>>>=2),(j&1)===0&&k++,k},V.prototype.bitLength=function(){var q=this.words[this.length-1],j=this._countBits(q);return(this.length-1)*26+j};function A(q){for(var j=new Array(q.bitLength()),k=0;k>>N}return j}V.prototype.zeroBits=function(){if(this.isZero())return 0;for(var q=0,j=0;jq.length?this.clone().ior(q):q.clone().ior(this)},V.prototype.uor=function(q){return this.length>q.length?this.clone().iuor(q):q.clone().iuor(this)},V.prototype.iuand=function(q){var j;this.length>q.length?j=q:j=this;for(var k=0;kq.length?this.clone().iand(q):q.clone().iand(this)},V.prototype.uand=function(q){return this.length>q.length?this.clone().iuand(q):q.clone().iuand(this)},V.prototype.iuxor=function(q){var j,k;this.length>q.length?(j=this,k=q):(j=q,k=this);for(var g=0;gq.length?this.clone().ixor(q):q.clone().ixor(this)},V.prototype.uxor=function(q){return this.length>q.length?this.clone().iuxor(q):q.clone().iuxor(this)},V.prototype.inotn=function(q){Z(typeof q=="number"&&q>=0);var j=Math.ceil(q/26)|0,k=q%26;this._expand(j),k>0&&j--;for(var g=0;g0&&(this.words[g]=~this.words[g]&67108863>>26-k),this.strip()},V.prototype.notn=function(q){return this.clone().inotn(q)},V.prototype.setn=function(q,j){Z(typeof q=="number"&&q>=0);var k=q/26|0,g=q%26;return this._expand(k+1),j?this.words[k]=this.words[k]|1<q.length?(k=this,g=q):(k=q,g=this);for(var N=0,x=0;x>>26;for(;N!==0&&x>>26;if(this.length=k.length,N!==0)this.words[this.length]=N,this.length++;else if(k!==this)for(;xq.length?this.clone().iadd(q):q.clone().iadd(this)},V.prototype.isub=function(q){if(q.negative!==0){q.negative=0;var j=this.iadd(q);return q.negative=1,j._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(q),this.negative=1,this._normSign();var k=this.cmp(q);if(k===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,N;k>0?(g=this,N=q):(g=q,N=this);for(var x=0,_=0;_>26,this.words[_]=j&67108863;for(;x!==0&&_>26,this.words[_]=j&67108863;if(x===0&&_>>26,p=y&67108863,c=Math.min(w,j.length-1),h=Math.max(0,w-q.length+1);h<=c;h++){var d=w-h|0;N=q.words[d]|0,x=j.words[h]|0,_=N*x+p,f+=_/67108864|0,p=_&67108863}k.words[w]=p|0,y=f|0}return y!==0?k.words[w]=y|0:k.length--,k.strip()}var H=function(q,j,k){var g=q.words,N=j.words,x=k.words,_=0,B,y,w,f=g[0]|0,p=f&8191,c=f>>>13,h=g[1]|0,d=h&8191,b=h>>>13,l=g[2]|0,o=l&8191,u=l>>>13,n=g[3]|0,s=n&8191,t=n>>>13,m=g[4]|0,a=m&8191,r=m>>>13,e=g[5]|0,i=e&8191,$0=e>>>13,Q0=g[6]|0,Y0=Q0&8191,Z0=Q0>>>13,G0=g[7]|0,V0=G0&8191,U0=G0>>>13,X0=g[8]|0,K0=X0&8191,I0=X0>>>13,J0=g[9]|0,O0=J0&8191,F0=J0>>>13,A0=N[0]|0,W0=A0&8191,H0=A0>>>13,E0=N[1]|0,T0=E0&8191,D0=E0>>>13,C0=N[2]|0,L0=C0&8191,R0=C0>>>13,P0=N[3]|0,z0=P0&8191,M0=P0>>>13,S0=N[4]|0,v0=S0&8191,q0=S0>>>13,j0=N[5]|0,k0=j0&8191,g0=j0>>>13,N0=N[6]|0,x0=N0&8191,_0=N0>>>13,B0=N[7]|0,y0=B0&8191,w0=B0>>>13,f0=N[8]|0,p0=f0&8191,c0=f0>>>13,h0=N[9]|0,d0=h0&8191,b0=h0>>>13;k.negative=q.negative^j.negative,k.length=19,B=Math.imul(p,W0),y=Math.imul(p,H0),y=y+Math.imul(c,W0)|0,w=Math.imul(c,H0);var l0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(l0>>>26)|0,l0&=67108863,B=Math.imul(d,W0),y=Math.imul(d,H0),y=y+Math.imul(b,W0)|0,w=Math.imul(b,H0),B=B+Math.imul(p,T0)|0,y=y+Math.imul(p,D0)|0,y=y+Math.imul(c,T0)|0,w=w+Math.imul(c,D0)|0;var o0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(o0>>>26)|0,o0&=67108863,B=Math.imul(o,W0),y=Math.imul(o,H0),y=y+Math.imul(u,W0)|0,w=Math.imul(u,H0),B=B+Math.imul(d,T0)|0,y=y+Math.imul(d,D0)|0,y=y+Math.imul(b,T0)|0,w=w+Math.imul(b,D0)|0,B=B+Math.imul(p,L0)|0,y=y+Math.imul(p,R0)|0,y=y+Math.imul(c,L0)|0,w=w+Math.imul(c,R0)|0;var u0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(u0>>>26)|0,u0&=67108863,B=Math.imul(s,W0),y=Math.imul(s,H0),y=y+Math.imul(t,W0)|0,w=Math.imul(t,H0),B=B+Math.imul(o,T0)|0,y=y+Math.imul(o,D0)|0,y=y+Math.imul(u,T0)|0,w=w+Math.imul(u,D0)|0,B=B+Math.imul(d,L0)|0,y=y+Math.imul(d,R0)|0,y=y+Math.imul(b,L0)|0,w=w+Math.imul(b,R0)|0,B=B+Math.imul(p,z0)|0,y=y+Math.imul(p,M0)|0,y=y+Math.imul(c,z0)|0,w=w+Math.imul(c,M0)|0;var n0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(n0>>>26)|0,n0&=67108863,B=Math.imul(a,W0),y=Math.imul(a,H0),y=y+Math.imul(r,W0)|0,w=Math.imul(r,H0),B=B+Math.imul(s,T0)|0,y=y+Math.imul(s,D0)|0,y=y+Math.imul(t,T0)|0,w=w+Math.imul(t,D0)|0,B=B+Math.imul(o,L0)|0,y=y+Math.imul(o,R0)|0,y=y+Math.imul(u,L0)|0,w=w+Math.imul(u,R0)|0,B=B+Math.imul(d,z0)|0,y=y+Math.imul(d,M0)|0,y=y+Math.imul(b,z0)|0,w=w+Math.imul(b,M0)|0,B=B+Math.imul(p,v0)|0,y=y+Math.imul(p,q0)|0,y=y+Math.imul(c,v0)|0,w=w+Math.imul(c,q0)|0;var s0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(s0>>>26)|0,s0&=67108863,B=Math.imul(i,W0),y=Math.imul(i,H0),y=y+Math.imul($0,W0)|0,w=Math.imul($0,H0),B=B+Math.imul(a,T0)|0,y=y+Math.imul(a,D0)|0,y=y+Math.imul(r,T0)|0,w=w+Math.imul(r,D0)|0,B=B+Math.imul(s,L0)|0,y=y+Math.imul(s,R0)|0,y=y+Math.imul(t,L0)|0,w=w+Math.imul(t,R0)|0,B=B+Math.imul(o,z0)|0,y=y+Math.imul(o,M0)|0,y=y+Math.imul(u,z0)|0,w=w+Math.imul(u,M0)|0,B=B+Math.imul(d,v0)|0,y=y+Math.imul(d,q0)|0,y=y+Math.imul(b,v0)|0,w=w+Math.imul(b,q0)|0,B=B+Math.imul(p,k0)|0,y=y+Math.imul(p,g0)|0,y=y+Math.imul(c,k0)|0,w=w+Math.imul(c,g0)|0;var t0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(t0>>>26)|0,t0&=67108863,B=Math.imul(Y0,W0),y=Math.imul(Y0,H0),y=y+Math.imul(Z0,W0)|0,w=Math.imul(Z0,H0),B=B+Math.imul(i,T0)|0,y=y+Math.imul(i,D0)|0,y=y+Math.imul($0,T0)|0,w=w+Math.imul($0,D0)|0,B=B+Math.imul(a,L0)|0,y=y+Math.imul(a,R0)|0,y=y+Math.imul(r,L0)|0,w=w+Math.imul(r,R0)|0,B=B+Math.imul(s,z0)|0,y=y+Math.imul(s,M0)|0,y=y+Math.imul(t,z0)|0,w=w+Math.imul(t,M0)|0,B=B+Math.imul(o,v0)|0,y=y+Math.imul(o,q0)|0,y=y+Math.imul(u,v0)|0,w=w+Math.imul(u,q0)|0,B=B+Math.imul(d,k0)|0,y=y+Math.imul(d,g0)|0,y=y+Math.imul(b,k0)|0,w=w+Math.imul(b,g0)|0,B=B+Math.imul(p,x0)|0,y=y+Math.imul(p,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,_0)|0;var m0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(m0>>>26)|0,m0&=67108863,B=Math.imul(V0,W0),y=Math.imul(V0,H0),y=y+Math.imul(U0,W0)|0,w=Math.imul(U0,H0),B=B+Math.imul(Y0,T0)|0,y=y+Math.imul(Y0,D0)|0,y=y+Math.imul(Z0,T0)|0,w=w+Math.imul(Z0,D0)|0,B=B+Math.imul(i,L0)|0,y=y+Math.imul(i,R0)|0,y=y+Math.imul($0,L0)|0,w=w+Math.imul($0,R0)|0,B=B+Math.imul(a,z0)|0,y=y+Math.imul(a,M0)|0,y=y+Math.imul(r,z0)|0,w=w+Math.imul(r,M0)|0,B=B+Math.imul(s,v0)|0,y=y+Math.imul(s,q0)|0,y=y+Math.imul(t,v0)|0,w=w+Math.imul(t,q0)|0,B=B+Math.imul(o,k0)|0,y=y+Math.imul(o,g0)|0,y=y+Math.imul(u,k0)|0,w=w+Math.imul(u,g0)|0,B=B+Math.imul(d,x0)|0,y=y+Math.imul(d,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,_0)|0,B=B+Math.imul(p,y0)|0,y=y+Math.imul(p,w0)|0,y=y+Math.imul(c,y0)|0,w=w+Math.imul(c,w0)|0;var a0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(a0>>>26)|0,a0&=67108863,B=Math.imul(K0,W0),y=Math.imul(K0,H0),y=y+Math.imul(I0,W0)|0,w=Math.imul(I0,H0),B=B+Math.imul(V0,T0)|0,y=y+Math.imul(V0,D0)|0,y=y+Math.imul(U0,T0)|0,w=w+Math.imul(U0,D0)|0,B=B+Math.imul(Y0,L0)|0,y=y+Math.imul(Y0,R0)|0,y=y+Math.imul(Z0,L0)|0,w=w+Math.imul(Z0,R0)|0,B=B+Math.imul(i,z0)|0,y=y+Math.imul(i,M0)|0,y=y+Math.imul($0,z0)|0,w=w+Math.imul($0,M0)|0,B=B+Math.imul(a,v0)|0,y=y+Math.imul(a,q0)|0,y=y+Math.imul(r,v0)|0,w=w+Math.imul(r,q0)|0,B=B+Math.imul(s,k0)|0,y=y+Math.imul(s,g0)|0,y=y+Math.imul(t,k0)|0,w=w+Math.imul(t,g0)|0,B=B+Math.imul(o,x0)|0,y=y+Math.imul(o,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,_0)|0,B=B+Math.imul(d,y0)|0,y=y+Math.imul(d,w0)|0,y=y+Math.imul(b,y0)|0,w=w+Math.imul(b,w0)|0,B=B+Math.imul(p,p0)|0,y=y+Math.imul(p,c0)|0,y=y+Math.imul(c,p0)|0,w=w+Math.imul(c,c0)|0;var r0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(r0>>>26)|0,r0&=67108863,B=Math.imul(O0,W0),y=Math.imul(O0,H0),y=y+Math.imul(F0,W0)|0,w=Math.imul(F0,H0),B=B+Math.imul(K0,T0)|0,y=y+Math.imul(K0,D0)|0,y=y+Math.imul(I0,T0)|0,w=w+Math.imul(I0,D0)|0,B=B+Math.imul(V0,L0)|0,y=y+Math.imul(V0,R0)|0,y=y+Math.imul(U0,L0)|0,w=w+Math.imul(U0,R0)|0,B=B+Math.imul(Y0,z0)|0,y=y+Math.imul(Y0,M0)|0,y=y+Math.imul(Z0,z0)|0,w=w+Math.imul(Z0,M0)|0,B=B+Math.imul(i,v0)|0,y=y+Math.imul(i,q0)|0,y=y+Math.imul($0,v0)|0,w=w+Math.imul($0,q0)|0,B=B+Math.imul(a,k0)|0,y=y+Math.imul(a,g0)|0,y=y+Math.imul(r,k0)|0,w=w+Math.imul(r,g0)|0,B=B+Math.imul(s,x0)|0,y=y+Math.imul(s,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,_0)|0,B=B+Math.imul(o,y0)|0,y=y+Math.imul(o,w0)|0,y=y+Math.imul(u,y0)|0,w=w+Math.imul(u,w0)|0,B=B+Math.imul(d,p0)|0,y=y+Math.imul(d,c0)|0,y=y+Math.imul(b,p0)|0,w=w+Math.imul(b,c0)|0,B=B+Math.imul(p,d0)|0,y=y+Math.imul(p,b0)|0,y=y+Math.imul(c,d0)|0,w=w+Math.imul(c,b0)|0;var e0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(e0>>>26)|0,e0&=67108863,B=Math.imul(O0,T0),y=Math.imul(O0,D0),y=y+Math.imul(F0,T0)|0,w=Math.imul(F0,D0),B=B+Math.imul(K0,L0)|0,y=y+Math.imul(K0,R0)|0,y=y+Math.imul(I0,L0)|0,w=w+Math.imul(I0,R0)|0,B=B+Math.imul(V0,z0)|0,y=y+Math.imul(V0,M0)|0,y=y+Math.imul(U0,z0)|0,w=w+Math.imul(U0,M0)|0,B=B+Math.imul(Y0,v0)|0,y=y+Math.imul(Y0,q0)|0,y=y+Math.imul(Z0,v0)|0,w=w+Math.imul(Z0,q0)|0,B=B+Math.imul(i,k0)|0,y=y+Math.imul(i,g0)|0,y=y+Math.imul($0,k0)|0,w=w+Math.imul($0,g0)|0,B=B+Math.imul(a,x0)|0,y=y+Math.imul(a,_0)|0,y=y+Math.imul(r,x0)|0,w=w+Math.imul(r,_0)|0,B=B+Math.imul(s,y0)|0,y=y+Math.imul(s,w0)|0,y=y+Math.imul(t,y0)|0,w=w+Math.imul(t,w0)|0,B=B+Math.imul(o,p0)|0,y=y+Math.imul(o,c0)|0,y=y+Math.imul(u,p0)|0,w=w+Math.imul(u,c0)|0,B=B+Math.imul(d,d0)|0,y=y+Math.imul(d,b0)|0,y=y+Math.imul(b,d0)|0,w=w+Math.imul(b,b0)|0;var i0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(i0>>>26)|0,i0&=67108863,B=Math.imul(O0,L0),y=Math.imul(O0,R0),y=y+Math.imul(F0,L0)|0,w=Math.imul(F0,R0),B=B+Math.imul(K0,z0)|0,y=y+Math.imul(K0,M0)|0,y=y+Math.imul(I0,z0)|0,w=w+Math.imul(I0,M0)|0,B=B+Math.imul(V0,v0)|0,y=y+Math.imul(V0,q0)|0,y=y+Math.imul(U0,v0)|0,w=w+Math.imul(U0,q0)|0,B=B+Math.imul(Y0,k0)|0,y=y+Math.imul(Y0,g0)|0,y=y+Math.imul(Z0,k0)|0,w=w+Math.imul(Z0,g0)|0,B=B+Math.imul(i,x0)|0,y=y+Math.imul(i,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,_0)|0,B=B+Math.imul(a,y0)|0,y=y+Math.imul(a,w0)|0,y=y+Math.imul(r,y0)|0,w=w+Math.imul(r,w0)|0,B=B+Math.imul(s,p0)|0,y=y+Math.imul(s,c0)|0,y=y+Math.imul(t,p0)|0,w=w+Math.imul(t,c0)|0,B=B+Math.imul(o,d0)|0,y=y+Math.imul(o,b0)|0,y=y+Math.imul(u,d0)|0,w=w+Math.imul(u,b0)|0;var $$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+($$>>>26)|0,$$&=67108863,B=Math.imul(O0,z0),y=Math.imul(O0,M0),y=y+Math.imul(F0,z0)|0,w=Math.imul(F0,M0),B=B+Math.imul(K0,v0)|0,y=y+Math.imul(K0,q0)|0,y=y+Math.imul(I0,v0)|0,w=w+Math.imul(I0,q0)|0,B=B+Math.imul(V0,k0)|0,y=y+Math.imul(V0,g0)|0,y=y+Math.imul(U0,k0)|0,w=w+Math.imul(U0,g0)|0,B=B+Math.imul(Y0,x0)|0,y=y+Math.imul(Y0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,_0)|0,B=B+Math.imul(i,y0)|0,y=y+Math.imul(i,w0)|0,y=y+Math.imul($0,y0)|0,w=w+Math.imul($0,w0)|0,B=B+Math.imul(a,p0)|0,y=y+Math.imul(a,c0)|0,y=y+Math.imul(r,p0)|0,w=w+Math.imul(r,c0)|0,B=B+Math.imul(s,d0)|0,y=y+Math.imul(s,b0)|0,y=y+Math.imul(t,d0)|0,w=w+Math.imul(t,b0)|0;var Q$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,B=Math.imul(O0,v0),y=Math.imul(O0,q0),y=y+Math.imul(F0,v0)|0,w=Math.imul(F0,q0),B=B+Math.imul(K0,k0)|0,y=y+Math.imul(K0,g0)|0,y=y+Math.imul(I0,k0)|0,w=w+Math.imul(I0,g0)|0,B=B+Math.imul(V0,x0)|0,y=y+Math.imul(V0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,_0)|0,B=B+Math.imul(Y0,y0)|0,y=y+Math.imul(Y0,w0)|0,y=y+Math.imul(Z0,y0)|0,w=w+Math.imul(Z0,w0)|0,B=B+Math.imul(i,p0)|0,y=y+Math.imul(i,c0)|0,y=y+Math.imul($0,p0)|0,w=w+Math.imul($0,c0)|0,B=B+Math.imul(a,d0)|0,y=y+Math.imul(a,b0)|0,y=y+Math.imul(r,d0)|0,w=w+Math.imul(r,b0)|0;var Y$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,B=Math.imul(O0,k0),y=Math.imul(O0,g0),y=y+Math.imul(F0,k0)|0,w=Math.imul(F0,g0),B=B+Math.imul(K0,x0)|0,y=y+Math.imul(K0,_0)|0,y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,_0)|0,B=B+Math.imul(V0,y0)|0,y=y+Math.imul(V0,w0)|0,y=y+Math.imul(U0,y0)|0,w=w+Math.imul(U0,w0)|0,B=B+Math.imul(Y0,p0)|0,y=y+Math.imul(Y0,c0)|0,y=y+Math.imul(Z0,p0)|0,w=w+Math.imul(Z0,c0)|0,B=B+Math.imul(i,d0)|0,y=y+Math.imul(i,b0)|0,y=y+Math.imul($0,d0)|0,w=w+Math.imul($0,b0)|0;var Z$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,B=Math.imul(O0,x0),y=Math.imul(O0,_0),y=y+Math.imul(F0,x0)|0,w=Math.imul(F0,_0),B=B+Math.imul(K0,y0)|0,y=y+Math.imul(K0,w0)|0,y=y+Math.imul(I0,y0)|0,w=w+Math.imul(I0,w0)|0,B=B+Math.imul(V0,p0)|0,y=y+Math.imul(V0,c0)|0,y=y+Math.imul(U0,p0)|0,w=w+Math.imul(U0,c0)|0,B=B+Math.imul(Y0,d0)|0,y=y+Math.imul(Y0,b0)|0,y=y+Math.imul(Z0,d0)|0,w=w+Math.imul(Z0,b0)|0;var G$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(G$>>>26)|0,G$&=67108863,B=Math.imul(O0,y0),y=Math.imul(O0,w0),y=y+Math.imul(F0,y0)|0,w=Math.imul(F0,w0),B=B+Math.imul(K0,p0)|0,y=y+Math.imul(K0,c0)|0,y=y+Math.imul(I0,p0)|0,w=w+Math.imul(I0,c0)|0,B=B+Math.imul(V0,d0)|0,y=y+Math.imul(V0,b0)|0,y=y+Math.imul(U0,d0)|0,w=w+Math.imul(U0,b0)|0;var V$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(V$>>>26)|0,V$&=67108863,B=Math.imul(O0,p0),y=Math.imul(O0,c0),y=y+Math.imul(F0,p0)|0,w=Math.imul(F0,c0),B=B+Math.imul(K0,d0)|0,y=y+Math.imul(K0,b0)|0,y=y+Math.imul(I0,d0)|0,w=w+Math.imul(I0,b0)|0;var U$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(U$>>>26)|0,U$&=67108863,B=Math.imul(O0,d0),y=Math.imul(O0,b0),y=y+Math.imul(F0,d0)|0,w=Math.imul(F0,b0);var X$=(_+B|0)+((y&8191)<<13)|0;return _=(w+(y>>>13)|0)+(X$>>>26)|0,X$&=67108863,x[0]=l0,x[1]=o0,x[2]=u0,x[3]=n0,x[4]=s0,x[5]=t0,x[6]=m0,x[7]=a0,x[8]=r0,x[9]=e0,x[10]=i0,x[11]=$$,x[12]=Q$,x[13]=Y$,x[14]=Z$,x[15]=G$,x[16]=V$,x[17]=U$,x[18]=X$,_!==0&&(x[19]=_,k.length++),k};Math.imul||(H=W);function E(q,j,k){k.negative=j.negative^q.negative,k.length=q.length+j.length;for(var g=0,N=0,x=0;x>>26)|0,N+=_>>>26,_&=67108863}k.words[x]=B,g=_,_=N}return g!==0?k.words[x]=g:k.length--,k.strip()}function T(q,j,k){var g=new D;return g.mulp(q,j,k)}V.prototype.mulTo=function(q,j){var k,g=this.length+q.length;return this.length===10&&q.length===10?k=H(this,q,j):g<63?k=W(this,q,j):g<1024?k=E(this,q,j):k=T(this,q,j),k};function D(q,j){this.x=q,this.y=j}D.prototype.makeRBT=function(q){for(var j=new Array(q),k=V.prototype._countBits(q)-1,g=0;g>=1;return g},D.prototype.permute=function(q,j,k,g,N,x){for(var _=0;_>>1)N++;return 1<>>13,k[2*x+1]=N&8191,N=N>>>13;for(x=2*j;x>=26,j+=g/67108864|0,j+=N>>>26,this.words[k]=N&67108863}return j!==0&&(this.words[k]=j,this.length++),this},V.prototype.muln=function(q){return this.clone().imuln(q)},V.prototype.sqr=function(){return this.mul(this)},V.prototype.isqr=function(){return this.imul(this.clone())},V.prototype.pow=function(q){var j=A(q);if(j.length===0)return new V(1);for(var k=this,g=0;g=0);var j=q%26,k=(q-j)/26,g=67108863>>>26-j<<26-j,N;if(j!==0){var x=0;for(N=0;N>>26-j}x&&(this.words[N]=x,this.length++)}if(k!==0){for(N=this.length-1;N>=0;N--)this.words[N+k]=this.words[N];for(N=0;N=0);var g;j?g=(j-j%26)/26:g=0;var N=q%26,x=Math.min((q-N)/26,this.length),_=67108863^67108863>>>N<x)for(this.length-=x,y=0;y=0&&(w!==0||y>=g);y--){var f=this.words[y]|0;this.words[y]=w<<26-N|f>>>N,w=f&_}return B&&w!==0&&(B.words[B.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},V.prototype.ishrn=function(q,j,k){return Z(this.negative===0),this.iushrn(q,j,k)},V.prototype.shln=function(q){return this.clone().ishln(q)},V.prototype.ushln=function(q){return this.clone().iushln(q)},V.prototype.shrn=function(q){return this.clone().ishrn(q)},V.prototype.ushrn=function(q){return this.clone().iushrn(q)},V.prototype.testn=function(q){Z(typeof q=="number"&&q>=0);var j=q%26,k=(q-j)/26,g=1<=0);var j=q%26,k=(q-j)/26;if(Z(this.negative===0,"imaskn works only with positive numbers"),this.length<=k)return this;if(j!==0&&k++,this.length=Math.min(k,this.length),j!==0){var g=67108863^67108863>>>j<=67108864;j++)this.words[j]-=67108864,j===this.length-1?this.words[j+1]=1:this.words[j+1]++;return this.length=Math.max(this.length,j+1),this},V.prototype.isubn=function(q){if(Z(typeof q=="number"),Z(q<67108864),q<0)return this.iaddn(-q);if(this.negative!==0)return this.negative=0,this.iaddn(q),this.negative=1,this;if(this.words[0]-=q,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var j=0;j>26)-(B/67108864|0),this.words[N+k]=x&67108863}for(;N>26,this.words[N+k]=x&67108863;if(_===0)return this.strip();for(Z(_===-1),_=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},V.prototype._wordDiv=function(q,j){var k=this.length-q.length,g=this.clone(),N=q,x=N.words[N.length-1]|0,_=this._countBits(x);k=26-_,k!==0&&(N=N.ushln(k),g.iushln(k),x=N.words[N.length-1]|0);var B=g.length-N.length,y;if(j!=="mod"){y=new V(null),y.length=B+1,y.words=new Array(y.length);for(var w=0;w=0;p--){var c=(g.words[N.length+p]|0)*67108864+(g.words[N.length+p-1]|0);for(c=Math.min(c/x|0,67108863),g._ishlnsubmul(N,c,p);g.negative!==0;)c--,g.negative=0,g._ishlnsubmul(N,1,p),g.isZero()||(g.negative^=1);y&&(y.words[p]=c)}return y&&y.strip(),g.strip(),j!=="div"&&k!==0&&g.iushrn(k),{div:y||null,mod:g}},V.prototype.divmod=function(q,j,k){if(Z(!q.isZero()),this.isZero())return{div:new V(0),mod:new V(0)};var g,N,x;return this.negative!==0&&q.negative===0?(x=this.neg().divmod(q,j),j!=="mod"&&(g=x.div.neg()),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.iadd(q)),{div:g,mod:N}):this.negative===0&&q.negative!==0?(x=this.divmod(q.neg(),j),j!=="mod"&&(g=x.div.neg()),{div:g,mod:x.mod}):(this.negative&q.negative)!==0?(x=this.neg().divmod(q.neg(),j),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.isub(q)),{div:x.div,mod:N}):q.length>this.length||this.cmp(q)<0?{div:new V(0),mod:this}:q.length===1?j==="div"?{div:this.divn(q.words[0]),mod:null}:j==="mod"?{div:null,mod:new V(this.modn(q.words[0]))}:{div:this.divn(q.words[0]),mod:new V(this.modn(q.words[0]))}:this._wordDiv(q,j)},V.prototype.div=function(q){return this.divmod(q,"div",!1).div},V.prototype.mod=function(q){return this.divmod(q,"mod",!1).mod},V.prototype.umod=function(q){return this.divmod(q,"mod",!0).mod},V.prototype.divRound=function(q){var j=this.divmod(q);if(j.mod.isZero())return j.div;var k=j.div.negative!==0?j.mod.isub(q):j.mod,g=q.ushrn(1),N=q.andln(1),x=k.cmp(g);return x<0||N===1&&x===0?j.div:j.div.negative!==0?j.div.isubn(1):j.div.iaddn(1)},V.prototype.modn=function(q){Z(q<=67108863);for(var j=(1<<26)%q,k=0,g=this.length-1;g>=0;g--)k=(j*k+(this.words[g]|0))%q;return k},V.prototype.idivn=function(q){Z(q<=67108863);for(var j=0,k=this.length-1;k>=0;k--){var g=(this.words[k]|0)+j*67108864;this.words[k]=g/q|0,j=g%q}return this.strip()},V.prototype.divn=function(q){return this.clone().idivn(q)},V.prototype.egcd=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=new V(0),_=new V(1),B=0;j.isEven()&&k.isEven();)j.iushrn(1),k.iushrn(1),++B;for(var y=k.clone(),w=j.clone();!j.isZero();){for(var f=0,p=1;(j.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(j.iushrn(f);f-- >0;)(g.isOdd()||N.isOdd())&&(g.iadd(y),N.isub(w)),g.iushrn(1),N.iushrn(1);for(var c=0,h=1;(k.words[0]&h)===0&&c<26;++c,h<<=1);if(c>0)for(k.iushrn(c);c-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(y),_.isub(w)),x.iushrn(1),_.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(x),N.isub(_)):(k.isub(j),x.isub(g),_.isub(N))}return{a:x,b:_,gcd:k.iushln(B)}},V.prototype._invmp=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=k.clone();j.cmpn(1)>0&&k.cmpn(1)>0;){for(var _=0,B=1;(j.words[0]&B)===0&&_<26;++_,B<<=1);if(_>0)for(j.iushrn(_);_-- >0;)g.isOdd()&&g.iadd(x),g.iushrn(1);for(var y=0,w=1;(k.words[0]&w)===0&&y<26;++y,w<<=1);if(y>0)for(k.iushrn(y);y-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(N)):(k.isub(j),N.isub(g))}var f;return j.cmpn(1)===0?f=g:f=N,f.cmpn(0)<0&&f.iadd(q),f},V.prototype.gcd=function(q){if(this.isZero())return q.abs();if(q.isZero())return this.abs();var j=this.clone(),k=q.clone();j.negative=0,k.negative=0;for(var g=0;j.isEven()&&k.isEven();g++)j.iushrn(1),k.iushrn(1);do{for(;j.isEven();)j.iushrn(1);for(;k.isEven();)k.iushrn(1);var N=j.cmp(k);if(N<0){var x=j;j=k,k=x}else if(N===0||k.cmpn(1)===0)break;j.isub(k)}while(!0);return k.iushln(g)},V.prototype.invm=function(q){return this.egcd(q).a.umod(q)},V.prototype.isEven=function(){return(this.words[0]&1)===0},V.prototype.isOdd=function(){return(this.words[0]&1)===1},V.prototype.andln=function(q){return this.words[0]&q},V.prototype.bincn=function(q){Z(typeof q=="number");var j=q%26,k=(q-j)/26,g=1<>>26,_&=67108863,this.words[x]=_}return N!==0&&(this.words[x]=N,this.length++),this},V.prototype.isZero=function(){return this.length===1&&this.words[0]===0},V.prototype.cmpn=function(q){var j=q<0;if(this.negative!==0&&!j)return-1;if(this.negative===0&&j)return 1;this.strip();var k;if(this.length>1)k=1;else{j&&(q=-q),Z(q<=67108863,"Number is too big");var g=this.words[0]|0;k=g===q?0:gq.length)return 1;if(this.length=0;k--){var g=this.words[k]|0,N=q.words[k]|0;if(g!==N){gN&&(j=1);break}}return j},V.prototype.gtn=function(q){return this.cmpn(q)===1},V.prototype.gt=function(q){return this.cmp(q)===1},V.prototype.gten=function(q){return this.cmpn(q)>=0},V.prototype.gte=function(q){return this.cmp(q)>=0},V.prototype.ltn=function(q){return this.cmpn(q)===-1},V.prototype.lt=function(q){return this.cmp(q)===-1},V.prototype.lten=function(q){return this.cmpn(q)<=0},V.prototype.lte=function(q){return this.cmp(q)<=0},V.prototype.eqn=function(q){return this.cmpn(q)===0},V.prototype.eq=function(q){return this.cmp(q)===0},V.red=function(q){return new S(q)},V.prototype.toRed=function(q){return Z(!this.red,"Already a number in reduction context"),Z(this.negative===0,"red works only with positives"),q.convertTo(this)._forceRed(q)},V.prototype.fromRed=function(){return Z(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},V.prototype._forceRed=function(q){return this.red=q,this},V.prototype.forceRed=function(q){return Z(!this.red,"Already a number in reduction context"),this._forceRed(q)},V.prototype.redAdd=function(q){return Z(this.red,"redAdd works only with red numbers"),this.red.add(this,q)},V.prototype.redIAdd=function(q){return Z(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,q)},V.prototype.redSub=function(q){return Z(this.red,"redSub works only with red numbers"),this.red.sub(this,q)},V.prototype.redISub=function(q){return Z(this.red,"redISub works only with red numbers"),this.red.isub(this,q)},V.prototype.redShl=function(q){return Z(this.red,"redShl works only with red numbers"),this.red.shl(this,q)},V.prototype.redMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.mul(this,q)},V.prototype.redIMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.imul(this,q)},V.prototype.redSqr=function(){return Z(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},V.prototype.redISqr=function(){return Z(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},V.prototype.redSqrt=function(){return Z(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},V.prototype.redInvm=function(){return Z(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},V.prototype.redNeg=function(){return Z(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},V.prototype.redPow=function(q){return Z(this.red&&!q.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,q)};var C={k256:null,p224:null,p192:null,p25519:null};function L(q,j){this.name=q,this.p=new V(j,16),this.n=this.p.bitLength(),this.k=new V(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}L.prototype._tmp=function(){var q=new V(null);return q.words=new Array(Math.ceil(this.n/13)),q},L.prototype.ireduce=function(q){var j=q,k;do this.split(j,this.tmp),j=this.imulK(j),j=j.iadd(this.tmp),k=j.bitLength();while(k>this.n);var g=k0?j.isub(this.p):j.strip!==void 0?j.strip():j._strip(),j},L.prototype.split=function(q,j){q.iushrn(this.n,0,j)},L.prototype.imulK=function(q){return q.imul(this.k)};function R(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}G(R,L),R.prototype.split=function(q,j){for(var k=4194303,g=Math.min(q.length,9),N=0;N>>22,x=_}x>>>=22,q.words[N-10]=x,x===0&&q.length>10?q.length-=10:q.length-=9},R.prototype.imulK=function(q){q.words[q.length]=0,q.words[q.length+1]=0,q.length+=2;for(var j=0,k=0;k>>=26,q.words[k]=N,j=g}return j!==0&&(q.words[q.length++]=j),q},V._prime=function(q){if(C[q])return C[q];var j;if(q==="k256")j=new R;else if(q==="p224")j=new P;else if(q==="p192")j=new z;else if(q==="p25519")j=new M;else throw new Error("Unknown prime "+q);return C[q]=j,j};function S(q){if(typeof q=="string"){var j=V._prime(q);this.m=j.p,this.prime=j}else Z(q.gtn(1),"modulus must be greater than 1"),this.m=q,this.prime=null}S.prototype._verify1=function(q){Z(q.negative===0,"red works only with positives"),Z(q.red,"red works only with red numbers")},S.prototype._verify2=function(q,j){Z((q.negative|j.negative)===0,"red works only with positives"),Z(q.red&&q.red===j.red,"red works only with red numbers")},S.prototype.imod=function(q){return this.prime?this.prime.ireduce(q)._forceRed(this):q.umod(this.m)._forceRed(this)},S.prototype.neg=function(q){return q.isZero()?q.clone():this.m.sub(q)._forceRed(this)},S.prototype.add=function(q,j){this._verify2(q,j);var k=q.add(j);return k.cmp(this.m)>=0&&k.isub(this.m),k._forceRed(this)},S.prototype.iadd=function(q,j){this._verify2(q,j);var k=q.iadd(j);return k.cmp(this.m)>=0&&k.isub(this.m),k},S.prototype.sub=function(q,j){this._verify2(q,j);var k=q.sub(j);return k.cmpn(0)<0&&k.iadd(this.m),k._forceRed(this)},S.prototype.isub=function(q,j){this._verify2(q,j);var k=q.isub(j);return k.cmpn(0)<0&&k.iadd(this.m),k},S.prototype.shl=function(q,j){return this._verify1(q),this.imod(q.ushln(j))},S.prototype.imul=function(q,j){return this._verify2(q,j),this.imod(q.imul(j))},S.prototype.mul=function(q,j){return this._verify2(q,j),this.imod(q.mul(j))},S.prototype.isqr=function(q){return this.imul(q,q.clone())},S.prototype.sqr=function(q){return this.mul(q,q)},S.prototype.sqrt=function(q){if(q.isZero())return q.clone();var j=this.m.andln(3);if(Z(j%2===1),j===3){var k=this.m.add(new V(1)).iushrn(2);return this.pow(q,k)}for(var g=this.m.subn(1),N=0;!g.isZero()&&g.andln(1)===0;)N++,g.iushrn(1);Z(!g.isZero());var x=new V(1).toRed(this),_=x.redNeg(),B=this.m.subn(1).iushrn(1),y=this.m.bitLength();for(y=new V(2*y*y).toRed(this);this.pow(y,B).cmp(_)!==0;)y.redIAdd(_);for(var w=this.pow(y,g),f=this.pow(q,g.addn(1).iushrn(1)),p=this.pow(q,g),c=N;p.cmp(x)!==0;){for(var h=p,d=0;h.cmp(x)!==0;d++)h=h.redSqr();Z(d=0;N--){for(var w=j.words[N],f=y-1;f>=0;f--){var p=w>>f&1;if(x!==g[0]&&(x=this.sqr(x)),p===0&&_===0){B=0;continue}_<<=1,_|=p,B++,!(B!==k&&(N!==0||f!==0))&&(x=this.mul(x,g[_]),B=0,_=0)}y=26}return x},S.prototype.convertTo=function(q){var j=q.umod(this.m);return j===q?j.clone():j},S.prototype.convertFrom=function(q){var j=q.clone();return j.red=null,j},V.mont=function(q){return new v(q)};function v(q){S.call(this,q),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new V(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}G(v,S),v.prototype.convertTo=function(q){return this.imod(q.ushln(this.shift))},v.prototype.convertFrom=function(q){var j=this.imod(q.mul(this.rinv));return j.red=null,j},v.prototype.imul=function(q,j){if(q.isZero()||j.isZero())return q.words[0]=0,q.length=1,q;var k=q.imul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.mul=function(q,j){if(q.isZero()||j.isZero())return new V(0)._forceRed(this);var k=q.mul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.invm=function(q){var j=this.imod(q._invmp(this.m).mul(this.r2));return j._forceRed(this)}})(typeof $>"u"||$,bZ)}}),qQ=P$({"node_modules/miller-rabin/node_modules/bn.js/lib/bn.js"(bZ,$){(function(Q,Y){function Z(q,j){if(!q)throw new Error(j||"Assertion failed")}function G(q,j){q.super_=j;var k=function(){};k.prototype=j.prototype,q.prototype=new k,q.prototype.constructor=q}function V(q,j,k){if(V.isBN(q))return q;this.negative=0,this.words=null,this.length=0,this.red=null,q!==null&&((j==="le"||j==="be")&&(k=j,j=10),this._init(q||0,j||10,k||"be"))}typeof Q=="object"?Q.exports=V:Y.BN=V,V.BN=V,V.wordSize=26;var U;try{typeof window<"u"&&typeof window.Buffer<"u"?U=window.Buffer:U=L$("buffer").Buffer}catch{}V.isBN=function(q){return q instanceof V?!0:q!==null&&typeof q=="object"&&q.constructor.wordSize===V.wordSize&&Array.isArray(q.words)},V.max=function(q,j){return q.cmp(j)>0?q:j},V.min=function(q,j){return q.cmp(j)<0?q:j},V.prototype._init=function(q,j,k){if(typeof q=="number")return this._initNumber(q,j,k);if(typeof q=="object")return this._initArray(q,j,k);j==="hex"&&(j=16),Z(j===(j|0)&&j>=2&&j<=36),q=q.toString().replace(/\s+/g,"");var g=0;q[0]==="-"&&(g++,this.negative=1),g=0;g-=3)x=q[g]|q[g-1]<<8|q[g-2]<<16,this.words[N]|=x<<_&67108863,this.words[N+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);else if(k==="le")for(g=0,N=0;g>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);return this.strip()};function X(q,j){var k=q.charCodeAt(j);return k>=65&&k<=70?k-55:k>=97&&k<=102?k-87:k-48&15}function K(q,j,k){var g=X(q,k);return k-1>=j&&(g|=X(q,k-1)<<4),g}V.prototype._parseHex=function(q,j,k){this.length=Math.ceil((q.length-j)/6),this.words=new Array(this.length);for(var g=0;g=j;g-=2)_=K(q,j,g)<=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8;else{var B=q.length-j;for(g=B%2===0?j+1:j;g=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8}this.strip()};function I(q,j,k,g){for(var N=0,x=Math.min(q.length,k),_=j;_=49?N+=B-49+10:B>=17?N+=B-17+10:N+=B}return N}V.prototype._parseBase=function(q,j,k){this.words=[0],this.length=1;for(var g=0,N=1;N<=67108863;N*=j)g++;g--,N=N/j|0;for(var x=q.length-k,_=x%g,B=Math.min(x,x-_)+k,y=0,w=k;w1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},V.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},V.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],O=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],F=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];V.prototype.toString=function(q,j){q=q||10,j=j|0||1;var k;if(q===16||q==="hex"){k="";for(var g=0,N=0,x=0;x>>24-g&16777215,N!==0||x!==this.length-1?k=J[6-B.length]+B+k:k=B+k,g+=2,g>=26&&(g-=26,x--)}for(N!==0&&(k=N.toString(16)+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}if(q===(q|0)&&q>=2&&q<=36){var y=O[q],w=F[q];k="";var f=this.clone();for(f.negative=0;!f.isZero();){var p=f.modn(w).toString(q);f=f.idivn(w),f.isZero()?k=p+k:k=J[y-p.length]+p+k}for(this.isZero()&&(k="0"+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}Z(!1,"Base should be between 2 and 36")},V.prototype.toNumber=function(){var q=this.words[0];return this.length===2?q+=this.words[1]*67108864:this.length===3&&this.words[2]===1?q+=4503599627370496+this.words[1]*67108864:this.length>2&&Z(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-q:q},V.prototype.toJSON=function(){return this.toString(16)},V.prototype.toBuffer=function(q,j){return Z(typeof U<"u"),this.toArrayLike(U,q,j)},V.prototype.toArray=function(q,j){return this.toArrayLike(Array,q,j)},V.prototype.toArrayLike=function(q,j,k){var g=this.byteLength(),N=k||Math.max(1,g);Z(g<=N,"byte array longer than desired length"),Z(N>0,"Requested array length <= 0"),this.strip();var x=j==="le",_=new q(N),B,y,w=this.clone();if(x){for(y=0;!w.isZero();y++)B=w.andln(255),w.iushrn(8),_[y]=B;for(;y=4096&&(k+=13,j>>>=13),j>=64&&(k+=7,j>>>=7),j>=8&&(k+=4,j>>>=4),j>=2&&(k+=2,j>>>=2),k+j},V.prototype._zeroBits=function(q){if(q===0)return 26;var j=q,k=0;return(j&8191)===0&&(k+=13,j>>>=13),(j&127)===0&&(k+=7,j>>>=7),(j&15)===0&&(k+=4,j>>>=4),(j&3)===0&&(k+=2,j>>>=2),(j&1)===0&&k++,k},V.prototype.bitLength=function(){var q=this.words[this.length-1],j=this._countBits(q);return(this.length-1)*26+j};function A(q){for(var j=new Array(q.bitLength()),k=0;k>>N}return j}V.prototype.zeroBits=function(){if(this.isZero())return 0;for(var q=0,j=0;jq.length?this.clone().ior(q):q.clone().ior(this)},V.prototype.uor=function(q){return this.length>q.length?this.clone().iuor(q):q.clone().iuor(this)},V.prototype.iuand=function(q){var j;this.length>q.length?j=q:j=this;for(var k=0;kq.length?this.clone().iand(q):q.clone().iand(this)},V.prototype.uand=function(q){return this.length>q.length?this.clone().iuand(q):q.clone().iuand(this)},V.prototype.iuxor=function(q){var j,k;this.length>q.length?(j=this,k=q):(j=q,k=this);for(var g=0;gq.length?this.clone().ixor(q):q.clone().ixor(this)},V.prototype.uxor=function(q){return this.length>q.length?this.clone().iuxor(q):q.clone().iuxor(this)},V.prototype.inotn=function(q){Z(typeof q=="number"&&q>=0);var j=Math.ceil(q/26)|0,k=q%26;this._expand(j),k>0&&j--;for(var g=0;g0&&(this.words[g]=~this.words[g]&67108863>>26-k),this.strip()},V.prototype.notn=function(q){return this.clone().inotn(q)},V.prototype.setn=function(q,j){Z(typeof q=="number"&&q>=0);var k=q/26|0,g=q%26;return this._expand(k+1),j?this.words[k]=this.words[k]|1<q.length?(k=this,g=q):(k=q,g=this);for(var N=0,x=0;x>>26;for(;N!==0&&x>>26;if(this.length=k.length,N!==0)this.words[this.length]=N,this.length++;else if(k!==this)for(;xq.length?this.clone().iadd(q):q.clone().iadd(this)},V.prototype.isub=function(q){if(q.negative!==0){q.negative=0;var j=this.iadd(q);return q.negative=1,j._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(q),this.negative=1,this._normSign();var k=this.cmp(q);if(k===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,N;k>0?(g=this,N=q):(g=q,N=this);for(var x=0,_=0;_>26,this.words[_]=j&67108863;for(;x!==0&&_>26,this.words[_]=j&67108863;if(x===0&&_>>26,p=y&67108863,c=Math.min(w,j.length-1),h=Math.max(0,w-q.length+1);h<=c;h++){var d=w-h|0;N=q.words[d]|0,x=j.words[h]|0,_=N*x+p,f+=_/67108864|0,p=_&67108863}k.words[w]=p|0,y=f|0}return y!==0?k.words[w]=y|0:k.length--,k.strip()}var H=function(q,j,k){var g=q.words,N=j.words,x=k.words,_=0,B,y,w,f=g[0]|0,p=f&8191,c=f>>>13,h=g[1]|0,d=h&8191,b=h>>>13,l=g[2]|0,o=l&8191,u=l>>>13,n=g[3]|0,s=n&8191,t=n>>>13,m=g[4]|0,a=m&8191,r=m>>>13,e=g[5]|0,i=e&8191,$0=e>>>13,Q0=g[6]|0,Y0=Q0&8191,Z0=Q0>>>13,G0=g[7]|0,V0=G0&8191,U0=G0>>>13,X0=g[8]|0,K0=X0&8191,I0=X0>>>13,J0=g[9]|0,O0=J0&8191,F0=J0>>>13,A0=N[0]|0,W0=A0&8191,H0=A0>>>13,E0=N[1]|0,T0=E0&8191,D0=E0>>>13,C0=N[2]|0,L0=C0&8191,R0=C0>>>13,P0=N[3]|0,z0=P0&8191,M0=P0>>>13,S0=N[4]|0,v0=S0&8191,q0=S0>>>13,j0=N[5]|0,k0=j0&8191,g0=j0>>>13,N0=N[6]|0,x0=N0&8191,_0=N0>>>13,B0=N[7]|0,y0=B0&8191,w0=B0>>>13,f0=N[8]|0,p0=f0&8191,c0=f0>>>13,h0=N[9]|0,d0=h0&8191,b0=h0>>>13;k.negative=q.negative^j.negative,k.length=19,B=Math.imul(p,W0),y=Math.imul(p,H0),y=y+Math.imul(c,W0)|0,w=Math.imul(c,H0);var l0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(l0>>>26)|0,l0&=67108863,B=Math.imul(d,W0),y=Math.imul(d,H0),y=y+Math.imul(b,W0)|0,w=Math.imul(b,H0),B=B+Math.imul(p,T0)|0,y=y+Math.imul(p,D0)|0,y=y+Math.imul(c,T0)|0,w=w+Math.imul(c,D0)|0;var o0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(o0>>>26)|0,o0&=67108863,B=Math.imul(o,W0),y=Math.imul(o,H0),y=y+Math.imul(u,W0)|0,w=Math.imul(u,H0),B=B+Math.imul(d,T0)|0,y=y+Math.imul(d,D0)|0,y=y+Math.imul(b,T0)|0,w=w+Math.imul(b,D0)|0,B=B+Math.imul(p,L0)|0,y=y+Math.imul(p,R0)|0,y=y+Math.imul(c,L0)|0,w=w+Math.imul(c,R0)|0;var u0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(u0>>>26)|0,u0&=67108863,B=Math.imul(s,W0),y=Math.imul(s,H0),y=y+Math.imul(t,W0)|0,w=Math.imul(t,H0),B=B+Math.imul(o,T0)|0,y=y+Math.imul(o,D0)|0,y=y+Math.imul(u,T0)|0,w=w+Math.imul(u,D0)|0,B=B+Math.imul(d,L0)|0,y=y+Math.imul(d,R0)|0,y=y+Math.imul(b,L0)|0,w=w+Math.imul(b,R0)|0,B=B+Math.imul(p,z0)|0,y=y+Math.imul(p,M0)|0,y=y+Math.imul(c,z0)|0,w=w+Math.imul(c,M0)|0;var n0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(n0>>>26)|0,n0&=67108863,B=Math.imul(a,W0),y=Math.imul(a,H0),y=y+Math.imul(r,W0)|0,w=Math.imul(r,H0),B=B+Math.imul(s,T0)|0,y=y+Math.imul(s,D0)|0,y=y+Math.imul(t,T0)|0,w=w+Math.imul(t,D0)|0,B=B+Math.imul(o,L0)|0,y=y+Math.imul(o,R0)|0,y=y+Math.imul(u,L0)|0,w=w+Math.imul(u,R0)|0,B=B+Math.imul(d,z0)|0,y=y+Math.imul(d,M0)|0,y=y+Math.imul(b,z0)|0,w=w+Math.imul(b,M0)|0,B=B+Math.imul(p,v0)|0,y=y+Math.imul(p,q0)|0,y=y+Math.imul(c,v0)|0,w=w+Math.imul(c,q0)|0;var s0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(s0>>>26)|0,s0&=67108863,B=Math.imul(i,W0),y=Math.imul(i,H0),y=y+Math.imul($0,W0)|0,w=Math.imul($0,H0),B=B+Math.imul(a,T0)|0,y=y+Math.imul(a,D0)|0,y=y+Math.imul(r,T0)|0,w=w+Math.imul(r,D0)|0,B=B+Math.imul(s,L0)|0,y=y+Math.imul(s,R0)|0,y=y+Math.imul(t,L0)|0,w=w+Math.imul(t,R0)|0,B=B+Math.imul(o,z0)|0,y=y+Math.imul(o,M0)|0,y=y+Math.imul(u,z0)|0,w=w+Math.imul(u,M0)|0,B=B+Math.imul(d,v0)|0,y=y+Math.imul(d,q0)|0,y=y+Math.imul(b,v0)|0,w=w+Math.imul(b,q0)|0,B=B+Math.imul(p,k0)|0,y=y+Math.imul(p,g0)|0,y=y+Math.imul(c,k0)|0,w=w+Math.imul(c,g0)|0;var t0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(t0>>>26)|0,t0&=67108863,B=Math.imul(Y0,W0),y=Math.imul(Y0,H0),y=y+Math.imul(Z0,W0)|0,w=Math.imul(Z0,H0),B=B+Math.imul(i,T0)|0,y=y+Math.imul(i,D0)|0,y=y+Math.imul($0,T0)|0,w=w+Math.imul($0,D0)|0,B=B+Math.imul(a,L0)|0,y=y+Math.imul(a,R0)|0,y=y+Math.imul(r,L0)|0,w=w+Math.imul(r,R0)|0,B=B+Math.imul(s,z0)|0,y=y+Math.imul(s,M0)|0,y=y+Math.imul(t,z0)|0,w=w+Math.imul(t,M0)|0,B=B+Math.imul(o,v0)|0,y=y+Math.imul(o,q0)|0,y=y+Math.imul(u,v0)|0,w=w+Math.imul(u,q0)|0,B=B+Math.imul(d,k0)|0,y=y+Math.imul(d,g0)|0,y=y+Math.imul(b,k0)|0,w=w+Math.imul(b,g0)|0,B=B+Math.imul(p,x0)|0,y=y+Math.imul(p,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,_0)|0;var m0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(m0>>>26)|0,m0&=67108863,B=Math.imul(V0,W0),y=Math.imul(V0,H0),y=y+Math.imul(U0,W0)|0,w=Math.imul(U0,H0),B=B+Math.imul(Y0,T0)|0,y=y+Math.imul(Y0,D0)|0,y=y+Math.imul(Z0,T0)|0,w=w+Math.imul(Z0,D0)|0,B=B+Math.imul(i,L0)|0,y=y+Math.imul(i,R0)|0,y=y+Math.imul($0,L0)|0,w=w+Math.imul($0,R0)|0,B=B+Math.imul(a,z0)|0,y=y+Math.imul(a,M0)|0,y=y+Math.imul(r,z0)|0,w=w+Math.imul(r,M0)|0,B=B+Math.imul(s,v0)|0,y=y+Math.imul(s,q0)|0,y=y+Math.imul(t,v0)|0,w=w+Math.imul(t,q0)|0,B=B+Math.imul(o,k0)|0,y=y+Math.imul(o,g0)|0,y=y+Math.imul(u,k0)|0,w=w+Math.imul(u,g0)|0,B=B+Math.imul(d,x0)|0,y=y+Math.imul(d,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,_0)|0,B=B+Math.imul(p,y0)|0,y=y+Math.imul(p,w0)|0,y=y+Math.imul(c,y0)|0,w=w+Math.imul(c,w0)|0;var a0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(a0>>>26)|0,a0&=67108863,B=Math.imul(K0,W0),y=Math.imul(K0,H0),y=y+Math.imul(I0,W0)|0,w=Math.imul(I0,H0),B=B+Math.imul(V0,T0)|0,y=y+Math.imul(V0,D0)|0,y=y+Math.imul(U0,T0)|0,w=w+Math.imul(U0,D0)|0,B=B+Math.imul(Y0,L0)|0,y=y+Math.imul(Y0,R0)|0,y=y+Math.imul(Z0,L0)|0,w=w+Math.imul(Z0,R0)|0,B=B+Math.imul(i,z0)|0,y=y+Math.imul(i,M0)|0,y=y+Math.imul($0,z0)|0,w=w+Math.imul($0,M0)|0,B=B+Math.imul(a,v0)|0,y=y+Math.imul(a,q0)|0,y=y+Math.imul(r,v0)|0,w=w+Math.imul(r,q0)|0,B=B+Math.imul(s,k0)|0,y=y+Math.imul(s,g0)|0,y=y+Math.imul(t,k0)|0,w=w+Math.imul(t,g0)|0,B=B+Math.imul(o,x0)|0,y=y+Math.imul(o,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,_0)|0,B=B+Math.imul(d,y0)|0,y=y+Math.imul(d,w0)|0,y=y+Math.imul(b,y0)|0,w=w+Math.imul(b,w0)|0,B=B+Math.imul(p,p0)|0,y=y+Math.imul(p,c0)|0,y=y+Math.imul(c,p0)|0,w=w+Math.imul(c,c0)|0;var r0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(r0>>>26)|0,r0&=67108863,B=Math.imul(O0,W0),y=Math.imul(O0,H0),y=y+Math.imul(F0,W0)|0,w=Math.imul(F0,H0),B=B+Math.imul(K0,T0)|0,y=y+Math.imul(K0,D0)|0,y=y+Math.imul(I0,T0)|0,w=w+Math.imul(I0,D0)|0,B=B+Math.imul(V0,L0)|0,y=y+Math.imul(V0,R0)|0,y=y+Math.imul(U0,L0)|0,w=w+Math.imul(U0,R0)|0,B=B+Math.imul(Y0,z0)|0,y=y+Math.imul(Y0,M0)|0,y=y+Math.imul(Z0,z0)|0,w=w+Math.imul(Z0,M0)|0,B=B+Math.imul(i,v0)|0,y=y+Math.imul(i,q0)|0,y=y+Math.imul($0,v0)|0,w=w+Math.imul($0,q0)|0,B=B+Math.imul(a,k0)|0,y=y+Math.imul(a,g0)|0,y=y+Math.imul(r,k0)|0,w=w+Math.imul(r,g0)|0,B=B+Math.imul(s,x0)|0,y=y+Math.imul(s,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,_0)|0,B=B+Math.imul(o,y0)|0,y=y+Math.imul(o,w0)|0,y=y+Math.imul(u,y0)|0,w=w+Math.imul(u,w0)|0,B=B+Math.imul(d,p0)|0,y=y+Math.imul(d,c0)|0,y=y+Math.imul(b,p0)|0,w=w+Math.imul(b,c0)|0,B=B+Math.imul(p,d0)|0,y=y+Math.imul(p,b0)|0,y=y+Math.imul(c,d0)|0,w=w+Math.imul(c,b0)|0;var e0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(e0>>>26)|0,e0&=67108863,B=Math.imul(O0,T0),y=Math.imul(O0,D0),y=y+Math.imul(F0,T0)|0,w=Math.imul(F0,D0),B=B+Math.imul(K0,L0)|0,y=y+Math.imul(K0,R0)|0,y=y+Math.imul(I0,L0)|0,w=w+Math.imul(I0,R0)|0,B=B+Math.imul(V0,z0)|0,y=y+Math.imul(V0,M0)|0,y=y+Math.imul(U0,z0)|0,w=w+Math.imul(U0,M0)|0,B=B+Math.imul(Y0,v0)|0,y=y+Math.imul(Y0,q0)|0,y=y+Math.imul(Z0,v0)|0,w=w+Math.imul(Z0,q0)|0,B=B+Math.imul(i,k0)|0,y=y+Math.imul(i,g0)|0,y=y+Math.imul($0,k0)|0,w=w+Math.imul($0,g0)|0,B=B+Math.imul(a,x0)|0,y=y+Math.imul(a,_0)|0,y=y+Math.imul(r,x0)|0,w=w+Math.imul(r,_0)|0,B=B+Math.imul(s,y0)|0,y=y+Math.imul(s,w0)|0,y=y+Math.imul(t,y0)|0,w=w+Math.imul(t,w0)|0,B=B+Math.imul(o,p0)|0,y=y+Math.imul(o,c0)|0,y=y+Math.imul(u,p0)|0,w=w+Math.imul(u,c0)|0,B=B+Math.imul(d,d0)|0,y=y+Math.imul(d,b0)|0,y=y+Math.imul(b,d0)|0,w=w+Math.imul(b,b0)|0;var i0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(i0>>>26)|0,i0&=67108863,B=Math.imul(O0,L0),y=Math.imul(O0,R0),y=y+Math.imul(F0,L0)|0,w=Math.imul(F0,R0),B=B+Math.imul(K0,z0)|0,y=y+Math.imul(K0,M0)|0,y=y+Math.imul(I0,z0)|0,w=w+Math.imul(I0,M0)|0,B=B+Math.imul(V0,v0)|0,y=y+Math.imul(V0,q0)|0,y=y+Math.imul(U0,v0)|0,w=w+Math.imul(U0,q0)|0,B=B+Math.imul(Y0,k0)|0,y=y+Math.imul(Y0,g0)|0,y=y+Math.imul(Z0,k0)|0,w=w+Math.imul(Z0,g0)|0,B=B+Math.imul(i,x0)|0,y=y+Math.imul(i,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,_0)|0,B=B+Math.imul(a,y0)|0,y=y+Math.imul(a,w0)|0,y=y+Math.imul(r,y0)|0,w=w+Math.imul(r,w0)|0,B=B+Math.imul(s,p0)|0,y=y+Math.imul(s,c0)|0,y=y+Math.imul(t,p0)|0,w=w+Math.imul(t,c0)|0,B=B+Math.imul(o,d0)|0,y=y+Math.imul(o,b0)|0,y=y+Math.imul(u,d0)|0,w=w+Math.imul(u,b0)|0;var $$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+($$>>>26)|0,$$&=67108863,B=Math.imul(O0,z0),y=Math.imul(O0,M0),y=y+Math.imul(F0,z0)|0,w=Math.imul(F0,M0),B=B+Math.imul(K0,v0)|0,y=y+Math.imul(K0,q0)|0,y=y+Math.imul(I0,v0)|0,w=w+Math.imul(I0,q0)|0,B=B+Math.imul(V0,k0)|0,y=y+Math.imul(V0,g0)|0,y=y+Math.imul(U0,k0)|0,w=w+Math.imul(U0,g0)|0,B=B+Math.imul(Y0,x0)|0,y=y+Math.imul(Y0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,_0)|0,B=B+Math.imul(i,y0)|0,y=y+Math.imul(i,w0)|0,y=y+Math.imul($0,y0)|0,w=w+Math.imul($0,w0)|0,B=B+Math.imul(a,p0)|0,y=y+Math.imul(a,c0)|0,y=y+Math.imul(r,p0)|0,w=w+Math.imul(r,c0)|0,B=B+Math.imul(s,d0)|0,y=y+Math.imul(s,b0)|0,y=y+Math.imul(t,d0)|0,w=w+Math.imul(t,b0)|0;var Q$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,B=Math.imul(O0,v0),y=Math.imul(O0,q0),y=y+Math.imul(F0,v0)|0,w=Math.imul(F0,q0),B=B+Math.imul(K0,k0)|0,y=y+Math.imul(K0,g0)|0,y=y+Math.imul(I0,k0)|0,w=w+Math.imul(I0,g0)|0,B=B+Math.imul(V0,x0)|0,y=y+Math.imul(V0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,_0)|0,B=B+Math.imul(Y0,y0)|0,y=y+Math.imul(Y0,w0)|0,y=y+Math.imul(Z0,y0)|0,w=w+Math.imul(Z0,w0)|0,B=B+Math.imul(i,p0)|0,y=y+Math.imul(i,c0)|0,y=y+Math.imul($0,p0)|0,w=w+Math.imul($0,c0)|0,B=B+Math.imul(a,d0)|0,y=y+Math.imul(a,b0)|0,y=y+Math.imul(r,d0)|0,w=w+Math.imul(r,b0)|0;var Y$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,B=Math.imul(O0,k0),y=Math.imul(O0,g0),y=y+Math.imul(F0,k0)|0,w=Math.imul(F0,g0),B=B+Math.imul(K0,x0)|0,y=y+Math.imul(K0,_0)|0,y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,_0)|0,B=B+Math.imul(V0,y0)|0,y=y+Math.imul(V0,w0)|0,y=y+Math.imul(U0,y0)|0,w=w+Math.imul(U0,w0)|0,B=B+Math.imul(Y0,p0)|0,y=y+Math.imul(Y0,c0)|0,y=y+Math.imul(Z0,p0)|0,w=w+Math.imul(Z0,c0)|0,B=B+Math.imul(i,d0)|0,y=y+Math.imul(i,b0)|0,y=y+Math.imul($0,d0)|0,w=w+Math.imul($0,b0)|0;var Z$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,B=Math.imul(O0,x0),y=Math.imul(O0,_0),y=y+Math.imul(F0,x0)|0,w=Math.imul(F0,_0),B=B+Math.imul(K0,y0)|0,y=y+Math.imul(K0,w0)|0,y=y+Math.imul(I0,y0)|0,w=w+Math.imul(I0,w0)|0,B=B+Math.imul(V0,p0)|0,y=y+Math.imul(V0,c0)|0,y=y+Math.imul(U0,p0)|0,w=w+Math.imul(U0,c0)|0,B=B+Math.imul(Y0,d0)|0,y=y+Math.imul(Y0,b0)|0,y=y+Math.imul(Z0,d0)|0,w=w+Math.imul(Z0,b0)|0;var G$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(G$>>>26)|0,G$&=67108863,B=Math.imul(O0,y0),y=Math.imul(O0,w0),y=y+Math.imul(F0,y0)|0,w=Math.imul(F0,w0),B=B+Math.imul(K0,p0)|0,y=y+Math.imul(K0,c0)|0,y=y+Math.imul(I0,p0)|0,w=w+Math.imul(I0,c0)|0,B=B+Math.imul(V0,d0)|0,y=y+Math.imul(V0,b0)|0,y=y+Math.imul(U0,d0)|0,w=w+Math.imul(U0,b0)|0;var V$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(V$>>>26)|0,V$&=67108863,B=Math.imul(O0,p0),y=Math.imul(O0,c0),y=y+Math.imul(F0,p0)|0,w=Math.imul(F0,c0),B=B+Math.imul(K0,d0)|0,y=y+Math.imul(K0,b0)|0,y=y+Math.imul(I0,d0)|0,w=w+Math.imul(I0,b0)|0;var U$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(U$>>>26)|0,U$&=67108863,B=Math.imul(O0,d0),y=Math.imul(O0,b0),y=y+Math.imul(F0,d0)|0,w=Math.imul(F0,b0);var X$=(_+B|0)+((y&8191)<<13)|0;return _=(w+(y>>>13)|0)+(X$>>>26)|0,X$&=67108863,x[0]=l0,x[1]=o0,x[2]=u0,x[3]=n0,x[4]=s0,x[5]=t0,x[6]=m0,x[7]=a0,x[8]=r0,x[9]=e0,x[10]=i0,x[11]=$$,x[12]=Q$,x[13]=Y$,x[14]=Z$,x[15]=G$,x[16]=V$,x[17]=U$,x[18]=X$,_!==0&&(x[19]=_,k.length++),k};Math.imul||(H=W);function E(q,j,k){k.negative=j.negative^q.negative,k.length=q.length+j.length;for(var g=0,N=0,x=0;x>>26)|0,N+=_>>>26,_&=67108863}k.words[x]=B,g=_,_=N}return g!==0?k.words[x]=g:k.length--,k.strip()}function T(q,j,k){var g=new D;return g.mulp(q,j,k)}V.prototype.mulTo=function(q,j){var k,g=this.length+q.length;return this.length===10&&q.length===10?k=H(this,q,j):g<63?k=W(this,q,j):g<1024?k=E(this,q,j):k=T(this,q,j),k};function D(q,j){this.x=q,this.y=j}D.prototype.makeRBT=function(q){for(var j=new Array(q),k=V.prototype._countBits(q)-1,g=0;g>=1;return g},D.prototype.permute=function(q,j,k,g,N,x){for(var _=0;_>>1)N++;return 1<>>13,k[2*x+1]=N&8191,N=N>>>13;for(x=2*j;x>=26,j+=g/67108864|0,j+=N>>>26,this.words[k]=N&67108863}return j!==0&&(this.words[k]=j,this.length++),this},V.prototype.muln=function(q){return this.clone().imuln(q)},V.prototype.sqr=function(){return this.mul(this)},V.prototype.isqr=function(){return this.imul(this.clone())},V.prototype.pow=function(q){var j=A(q);if(j.length===0)return new V(1);for(var k=this,g=0;g=0);var j=q%26,k=(q-j)/26,g=67108863>>>26-j<<26-j,N;if(j!==0){var x=0;for(N=0;N>>26-j}x&&(this.words[N]=x,this.length++)}if(k!==0){for(N=this.length-1;N>=0;N--)this.words[N+k]=this.words[N];for(N=0;N=0);var g;j?g=(j-j%26)/26:g=0;var N=q%26,x=Math.min((q-N)/26,this.length),_=67108863^67108863>>>N<x)for(this.length-=x,y=0;y=0&&(w!==0||y>=g);y--){var f=this.words[y]|0;this.words[y]=w<<26-N|f>>>N,w=f&_}return B&&w!==0&&(B.words[B.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},V.prototype.ishrn=function(q,j,k){return Z(this.negative===0),this.iushrn(q,j,k)},V.prototype.shln=function(q){return this.clone().ishln(q)},V.prototype.ushln=function(q){return this.clone().iushln(q)},V.prototype.shrn=function(q){return this.clone().ishrn(q)},V.prototype.ushrn=function(q){return this.clone().iushrn(q)},V.prototype.testn=function(q){Z(typeof q=="number"&&q>=0);var j=q%26,k=(q-j)/26,g=1<=0);var j=q%26,k=(q-j)/26;if(Z(this.negative===0,"imaskn works only with positive numbers"),this.length<=k)return this;if(j!==0&&k++,this.length=Math.min(k,this.length),j!==0){var g=67108863^67108863>>>j<=67108864;j++)this.words[j]-=67108864,j===this.length-1?this.words[j+1]=1:this.words[j+1]++;return this.length=Math.max(this.length,j+1),this},V.prototype.isubn=function(q){if(Z(typeof q=="number"),Z(q<67108864),q<0)return this.iaddn(-q);if(this.negative!==0)return this.negative=0,this.iaddn(q),this.negative=1,this;if(this.words[0]-=q,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var j=0;j>26)-(B/67108864|0),this.words[N+k]=x&67108863}for(;N>26,this.words[N+k]=x&67108863;if(_===0)return this.strip();for(Z(_===-1),_=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},V.prototype._wordDiv=function(q,j){var k=this.length-q.length,g=this.clone(),N=q,x=N.words[N.length-1]|0,_=this._countBits(x);k=26-_,k!==0&&(N=N.ushln(k),g.iushln(k),x=N.words[N.length-1]|0);var B=g.length-N.length,y;if(j!=="mod"){y=new V(null),y.length=B+1,y.words=new Array(y.length);for(var w=0;w=0;p--){var c=(g.words[N.length+p]|0)*67108864+(g.words[N.length+p-1]|0);for(c=Math.min(c/x|0,67108863),g._ishlnsubmul(N,c,p);g.negative!==0;)c--,g.negative=0,g._ishlnsubmul(N,1,p),g.isZero()||(g.negative^=1);y&&(y.words[p]=c)}return y&&y.strip(),g.strip(),j!=="div"&&k!==0&&g.iushrn(k),{div:y||null,mod:g}},V.prototype.divmod=function(q,j,k){if(Z(!q.isZero()),this.isZero())return{div:new V(0),mod:new V(0)};var g,N,x;return this.negative!==0&&q.negative===0?(x=this.neg().divmod(q,j),j!=="mod"&&(g=x.div.neg()),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.iadd(q)),{div:g,mod:N}):this.negative===0&&q.negative!==0?(x=this.divmod(q.neg(),j),j!=="mod"&&(g=x.div.neg()),{div:g,mod:x.mod}):(this.negative&q.negative)!==0?(x=this.neg().divmod(q.neg(),j),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.isub(q)),{div:x.div,mod:N}):q.length>this.length||this.cmp(q)<0?{div:new V(0),mod:this}:q.length===1?j==="div"?{div:this.divn(q.words[0]),mod:null}:j==="mod"?{div:null,mod:new V(this.modn(q.words[0]))}:{div:this.divn(q.words[0]),mod:new V(this.modn(q.words[0]))}:this._wordDiv(q,j)},V.prototype.div=function(q){return this.divmod(q,"div",!1).div},V.prototype.mod=function(q){return this.divmod(q,"mod",!1).mod},V.prototype.umod=function(q){return this.divmod(q,"mod",!0).mod},V.prototype.divRound=function(q){var j=this.divmod(q);if(j.mod.isZero())return j.div;var k=j.div.negative!==0?j.mod.isub(q):j.mod,g=q.ushrn(1),N=q.andln(1),x=k.cmp(g);return x<0||N===1&&x===0?j.div:j.div.negative!==0?j.div.isubn(1):j.div.iaddn(1)},V.prototype.modn=function(q){Z(q<=67108863);for(var j=(1<<26)%q,k=0,g=this.length-1;g>=0;g--)k=(j*k+(this.words[g]|0))%q;return k},V.prototype.idivn=function(q){Z(q<=67108863);for(var j=0,k=this.length-1;k>=0;k--){var g=(this.words[k]|0)+j*67108864;this.words[k]=g/q|0,j=g%q}return this.strip()},V.prototype.divn=function(q){return this.clone().idivn(q)},V.prototype.egcd=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=new V(0),_=new V(1),B=0;j.isEven()&&k.isEven();)j.iushrn(1),k.iushrn(1),++B;for(var y=k.clone(),w=j.clone();!j.isZero();){for(var f=0,p=1;(j.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(j.iushrn(f);f-- >0;)(g.isOdd()||N.isOdd())&&(g.iadd(y),N.isub(w)),g.iushrn(1),N.iushrn(1);for(var c=0,h=1;(k.words[0]&h)===0&&c<26;++c,h<<=1);if(c>0)for(k.iushrn(c);c-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(y),_.isub(w)),x.iushrn(1),_.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(x),N.isub(_)):(k.isub(j),x.isub(g),_.isub(N))}return{a:x,b:_,gcd:k.iushln(B)}},V.prototype._invmp=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=k.clone();j.cmpn(1)>0&&k.cmpn(1)>0;){for(var _=0,B=1;(j.words[0]&B)===0&&_<26;++_,B<<=1);if(_>0)for(j.iushrn(_);_-- >0;)g.isOdd()&&g.iadd(x),g.iushrn(1);for(var y=0,w=1;(k.words[0]&w)===0&&y<26;++y,w<<=1);if(y>0)for(k.iushrn(y);y-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(N)):(k.isub(j),N.isub(g))}var f;return j.cmpn(1)===0?f=g:f=N,f.cmpn(0)<0&&f.iadd(q),f},V.prototype.gcd=function(q){if(this.isZero())return q.abs();if(q.isZero())return this.abs();var j=this.clone(),k=q.clone();j.negative=0,k.negative=0;for(var g=0;j.isEven()&&k.isEven();g++)j.iushrn(1),k.iushrn(1);do{for(;j.isEven();)j.iushrn(1);for(;k.isEven();)k.iushrn(1);var N=j.cmp(k);if(N<0){var x=j;j=k,k=x}else if(N===0||k.cmpn(1)===0)break;j.isub(k)}while(!0);return k.iushln(g)},V.prototype.invm=function(q){return this.egcd(q).a.umod(q)},V.prototype.isEven=function(){return(this.words[0]&1)===0},V.prototype.isOdd=function(){return(this.words[0]&1)===1},V.prototype.andln=function(q){return this.words[0]&q},V.prototype.bincn=function(q){Z(typeof q=="number");var j=q%26,k=(q-j)/26,g=1<>>26,_&=67108863,this.words[x]=_}return N!==0&&(this.words[x]=N,this.length++),this},V.prototype.isZero=function(){return this.length===1&&this.words[0]===0},V.prototype.cmpn=function(q){var j=q<0;if(this.negative!==0&&!j)return-1;if(this.negative===0&&j)return 1;this.strip();var k;if(this.length>1)k=1;else{j&&(q=-q),Z(q<=67108863,"Number is too big");var g=this.words[0]|0;k=g===q?0:gq.length)return 1;if(this.length=0;k--){var g=this.words[k]|0,N=q.words[k]|0;if(g!==N){gN&&(j=1);break}}return j},V.prototype.gtn=function(q){return this.cmpn(q)===1},V.prototype.gt=function(q){return this.cmp(q)===1},V.prototype.gten=function(q){return this.cmpn(q)>=0},V.prototype.gte=function(q){return this.cmp(q)>=0},V.prototype.ltn=function(q){return this.cmpn(q)===-1},V.prototype.lt=function(q){return this.cmp(q)===-1},V.prototype.lten=function(q){return this.cmpn(q)<=0},V.prototype.lte=function(q){return this.cmp(q)<=0},V.prototype.eqn=function(q){return this.cmpn(q)===0},V.prototype.eq=function(q){return this.cmp(q)===0},V.red=function(q){return new S(q)},V.prototype.toRed=function(q){return Z(!this.red,"Already a number in reduction context"),Z(this.negative===0,"red works only with positives"),q.convertTo(this)._forceRed(q)},V.prototype.fromRed=function(){return Z(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},V.prototype._forceRed=function(q){return this.red=q,this},V.prototype.forceRed=function(q){return Z(!this.red,"Already a number in reduction context"),this._forceRed(q)},V.prototype.redAdd=function(q){return Z(this.red,"redAdd works only with red numbers"),this.red.add(this,q)},V.prototype.redIAdd=function(q){return Z(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,q)},V.prototype.redSub=function(q){return Z(this.red,"redSub works only with red numbers"),this.red.sub(this,q)},V.prototype.redISub=function(q){return Z(this.red,"redISub works only with red numbers"),this.red.isub(this,q)},V.prototype.redShl=function(q){return Z(this.red,"redShl works only with red numbers"),this.red.shl(this,q)},V.prototype.redMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.mul(this,q)},V.prototype.redIMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.imul(this,q)},V.prototype.redSqr=function(){return Z(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},V.prototype.redISqr=function(){return Z(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},V.prototype.redSqrt=function(){return Z(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},V.prototype.redInvm=function(){return Z(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},V.prototype.redNeg=function(){return Z(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},V.prototype.redPow=function(q){return Z(this.red&&!q.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,q)};var C={k256:null,p224:null,p192:null,p25519:null};function L(q,j){this.name=q,this.p=new V(j,16),this.n=this.p.bitLength(),this.k=new V(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}L.prototype._tmp=function(){var q=new V(null);return q.words=new Array(Math.ceil(this.n/13)),q},L.prototype.ireduce=function(q){var j=q,k;do this.split(j,this.tmp),j=this.imulK(j),j=j.iadd(this.tmp),k=j.bitLength();while(k>this.n);var g=k0?j.isub(this.p):j.strip!==void 0?j.strip():j._strip(),j},L.prototype.split=function(q,j){q.iushrn(this.n,0,j)},L.prototype.imulK=function(q){return q.imul(this.k)};function R(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}G(R,L),R.prototype.split=function(q,j){for(var k=4194303,g=Math.min(q.length,9),N=0;N>>22,x=_}x>>>=22,q.words[N-10]=x,x===0&&q.length>10?q.length-=10:q.length-=9},R.prototype.imulK=function(q){q.words[q.length]=0,q.words[q.length+1]=0,q.length+=2;for(var j=0,k=0;k>>=26,q.words[k]=N,j=g}return j!==0&&(q.words[q.length++]=j),q},V._prime=function(q){if(C[q])return C[q];var j;if(q==="k256")j=new R;else if(q==="p224")j=new P;else if(q==="p192")j=new z;else if(q==="p25519")j=new M;else throw new Error("Unknown prime "+q);return C[q]=j,j};function S(q){if(typeof q=="string"){var j=V._prime(q);this.m=j.p,this.prime=j}else Z(q.gtn(1),"modulus must be greater than 1"),this.m=q,this.prime=null}S.prototype._verify1=function(q){Z(q.negative===0,"red works only with positives"),Z(q.red,"red works only with red numbers")},S.prototype._verify2=function(q,j){Z((q.negative|j.negative)===0,"red works only with positives"),Z(q.red&&q.red===j.red,"red works only with red numbers")},S.prototype.imod=function(q){return this.prime?this.prime.ireduce(q)._forceRed(this):q.umod(this.m)._forceRed(this)},S.prototype.neg=function(q){return q.isZero()?q.clone():this.m.sub(q)._forceRed(this)},S.prototype.add=function(q,j){this._verify2(q,j);var k=q.add(j);return k.cmp(this.m)>=0&&k.isub(this.m),k._forceRed(this)},S.prototype.iadd=function(q,j){this._verify2(q,j);var k=q.iadd(j);return k.cmp(this.m)>=0&&k.isub(this.m),k},S.prototype.sub=function(q,j){this._verify2(q,j);var k=q.sub(j);return k.cmpn(0)<0&&k.iadd(this.m),k._forceRed(this)},S.prototype.isub=function(q,j){this._verify2(q,j);var k=q.isub(j);return k.cmpn(0)<0&&k.iadd(this.m),k},S.prototype.shl=function(q,j){return this._verify1(q),this.imod(q.ushln(j))},S.prototype.imul=function(q,j){return this._verify2(q,j),this.imod(q.imul(j))},S.prototype.mul=function(q,j){return this._verify2(q,j),this.imod(q.mul(j))},S.prototype.isqr=function(q){return this.imul(q,q.clone())},S.prototype.sqr=function(q){return this.mul(q,q)},S.prototype.sqrt=function(q){if(q.isZero())return q.clone();var j=this.m.andln(3);if(Z(j%2===1),j===3){var k=this.m.add(new V(1)).iushrn(2);return this.pow(q,k)}for(var g=this.m.subn(1),N=0;!g.isZero()&&g.andln(1)===0;)N++,g.iushrn(1);Z(!g.isZero());var x=new V(1).toRed(this),_=x.redNeg(),B=this.m.subn(1).iushrn(1),y=this.m.bitLength();for(y=new V(2*y*y).toRed(this);this.pow(y,B).cmp(_)!==0;)y.redIAdd(_);for(var w=this.pow(y,g),f=this.pow(q,g.addn(1).iushrn(1)),p=this.pow(q,g),c=N;p.cmp(x)!==0;){for(var h=p,d=0;h.cmp(x)!==0;d++)h=h.redSqr();Z(d=0;N--){for(var w=j.words[N],f=y-1;f>=0;f--){var p=w>>f&1;if(x!==g[0]&&(x=this.sqr(x)),p===0&&_===0){B=0;continue}_<<=1,_|=p,B++,!(B!==k&&(N!==0||f!==0))&&(x=this.mul(x,g[_]),B=0,_=0)}y=26}return x},S.prototype.convertTo=function(q){var j=q.umod(this.m);return j===q?j.clone():j},S.prototype.convertFrom=function(q){var j=q.clone();return j.red=null,j},V.mont=function(q){return new v(q)};function v(q){S.call(this,q),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new V(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}G(v,S),v.prototype.convertTo=function(q){return this.imod(q.ushln(this.shift))},v.prototype.convertFrom=function(q){var j=this.imod(q.mul(this.rinv));return j.red=null,j},v.prototype.imul=function(q,j){if(q.isZero()||j.isZero())return q.words[0]=0,q.length=1,q;var k=q.imul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.mul=function(q,j){if(q.isZero()||j.isZero())return new V(0)._forceRed(this);var k=q.mul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.invm=function(q){var j=this.imod(q._invmp(this.m).mul(this.r2));return j._forceRed(this)}})(typeof $>"u"||$,bZ)}}),jQ=P$({"(disabled):node_modules/crypto-browserify/index.js"(){}}),kQ=P$({"node_modules/brorand/index.js"(bZ,$){var Q;$.exports=function(Z){return Q||(Q=new Y(null)),Q.generate(Z)};function Y(Z){this.rand=Z}$.exports.Rand=Y,Y.prototype.generate=function(Z){return this._rand(Z)},Y.prototype._rand=function(Z){var G=new Buffer(Z);return O$.getRandomValues(G),G}}}),gQ=P$({"node_modules/miller-rabin/lib/mr.js"(bZ,$){var Q=qQ(),Y=kQ();function Z(G){this.rand=G||new Y.Rand}$.exports=Z,Z.create=function(G){return new Z(G)},Z.prototype._randbelow=function(G){var V=G.bitLength(),U=Math.ceil(V/8);do var X=new Q(this.rand.generate(U));while(X.cmp(G)>=0);return X},Z.prototype._randrange=function(G,V){var U=V.sub(G);return G.add(this._randbelow(U))},Z.prototype.test=function(G,V,U){var X=G.bitLength(),K=Q.mont(G),I=new Q(1).toRed(K);V||(V=Math.max(1,X/48|0));for(var J=G.subn(1),O=0;!J.testn(O);O++);for(var F=G.shrn(O),A=J.toRed(K),W=!0;V>0;V--){var H=this._randrange(new Q(2),J);U&&U(H);var E=H.toRed(K).redPow(F);if(!(E.cmp(I)===0||E.cmp(A)===0)){for(var T=1;T0;V--){var A=this._randrange(new Q(2),I),W=G.gcd(A);if(W.cmpn(1)!==0)return W;var H=A.toRed(X).redPow(O);if(!(H.cmp(K)===0||H.cmp(F)===0)){for(var E=1;EP;)M.ishrn(1);if(M.isEven()&&M.iadd(U),M.testn(1)||M.iadd(X),z.cmp(X)){if(!z.cmp(K))for(;M.mod(O).cmp(F);)M.iadd(H)}else for(;M.mod(Z).cmp(W);)M.iadd(H);if(S=M.shrn(1),C(S)&&C(M)&&L(S)&&L(M)&&V.test(S)&&V.test(M))return M}}}}),xQ=P$({"node_modules/diffie-hellman/lib/primes.json"(bZ,$){$.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}}}),_Q=P$({"node_modules/diffie-hellman/lib/dh.js"(bZ,$){var Q=vQ(),Y=gQ(),Z=new Y,G=new Q(24),V=new Q(11),U=new Q(10),X=new Q(3),K=new Q(7),I=NQ(),J=S$();$.exports=H;function O(T,D){return D=D||"utf8",Buffer.isBuffer(T)||(T=new Buffer(T,D)),this._pub=new Q(T),this}function F(T,D){return D=D||"utf8",Buffer.isBuffer(T)||(T=new Buffer(T,D)),this._priv=new Q(T),this}var A={};function W(T,D){var C=D.toString("hex"),L=[C,T.toString(16)].join("_");if(L in A)return A[L];var R=0;if(T.isEven()||!I.simpleSieve||!I.fermatTest(T)||!Z.test(T))return R+=1,C==="02"||C==="05"?R+=8:R+=4,A[L]=R,R;Z.test(T.shrn(1))||(R+=2);var P;switch(C){case"02":T.mod(G).cmp(V)&&(R+=8);break;case"05":P=T.mod(U),P.cmp(X)&&P.cmp(K)&&(R+=8);break;default:R+=4}return A[L]=R,R}function H(T,D,C){this.setGenerator(D),this.__prime=new Q(T),this._prime=Q.mont(this.__prime),this._primeLen=T.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,C?(this.setPublicKey=O,this.setPrivateKey=F):this._primeCode=8}Object.defineProperty(H.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=W(this.__prime,this.__gen)),this._primeCode}}),H.prototype.generateKeys=function(){return this._priv||(this._priv=new Q(J(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},H.prototype.computeSecret=function(T){T=new Q(T),T=T.toRed(this._prime);var D=T.redPow(this._priv).fromRed(),C=new Buffer(D.toArray()),L=this.getPrime();if(C.length0?g:N},V.min=function(g,N){return g.cmp(N)<0?g:N},V.prototype._init=function(g,N,x){if(typeof g=="number")return this._initNumber(g,N,x);if(typeof g=="object")return this._initArray(g,N,x);N==="hex"&&(N=16),Z(N===(N|0)&&N>=2&&N<=36),g=g.toString().replace(/\s+/g,"");var _=0;g[0]==="-"&&(_++,this.negative=1),_=0;_-=3)y=g[_]|g[_-1]<<8|g[_-2]<<16,this.words[B]|=y<>>26-w&67108863,w+=24,w>=26&&(w-=26,B++);else if(x==="le")for(_=0,B=0;_>>26-w&67108863,w+=24,w>=26&&(w-=26,B++);return this._strip()};function X(g,N){var x=g.charCodeAt(N);if(x>=48&&x<=57)return x-48;if(x>=65&&x<=70)return x-55;if(x>=97&&x<=102)return x-87;Z(!1,"Invalid character in "+g)}function K(g,N,x){var _=X(g,x);return x-1>=N&&(_|=X(g,x-1)<<4),_}V.prototype._parseHex=function(g,N,x){this.length=Math.ceil((g.length-N)/6),this.words=new Array(this.length);for(var _=0;_=N;_-=2)w=K(g,N,_)<=18?(B-=18,y+=1,this.words[y]|=w>>>26):B+=8;else{var f=g.length-N;for(_=f%2===0?N+1:N;_=18?(B-=18,y+=1,this.words[y]|=w>>>26):B+=8}this._strip()};function I(g,N,x,_){for(var B=0,y=0,w=Math.min(g.length,x),f=N;f=49?y=p-49+10:p>=17?y=p-17+10:y=p,Z(p>=0&&y<_,"Invalid character"),B+=y}return B}V.prototype._parseBase=function(g,N,x){this.words=[0],this.length=1;for(var _=0,B=1;B<=67108863;B*=N)_++;_--,B=B/N|0;for(var y=g.length-x,w=y%_,f=Math.min(y,y-w)+x,p=0,c=x;c1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},V.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{V.prototype[Symbol.for("nodejs.util.inspect.custom")]=O}catch{V.prototype.inspect=O}else V.prototype.inspect=O;function O(){return(this.red?""}var F=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],A=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],W=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];V.prototype.toString=function(g,N){g=g||10,N=N|0||1;var x;if(g===16||g==="hex"){x="";for(var _=0,B=0,y=0;y>>24-_&16777215,_+=2,_>=26&&(_-=26,y--),B!==0||y!==this.length-1?x=F[6-f.length]+f+x:x=f+x}for(B!==0&&(x=B.toString(16)+x);x.length%N!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}if(g===(g|0)&&g>=2&&g<=36){var p=A[g],c=W[g];x="";var h=this.clone();for(h.negative=0;!h.isZero();){var d=h.modrn(c).toString(g);h=h.idivn(c),h.isZero()?x=d+x:x=F[p-d.length]+d+x}for(this.isZero()&&(x="0"+x);x.length%N!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}Z(!1,"Base should be between 2 and 36")},V.prototype.toNumber=function(){var g=this.words[0];return this.length===2?g+=this.words[1]*67108864:this.length===3&&this.words[2]===1?g+=4503599627370496+this.words[1]*67108864:this.length>2&&Z(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-g:g},V.prototype.toJSON=function(){return this.toString(16,2)},U&&(V.prototype.toBuffer=function(g,N){return this.toArrayLike(U,g,N)}),V.prototype.toArray=function(g,N){return this.toArrayLike(Array,g,N)};var H=function(g,N){return g.allocUnsafe?g.allocUnsafe(N):new g(N)};V.prototype.toArrayLike=function(g,N,x){this._strip();var _=this.byteLength(),B=x||Math.max(1,_);Z(_<=B,"byte array longer than desired length"),Z(B>0,"Requested array length <= 0");var y=H(g,B),w=N==="le"?"LE":"BE";return this["_toArrayLike"+w](y,_),y},V.prototype._toArrayLikeLE=function(g,N){for(var x=0,_=0,B=0,y=0;B>8&255),x>16&255),y===6?(x>24&255),_=0,y=0):(_=w>>>24,y+=2)}if(x=0&&(g[x--]=w>>8&255),x>=0&&(g[x--]=w>>16&255),y===6?(x>=0&&(g[x--]=w>>24&255),_=0,y=0):(_=w>>>24,y+=2)}if(x>=0)for(g[x--]=_;x>=0;)g[x--]=0},Math.clz32?V.prototype._countBits=function(g){return 32-Math.clz32(g)}:V.prototype._countBits=function(g){var N=g,x=0;return N>=4096&&(x+=13,N>>>=13),N>=64&&(x+=7,N>>>=7),N>=8&&(x+=4,N>>>=4),N>=2&&(x+=2,N>>>=2),x+N},V.prototype._zeroBits=function(g){if(g===0)return 26;var N=g,x=0;return(N&8191)===0&&(x+=13,N>>>=13),(N&127)===0&&(x+=7,N>>>=7),(N&15)===0&&(x+=4,N>>>=4),(N&3)===0&&(x+=2,N>>>=2),(N&1)===0&&x++,x},V.prototype.bitLength=function(){var g=this.words[this.length-1],N=this._countBits(g);return(this.length-1)*26+N};function E(g){for(var N=new Array(g.bitLength()),x=0;x>>B&1}return N}V.prototype.zeroBits=function(){if(this.isZero())return 0;for(var g=0,N=0;Ng.length?this.clone().ior(g):g.clone().ior(this)},V.prototype.uor=function(g){return this.length>g.length?this.clone().iuor(g):g.clone().iuor(this)},V.prototype.iuand=function(g){var N;this.length>g.length?N=g:N=this;for(var x=0;xg.length?this.clone().iand(g):g.clone().iand(this)},V.prototype.uand=function(g){return this.length>g.length?this.clone().iuand(g):g.clone().iuand(this)},V.prototype.iuxor=function(g){var N,x;this.length>g.length?(N=this,x=g):(N=g,x=this);for(var _=0;_g.length?this.clone().ixor(g):g.clone().ixor(this)},V.prototype.uxor=function(g){return this.length>g.length?this.clone().iuxor(g):g.clone().iuxor(this)},V.prototype.inotn=function(g){Z(typeof g=="number"&&g>=0);var N=Math.ceil(g/26)|0,x=g%26;this._expand(N),x>0&&N--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-x),this._strip()},V.prototype.notn=function(g){return this.clone().inotn(g)},V.prototype.setn=function(g,N){Z(typeof g=="number"&&g>=0);var x=g/26|0,_=g%26;return this._expand(x+1),N?this.words[x]=this.words[x]|1<<_:this.words[x]=this.words[x]&~(1<<_),this._strip()},V.prototype.iadd=function(g){var N;if(this.negative!==0&&g.negative===0)return this.negative=0,N=this.isub(g),this.negative^=1,this._normSign();if(this.negative===0&&g.negative!==0)return g.negative=0,N=this.isub(g),g.negative=1,N._normSign();var x,_;this.length>g.length?(x=this,_=g):(x=g,_=this);for(var B=0,y=0;y<_.length;y++)N=(x.words[y]|0)+(_.words[y]|0)+B,this.words[y]=N&67108863,B=N>>>26;for(;B!==0&&y>>26;if(this.length=x.length,B!==0)this.words[this.length]=B,this.length++;else if(x!==this)for(;yg.length?this.clone().iadd(g):g.clone().iadd(this)},V.prototype.isub=function(g){if(g.negative!==0){g.negative=0;var N=this.iadd(g);return g.negative=1,N._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(g),this.negative=1,this._normSign();var x=this.cmp(g);if(x===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,B;x>0?(_=this,B=g):(_=g,B=this);for(var y=0,w=0;w>26,this.words[w]=N&67108863;for(;y!==0&&w<_.length;w++)N=(_.words[w]|0)+y,y=N>>26,this.words[w]=N&67108863;if(y===0&&w<_.length&&_!==this)for(;w<_.length;w++)this.words[w]=_.words[w];return this.length=Math.max(this.length,w),_!==this&&(this.negative=1),this._strip()},V.prototype.sub=function(g){return this.clone().isub(g)};function T(g,N,x){x.negative=N.negative^g.negative;var _=g.length+N.length|0;x.length=_,_=_-1|0;var B=g.words[0]|0,y=N.words[0]|0,w=B*y,f=w&67108863,p=w/67108864|0;x.words[0]=f;for(var c=1;c<_;c++){for(var h=p>>>26,d=p&67108863,b=Math.min(c,N.length-1),l=Math.max(0,c-g.length+1);l<=b;l++){var o=c-l|0;B=g.words[o]|0,y=N.words[l]|0,w=B*y+d,h+=w/67108864|0,d=w&67108863}x.words[c]=d|0,p=h|0}return p!==0?x.words[c]=p|0:x.length--,x._strip()}var D=function(g,N,x){var _=g.words,B=N.words,y=x.words,w=0,f,p,c,h=_[0]|0,d=h&8191,b=h>>>13,l=_[1]|0,o=l&8191,u=l>>>13,n=_[2]|0,s=n&8191,t=n>>>13,m=_[3]|0,a=m&8191,r=m>>>13,e=_[4]|0,i=e&8191,$0=e>>>13,Q0=_[5]|0,Y0=Q0&8191,Z0=Q0>>>13,G0=_[6]|0,V0=G0&8191,U0=G0>>>13,X0=_[7]|0,K0=X0&8191,I0=X0>>>13,J0=_[8]|0,O0=J0&8191,F0=J0>>>13,A0=_[9]|0,W0=A0&8191,H0=A0>>>13,E0=B[0]|0,T0=E0&8191,D0=E0>>>13,C0=B[1]|0,L0=C0&8191,R0=C0>>>13,P0=B[2]|0,z0=P0&8191,M0=P0>>>13,S0=B[3]|0,v0=S0&8191,q0=S0>>>13,j0=B[4]|0,k0=j0&8191,g0=j0>>>13,N0=B[5]|0,x0=N0&8191,_0=N0>>>13,B0=B[6]|0,y0=B0&8191,w0=B0>>>13,f0=B[7]|0,p0=f0&8191,c0=f0>>>13,h0=B[8]|0,d0=h0&8191,b0=h0>>>13,l0=B[9]|0,o0=l0&8191,u0=l0>>>13;x.negative=g.negative^N.negative,x.length=19,f=Math.imul(d,T0),p=Math.imul(d,D0),p=p+Math.imul(b,T0)|0,c=Math.imul(b,D0);var n0=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(n0>>>26)|0,n0&=67108863,f=Math.imul(o,T0),p=Math.imul(o,D0),p=p+Math.imul(u,T0)|0,c=Math.imul(u,D0),f=f+Math.imul(d,L0)|0,p=p+Math.imul(d,R0)|0,p=p+Math.imul(b,L0)|0,c=c+Math.imul(b,R0)|0;var s0=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(s0>>>26)|0,s0&=67108863,f=Math.imul(s,T0),p=Math.imul(s,D0),p=p+Math.imul(t,T0)|0,c=Math.imul(t,D0),f=f+Math.imul(o,L0)|0,p=p+Math.imul(o,R0)|0,p=p+Math.imul(u,L0)|0,c=c+Math.imul(u,R0)|0,f=f+Math.imul(d,z0)|0,p=p+Math.imul(d,M0)|0,p=p+Math.imul(b,z0)|0,c=c+Math.imul(b,M0)|0;var t0=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(t0>>>26)|0,t0&=67108863,f=Math.imul(a,T0),p=Math.imul(a,D0),p=p+Math.imul(r,T0)|0,c=Math.imul(r,D0),f=f+Math.imul(s,L0)|0,p=p+Math.imul(s,R0)|0,p=p+Math.imul(t,L0)|0,c=c+Math.imul(t,R0)|0,f=f+Math.imul(o,z0)|0,p=p+Math.imul(o,M0)|0,p=p+Math.imul(u,z0)|0,c=c+Math.imul(u,M0)|0,f=f+Math.imul(d,v0)|0,p=p+Math.imul(d,q0)|0,p=p+Math.imul(b,v0)|0,c=c+Math.imul(b,q0)|0;var m0=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(m0>>>26)|0,m0&=67108863,f=Math.imul(i,T0),p=Math.imul(i,D0),p=p+Math.imul($0,T0)|0,c=Math.imul($0,D0),f=f+Math.imul(a,L0)|0,p=p+Math.imul(a,R0)|0,p=p+Math.imul(r,L0)|0,c=c+Math.imul(r,R0)|0,f=f+Math.imul(s,z0)|0,p=p+Math.imul(s,M0)|0,p=p+Math.imul(t,z0)|0,c=c+Math.imul(t,M0)|0,f=f+Math.imul(o,v0)|0,p=p+Math.imul(o,q0)|0,p=p+Math.imul(u,v0)|0,c=c+Math.imul(u,q0)|0,f=f+Math.imul(d,k0)|0,p=p+Math.imul(d,g0)|0,p=p+Math.imul(b,k0)|0,c=c+Math.imul(b,g0)|0;var a0=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(a0>>>26)|0,a0&=67108863,f=Math.imul(Y0,T0),p=Math.imul(Y0,D0),p=p+Math.imul(Z0,T0)|0,c=Math.imul(Z0,D0),f=f+Math.imul(i,L0)|0,p=p+Math.imul(i,R0)|0,p=p+Math.imul($0,L0)|0,c=c+Math.imul($0,R0)|0,f=f+Math.imul(a,z0)|0,p=p+Math.imul(a,M0)|0,p=p+Math.imul(r,z0)|0,c=c+Math.imul(r,M0)|0,f=f+Math.imul(s,v0)|0,p=p+Math.imul(s,q0)|0,p=p+Math.imul(t,v0)|0,c=c+Math.imul(t,q0)|0,f=f+Math.imul(o,k0)|0,p=p+Math.imul(o,g0)|0,p=p+Math.imul(u,k0)|0,c=c+Math.imul(u,g0)|0,f=f+Math.imul(d,x0)|0,p=p+Math.imul(d,_0)|0,p=p+Math.imul(b,x0)|0,c=c+Math.imul(b,_0)|0;var r0=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(r0>>>26)|0,r0&=67108863,f=Math.imul(V0,T0),p=Math.imul(V0,D0),p=p+Math.imul(U0,T0)|0,c=Math.imul(U0,D0),f=f+Math.imul(Y0,L0)|0,p=p+Math.imul(Y0,R0)|0,p=p+Math.imul(Z0,L0)|0,c=c+Math.imul(Z0,R0)|0,f=f+Math.imul(i,z0)|0,p=p+Math.imul(i,M0)|0,p=p+Math.imul($0,z0)|0,c=c+Math.imul($0,M0)|0,f=f+Math.imul(a,v0)|0,p=p+Math.imul(a,q0)|0,p=p+Math.imul(r,v0)|0,c=c+Math.imul(r,q0)|0,f=f+Math.imul(s,k0)|0,p=p+Math.imul(s,g0)|0,p=p+Math.imul(t,k0)|0,c=c+Math.imul(t,g0)|0,f=f+Math.imul(o,x0)|0,p=p+Math.imul(o,_0)|0,p=p+Math.imul(u,x0)|0,c=c+Math.imul(u,_0)|0,f=f+Math.imul(d,y0)|0,p=p+Math.imul(d,w0)|0,p=p+Math.imul(b,y0)|0,c=c+Math.imul(b,w0)|0;var e0=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(e0>>>26)|0,e0&=67108863,f=Math.imul(K0,T0),p=Math.imul(K0,D0),p=p+Math.imul(I0,T0)|0,c=Math.imul(I0,D0),f=f+Math.imul(V0,L0)|0,p=p+Math.imul(V0,R0)|0,p=p+Math.imul(U0,L0)|0,c=c+Math.imul(U0,R0)|0,f=f+Math.imul(Y0,z0)|0,p=p+Math.imul(Y0,M0)|0,p=p+Math.imul(Z0,z0)|0,c=c+Math.imul(Z0,M0)|0,f=f+Math.imul(i,v0)|0,p=p+Math.imul(i,q0)|0,p=p+Math.imul($0,v0)|0,c=c+Math.imul($0,q0)|0,f=f+Math.imul(a,k0)|0,p=p+Math.imul(a,g0)|0,p=p+Math.imul(r,k0)|0,c=c+Math.imul(r,g0)|0,f=f+Math.imul(s,x0)|0,p=p+Math.imul(s,_0)|0,p=p+Math.imul(t,x0)|0,c=c+Math.imul(t,_0)|0,f=f+Math.imul(o,y0)|0,p=p+Math.imul(o,w0)|0,p=p+Math.imul(u,y0)|0,c=c+Math.imul(u,w0)|0,f=f+Math.imul(d,p0)|0,p=p+Math.imul(d,c0)|0,p=p+Math.imul(b,p0)|0,c=c+Math.imul(b,c0)|0;var i0=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(i0>>>26)|0,i0&=67108863,f=Math.imul(O0,T0),p=Math.imul(O0,D0),p=p+Math.imul(F0,T0)|0,c=Math.imul(F0,D0),f=f+Math.imul(K0,L0)|0,p=p+Math.imul(K0,R0)|0,p=p+Math.imul(I0,L0)|0,c=c+Math.imul(I0,R0)|0,f=f+Math.imul(V0,z0)|0,p=p+Math.imul(V0,M0)|0,p=p+Math.imul(U0,z0)|0,c=c+Math.imul(U0,M0)|0,f=f+Math.imul(Y0,v0)|0,p=p+Math.imul(Y0,q0)|0,p=p+Math.imul(Z0,v0)|0,c=c+Math.imul(Z0,q0)|0,f=f+Math.imul(i,k0)|0,p=p+Math.imul(i,g0)|0,p=p+Math.imul($0,k0)|0,c=c+Math.imul($0,g0)|0,f=f+Math.imul(a,x0)|0,p=p+Math.imul(a,_0)|0,p=p+Math.imul(r,x0)|0,c=c+Math.imul(r,_0)|0,f=f+Math.imul(s,y0)|0,p=p+Math.imul(s,w0)|0,p=p+Math.imul(t,y0)|0,c=c+Math.imul(t,w0)|0,f=f+Math.imul(o,p0)|0,p=p+Math.imul(o,c0)|0,p=p+Math.imul(u,p0)|0,c=c+Math.imul(u,c0)|0,f=f+Math.imul(d,d0)|0,p=p+Math.imul(d,b0)|0,p=p+Math.imul(b,d0)|0,c=c+Math.imul(b,b0)|0;var $$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+($$>>>26)|0,$$&=67108863,f=Math.imul(W0,T0),p=Math.imul(W0,D0),p=p+Math.imul(H0,T0)|0,c=Math.imul(H0,D0),f=f+Math.imul(O0,L0)|0,p=p+Math.imul(O0,R0)|0,p=p+Math.imul(F0,L0)|0,c=c+Math.imul(F0,R0)|0,f=f+Math.imul(K0,z0)|0,p=p+Math.imul(K0,M0)|0,p=p+Math.imul(I0,z0)|0,c=c+Math.imul(I0,M0)|0,f=f+Math.imul(V0,v0)|0,p=p+Math.imul(V0,q0)|0,p=p+Math.imul(U0,v0)|0,c=c+Math.imul(U0,q0)|0,f=f+Math.imul(Y0,k0)|0,p=p+Math.imul(Y0,g0)|0,p=p+Math.imul(Z0,k0)|0,c=c+Math.imul(Z0,g0)|0,f=f+Math.imul(i,x0)|0,p=p+Math.imul(i,_0)|0,p=p+Math.imul($0,x0)|0,c=c+Math.imul($0,_0)|0,f=f+Math.imul(a,y0)|0,p=p+Math.imul(a,w0)|0,p=p+Math.imul(r,y0)|0,c=c+Math.imul(r,w0)|0,f=f+Math.imul(s,p0)|0,p=p+Math.imul(s,c0)|0,p=p+Math.imul(t,p0)|0,c=c+Math.imul(t,c0)|0,f=f+Math.imul(o,d0)|0,p=p+Math.imul(o,b0)|0,p=p+Math.imul(u,d0)|0,c=c+Math.imul(u,b0)|0,f=f+Math.imul(d,o0)|0,p=p+Math.imul(d,u0)|0,p=p+Math.imul(b,o0)|0,c=c+Math.imul(b,u0)|0;var Q$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,f=Math.imul(W0,L0),p=Math.imul(W0,R0),p=p+Math.imul(H0,L0)|0,c=Math.imul(H0,R0),f=f+Math.imul(O0,z0)|0,p=p+Math.imul(O0,M0)|0,p=p+Math.imul(F0,z0)|0,c=c+Math.imul(F0,M0)|0,f=f+Math.imul(K0,v0)|0,p=p+Math.imul(K0,q0)|0,p=p+Math.imul(I0,v0)|0,c=c+Math.imul(I0,q0)|0,f=f+Math.imul(V0,k0)|0,p=p+Math.imul(V0,g0)|0,p=p+Math.imul(U0,k0)|0,c=c+Math.imul(U0,g0)|0,f=f+Math.imul(Y0,x0)|0,p=p+Math.imul(Y0,_0)|0,p=p+Math.imul(Z0,x0)|0,c=c+Math.imul(Z0,_0)|0,f=f+Math.imul(i,y0)|0,p=p+Math.imul(i,w0)|0,p=p+Math.imul($0,y0)|0,c=c+Math.imul($0,w0)|0,f=f+Math.imul(a,p0)|0,p=p+Math.imul(a,c0)|0,p=p+Math.imul(r,p0)|0,c=c+Math.imul(r,c0)|0,f=f+Math.imul(s,d0)|0,p=p+Math.imul(s,b0)|0,p=p+Math.imul(t,d0)|0,c=c+Math.imul(t,b0)|0,f=f+Math.imul(o,o0)|0,p=p+Math.imul(o,u0)|0,p=p+Math.imul(u,o0)|0,c=c+Math.imul(u,u0)|0;var Y$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,f=Math.imul(W0,z0),p=Math.imul(W0,M0),p=p+Math.imul(H0,z0)|0,c=Math.imul(H0,M0),f=f+Math.imul(O0,v0)|0,p=p+Math.imul(O0,q0)|0,p=p+Math.imul(F0,v0)|0,c=c+Math.imul(F0,q0)|0,f=f+Math.imul(K0,k0)|0,p=p+Math.imul(K0,g0)|0,p=p+Math.imul(I0,k0)|0,c=c+Math.imul(I0,g0)|0,f=f+Math.imul(V0,x0)|0,p=p+Math.imul(V0,_0)|0,p=p+Math.imul(U0,x0)|0,c=c+Math.imul(U0,_0)|0,f=f+Math.imul(Y0,y0)|0,p=p+Math.imul(Y0,w0)|0,p=p+Math.imul(Z0,y0)|0,c=c+Math.imul(Z0,w0)|0,f=f+Math.imul(i,p0)|0,p=p+Math.imul(i,c0)|0,p=p+Math.imul($0,p0)|0,c=c+Math.imul($0,c0)|0,f=f+Math.imul(a,d0)|0,p=p+Math.imul(a,b0)|0,p=p+Math.imul(r,d0)|0,c=c+Math.imul(r,b0)|0,f=f+Math.imul(s,o0)|0,p=p+Math.imul(s,u0)|0,p=p+Math.imul(t,o0)|0,c=c+Math.imul(t,u0)|0;var Z$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,f=Math.imul(W0,v0),p=Math.imul(W0,q0),p=p+Math.imul(H0,v0)|0,c=Math.imul(H0,q0),f=f+Math.imul(O0,k0)|0,p=p+Math.imul(O0,g0)|0,p=p+Math.imul(F0,k0)|0,c=c+Math.imul(F0,g0)|0,f=f+Math.imul(K0,x0)|0,p=p+Math.imul(K0,_0)|0,p=p+Math.imul(I0,x0)|0,c=c+Math.imul(I0,_0)|0,f=f+Math.imul(V0,y0)|0,p=p+Math.imul(V0,w0)|0,p=p+Math.imul(U0,y0)|0,c=c+Math.imul(U0,w0)|0,f=f+Math.imul(Y0,p0)|0,p=p+Math.imul(Y0,c0)|0,p=p+Math.imul(Z0,p0)|0,c=c+Math.imul(Z0,c0)|0,f=f+Math.imul(i,d0)|0,p=p+Math.imul(i,b0)|0,p=p+Math.imul($0,d0)|0,c=c+Math.imul($0,b0)|0,f=f+Math.imul(a,o0)|0,p=p+Math.imul(a,u0)|0,p=p+Math.imul(r,o0)|0,c=c+Math.imul(r,u0)|0;var G$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(G$>>>26)|0,G$&=67108863,f=Math.imul(W0,k0),p=Math.imul(W0,g0),p=p+Math.imul(H0,k0)|0,c=Math.imul(H0,g0),f=f+Math.imul(O0,x0)|0,p=p+Math.imul(O0,_0)|0,p=p+Math.imul(F0,x0)|0,c=c+Math.imul(F0,_0)|0,f=f+Math.imul(K0,y0)|0,p=p+Math.imul(K0,w0)|0,p=p+Math.imul(I0,y0)|0,c=c+Math.imul(I0,w0)|0,f=f+Math.imul(V0,p0)|0,p=p+Math.imul(V0,c0)|0,p=p+Math.imul(U0,p0)|0,c=c+Math.imul(U0,c0)|0,f=f+Math.imul(Y0,d0)|0,p=p+Math.imul(Y0,b0)|0,p=p+Math.imul(Z0,d0)|0,c=c+Math.imul(Z0,b0)|0,f=f+Math.imul(i,o0)|0,p=p+Math.imul(i,u0)|0,p=p+Math.imul($0,o0)|0,c=c+Math.imul($0,u0)|0;var V$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(V$>>>26)|0,V$&=67108863,f=Math.imul(W0,x0),p=Math.imul(W0,_0),p=p+Math.imul(H0,x0)|0,c=Math.imul(H0,_0),f=f+Math.imul(O0,y0)|0,p=p+Math.imul(O0,w0)|0,p=p+Math.imul(F0,y0)|0,c=c+Math.imul(F0,w0)|0,f=f+Math.imul(K0,p0)|0,p=p+Math.imul(K0,c0)|0,p=p+Math.imul(I0,p0)|0,c=c+Math.imul(I0,c0)|0,f=f+Math.imul(V0,d0)|0,p=p+Math.imul(V0,b0)|0,p=p+Math.imul(U0,d0)|0,c=c+Math.imul(U0,b0)|0,f=f+Math.imul(Y0,o0)|0,p=p+Math.imul(Y0,u0)|0,p=p+Math.imul(Z0,o0)|0,c=c+Math.imul(Z0,u0)|0;var U$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(U$>>>26)|0,U$&=67108863,f=Math.imul(W0,y0),p=Math.imul(W0,w0),p=p+Math.imul(H0,y0)|0,c=Math.imul(H0,w0),f=f+Math.imul(O0,p0)|0,p=p+Math.imul(O0,c0)|0,p=p+Math.imul(F0,p0)|0,c=c+Math.imul(F0,c0)|0,f=f+Math.imul(K0,d0)|0,p=p+Math.imul(K0,b0)|0,p=p+Math.imul(I0,d0)|0,c=c+Math.imul(I0,b0)|0,f=f+Math.imul(V0,o0)|0,p=p+Math.imul(V0,u0)|0,p=p+Math.imul(U0,o0)|0,c=c+Math.imul(U0,u0)|0;var X$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(X$>>>26)|0,X$&=67108863,f=Math.imul(W0,p0),p=Math.imul(W0,c0),p=p+Math.imul(H0,p0)|0,c=Math.imul(H0,c0),f=f+Math.imul(O0,d0)|0,p=p+Math.imul(O0,b0)|0,p=p+Math.imul(F0,d0)|0,c=c+Math.imul(F0,b0)|0,f=f+Math.imul(K0,o0)|0,p=p+Math.imul(K0,u0)|0,p=p+Math.imul(I0,o0)|0,c=c+Math.imul(I0,u0)|0;var K$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(K$>>>26)|0,K$&=67108863,f=Math.imul(W0,d0),p=Math.imul(W0,b0),p=p+Math.imul(H0,d0)|0,c=Math.imul(H0,b0),f=f+Math.imul(O0,o0)|0,p=p+Math.imul(O0,u0)|0,p=p+Math.imul(F0,o0)|0,c=c+Math.imul(F0,u0)|0;var I$=(w+f|0)+((p&8191)<<13)|0;w=(c+(p>>>13)|0)+(I$>>>26)|0,I$&=67108863,f=Math.imul(W0,o0),p=Math.imul(W0,u0),p=p+Math.imul(H0,o0)|0,c=Math.imul(H0,u0);var J$=(w+f|0)+((p&8191)<<13)|0;return w=(c+(p>>>13)|0)+(J$>>>26)|0,J$&=67108863,y[0]=n0,y[1]=s0,y[2]=t0,y[3]=m0,y[4]=a0,y[5]=r0,y[6]=e0,y[7]=i0,y[8]=$$,y[9]=Q$,y[10]=Y$,y[11]=Z$,y[12]=G$,y[13]=V$,y[14]=U$,y[15]=X$,y[16]=K$,y[17]=I$,y[18]=J$,w!==0&&(y[19]=w,x.length++),x};Math.imul||(D=T);function C(g,N,x){x.negative=N.negative^g.negative,x.length=g.length+N.length;for(var _=0,B=0,y=0;y>>26)|0,B+=w>>>26,w&=67108863}x.words[y]=f,_=w,w=B}return _!==0?x.words[y]=_:x.length--,x._strip()}function L(g,N,x){return C(g,N,x)}V.prototype.mulTo=function(g,N){var x,_=this.length+g.length;return this.length===10&&g.length===10?x=D(this,g,N):_<63?x=T(this,g,N):_<1024?x=C(this,g,N):x=L(this,g,N),x};function R(g,N){this.x=g,this.y=N}R.prototype.makeRBT=function(g){for(var N=new Array(g),x=V.prototype._countBits(g)-1,_=0;_>=1;return _},R.prototype.permute=function(g,N,x,_,B,y){for(var w=0;w>>1)B++;return 1<>>13,x[2*y+1]=B&8191,B=B>>>13;for(y=2*N;y<_;++y)x[y]=0;Z(B===0),Z((B&-8192)===0)},R.prototype.stub=function(g){for(var N=new Array(g),x=0;x>=26,x+=B/67108864|0,x+=y>>>26,this.words[_]=y&67108863}return x!==0&&(this.words[_]=x,this.length++),N?this.ineg():this},V.prototype.muln=function(g){return this.clone().imuln(g)},V.prototype.sqr=function(){return this.mul(this)},V.prototype.isqr=function(){return this.imul(this.clone())},V.prototype.pow=function(g){var N=E(g);if(N.length===0)return new V(1);for(var x=this,_=0;_=0);var N=g%26,x=(g-N)/26,_=67108863>>>26-N<<26-N,B;if(N!==0){var y=0;for(B=0;B>>26-N}y&&(this.words[B]=y,this.length++)}if(x!==0){for(B=this.length-1;B>=0;B--)this.words[B+x]=this.words[B];for(B=0;B=0);var _;N?_=(N-N%26)/26:_=0;var B=g%26,y=Math.min((g-B)/26,this.length),w=67108863^67108863>>>B<y)for(this.length-=y,p=0;p=0&&(c!==0||p>=_);p--){var h=this.words[p]|0;this.words[p]=c<<26-B|h>>>B,c=h&w}return f&&c!==0&&(f.words[f.length++]=c),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},V.prototype.ishrn=function(g,N,x){return Z(this.negative===0),this.iushrn(g,N,x)},V.prototype.shln=function(g){return this.clone().ishln(g)},V.prototype.ushln=function(g){return this.clone().iushln(g)},V.prototype.shrn=function(g){return this.clone().ishrn(g)},V.prototype.ushrn=function(g){return this.clone().iushrn(g)},V.prototype.testn=function(g){Z(typeof g=="number"&&g>=0);var N=g%26,x=(g-N)/26,_=1<=0);var N=g%26,x=(g-N)/26;if(Z(this.negative===0,"imaskn works only with positive numbers"),this.length<=x)return this;if(N!==0&&x++,this.length=Math.min(x,this.length),N!==0){var _=67108863^67108863>>>N<=67108864;N++)this.words[N]-=67108864,N===this.length-1?this.words[N+1]=1:this.words[N+1]++;return this.length=Math.max(this.length,N+1),this},V.prototype.isubn=function(g){if(Z(typeof g=="number"),Z(g<67108864),g<0)return this.iaddn(-g);if(this.negative!==0)return this.negative=0,this.iaddn(g),this.negative=1,this;if(this.words[0]-=g,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var N=0;N>26)-(f/67108864|0),this.words[B+x]=y&67108863}for(;B>26,this.words[B+x]=y&67108863;if(w===0)return this._strip();for(Z(w===-1),w=0,B=0;B>26,this.words[B]=y&67108863;return this.negative=1,this._strip()},V.prototype._wordDiv=function(g,N){var x=this.length-g.length,_=this.clone(),B=g,y=B.words[B.length-1]|0,w=this._countBits(y);x=26-w,x!==0&&(B=B.ushln(x),_.iushln(x),y=B.words[B.length-1]|0);var f=_.length-B.length,p;if(N!=="mod"){p=new V(null),p.length=f+1,p.words=new Array(p.length);for(var c=0;c=0;d--){var b=(_.words[B.length+d]|0)*67108864+(_.words[B.length+d-1]|0);for(b=Math.min(b/y|0,67108863),_._ishlnsubmul(B,b,d);_.negative!==0;)b--,_.negative=0,_._ishlnsubmul(B,1,d),_.isZero()||(_.negative^=1);p&&(p.words[d]=b)}return p&&p._strip(),_._strip(),N!=="div"&&x!==0&&_.iushrn(x),{div:p||null,mod:_}},V.prototype.divmod=function(g,N,x){if(Z(!g.isZero()),this.isZero())return{div:new V(0),mod:new V(0)};var _,B,y;return this.negative!==0&&g.negative===0?(y=this.neg().divmod(g,N),N!=="mod"&&(_=y.div.neg()),N!=="div"&&(B=y.mod.neg(),x&&B.negative!==0&&B.iadd(g)),{div:_,mod:B}):this.negative===0&&g.negative!==0?(y=this.divmod(g.neg(),N),N!=="mod"&&(_=y.div.neg()),{div:_,mod:y.mod}):(this.negative&g.negative)!==0?(y=this.neg().divmod(g.neg(),N),N!=="div"&&(B=y.mod.neg(),x&&B.negative!==0&&B.isub(g)),{div:y.div,mod:B}):g.length>this.length||this.cmp(g)<0?{div:new V(0),mod:this}:g.length===1?N==="div"?{div:this.divn(g.words[0]),mod:null}:N==="mod"?{div:null,mod:new V(this.modrn(g.words[0]))}:{div:this.divn(g.words[0]),mod:new V(this.modrn(g.words[0]))}:this._wordDiv(g,N)},V.prototype.div=function(g){return this.divmod(g,"div",!1).div},V.prototype.mod=function(g){return this.divmod(g,"mod",!1).mod},V.prototype.umod=function(g){return this.divmod(g,"mod",!0).mod},V.prototype.divRound=function(g){var N=this.divmod(g);if(N.mod.isZero())return N.div;var x=N.div.negative!==0?N.mod.isub(g):N.mod,_=g.ushrn(1),B=g.andln(1),y=x.cmp(_);return y<0||B===1&&y===0?N.div:N.div.negative!==0?N.div.isubn(1):N.div.iaddn(1)},V.prototype.modrn=function(g){var N=g<0;N&&(g=-g),Z(g<=67108863);for(var x=(1<<26)%g,_=0,B=this.length-1;B>=0;B--)_=(x*_+(this.words[B]|0))%g;return N?-_:_},V.prototype.modn=function(g){return this.modrn(g)},V.prototype.idivn=function(g){var N=g<0;N&&(g=-g),Z(g<=67108863);for(var x=0,_=this.length-1;_>=0;_--){var B=(this.words[_]|0)+x*67108864;this.words[_]=B/g|0,x=B%g}return this._strip(),N?this.ineg():this},V.prototype.divn=function(g){return this.clone().idivn(g)},V.prototype.egcd=function(g){Z(g.negative===0),Z(!g.isZero());var N=this,x=g.clone();N.negative!==0?N=N.umod(g):N=N.clone();for(var _=new V(1),B=new V(0),y=new V(0),w=new V(1),f=0;N.isEven()&&x.isEven();)N.iushrn(1),x.iushrn(1),++f;for(var p=x.clone(),c=N.clone();!N.isZero();){for(var h=0,d=1;(N.words[0]&d)===0&&h<26;++h,d<<=1);if(h>0)for(N.iushrn(h);h-- >0;)(_.isOdd()||B.isOdd())&&(_.iadd(p),B.isub(c)),_.iushrn(1),B.iushrn(1);for(var b=0,l=1;(x.words[0]&l)===0&&b<26;++b,l<<=1);if(b>0)for(x.iushrn(b);b-- >0;)(y.isOdd()||w.isOdd())&&(y.iadd(p),w.isub(c)),y.iushrn(1),w.iushrn(1);N.cmp(x)>=0?(N.isub(x),_.isub(y),B.isub(w)):(x.isub(N),y.isub(_),w.isub(B))}return{a:y,b:w,gcd:x.iushln(f)}},V.prototype._invmp=function(g){Z(g.negative===0),Z(!g.isZero());var N=this,x=g.clone();N.negative!==0?N=N.umod(g):N=N.clone();for(var _=new V(1),B=new V(0),y=x.clone();N.cmpn(1)>0&&x.cmpn(1)>0;){for(var w=0,f=1;(N.words[0]&f)===0&&w<26;++w,f<<=1);if(w>0)for(N.iushrn(w);w-- >0;)_.isOdd()&&_.iadd(y),_.iushrn(1);for(var p=0,c=1;(x.words[0]&c)===0&&p<26;++p,c<<=1);if(p>0)for(x.iushrn(p);p-- >0;)B.isOdd()&&B.iadd(y),B.iushrn(1);N.cmp(x)>=0?(N.isub(x),_.isub(B)):(x.isub(N),B.isub(_))}var h;return N.cmpn(1)===0?h=_:h=B,h.cmpn(0)<0&&h.iadd(g),h},V.prototype.gcd=function(g){if(this.isZero())return g.abs();if(g.isZero())return this.abs();var N=this.clone(),x=g.clone();N.negative=0,x.negative=0;for(var _=0;N.isEven()&&x.isEven();_++)N.iushrn(1),x.iushrn(1);do{for(;N.isEven();)N.iushrn(1);for(;x.isEven();)x.iushrn(1);var B=N.cmp(x);if(B<0){var y=N;N=x,x=y}else if(B===0||x.cmpn(1)===0)break;N.isub(x)}while(!0);return x.iushln(_)},V.prototype.invm=function(g){return this.egcd(g).a.umod(g)},V.prototype.isEven=function(){return(this.words[0]&1)===0},V.prototype.isOdd=function(){return(this.words[0]&1)===1},V.prototype.andln=function(g){return this.words[0]&g},V.prototype.bincn=function(g){Z(typeof g=="number");var N=g%26,x=(g-N)/26,_=1<>>26,w&=67108863,this.words[y]=w}return B!==0&&(this.words[y]=B,this.length++),this},V.prototype.isZero=function(){return this.length===1&&this.words[0]===0},V.prototype.cmpn=function(g){var N=g<0;if(this.negative!==0&&!N)return-1;if(this.negative===0&&N)return 1;this._strip();var x;if(this.length>1)x=1;else{N&&(g=-g),Z(g<=67108863,"Number is too big");var _=this.words[0]|0;x=_===g?0:_g.length)return 1;if(this.length=0;x--){var _=this.words[x]|0,B=g.words[x]|0;if(_!==B){_B&&(N=1);break}}return N},V.prototype.gtn=function(g){return this.cmpn(g)===1},V.prototype.gt=function(g){return this.cmp(g)===1},V.prototype.gten=function(g){return this.cmpn(g)>=0},V.prototype.gte=function(g){return this.cmp(g)>=0},V.prototype.ltn=function(g){return this.cmpn(g)===-1},V.prototype.lt=function(g){return this.cmp(g)===-1},V.prototype.lten=function(g){return this.cmpn(g)<=0},V.prototype.lte=function(g){return this.cmp(g)<=0},V.prototype.eqn=function(g){return this.cmpn(g)===0},V.prototype.eq=function(g){return this.cmp(g)===0},V.red=function(g){return new j(g)},V.prototype.toRed=function(g){return Z(!this.red,"Already a number in reduction context"),Z(this.negative===0,"red works only with positives"),g.convertTo(this)._forceRed(g)},V.prototype.fromRed=function(){return Z(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},V.prototype._forceRed=function(g){return this.red=g,this},V.prototype.forceRed=function(g){return Z(!this.red,"Already a number in reduction context"),this._forceRed(g)},V.prototype.redAdd=function(g){return Z(this.red,"redAdd works only with red numbers"),this.red.add(this,g)},V.prototype.redIAdd=function(g){return Z(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,g)},V.prototype.redSub=function(g){return Z(this.red,"redSub works only with red numbers"),this.red.sub(this,g)},V.prototype.redISub=function(g){return Z(this.red,"redISub works only with red numbers"),this.red.isub(this,g)},V.prototype.redShl=function(g){return Z(this.red,"redShl works only with red numbers"),this.red.shl(this,g)},V.prototype.redMul=function(g){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.mul(this,g)},V.prototype.redIMul=function(g){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.imul(this,g)},V.prototype.redSqr=function(){return Z(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},V.prototype.redISqr=function(){return Z(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},V.prototype.redSqrt=function(){return Z(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},V.prototype.redInvm=function(){return Z(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},V.prototype.redNeg=function(){return Z(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},V.prototype.redPow=function(g){return Z(this.red&&!g.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,g)};var P={k256:null,p224:null,p192:null,p25519:null};function z(g,N){this.name=g,this.p=new V(N,16),this.n=this.p.bitLength(),this.k=new V(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var g=new V(null);return g.words=new Array(Math.ceil(this.n/13)),g},z.prototype.ireduce=function(g){var N=g,x;do this.split(N,this.tmp),N=this.imulK(N),N=N.iadd(this.tmp),x=N.bitLength();while(x>this.n);var _=x0?N.isub(this.p):N.strip!==void 0?N.strip():N._strip(),N},z.prototype.split=function(g,N){g.iushrn(this.n,0,N)},z.prototype.imulK=function(g){return g.imul(this.k)};function M(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}G(M,z),M.prototype.split=function(g,N){for(var x=4194303,_=Math.min(g.length,9),B=0;B<_;B++)N.words[B]=g.words[B];if(N.length=_,g.length<=9){g.words[0]=0,g.length=1;return}var y=g.words[9];for(N.words[N.length++]=y&x,B=10;B>>22,y=w}y>>>=22,g.words[B-10]=y,y===0&&g.length>10?g.length-=10:g.length-=9},M.prototype.imulK=function(g){g.words[g.length]=0,g.words[g.length+1]=0,g.length+=2;for(var N=0,x=0;x>>=26,g.words[x]=B,N=_}return N!==0&&(g.words[g.length++]=N),g},V._prime=function(g){if(P[g])return P[g];var N;if(g==="k256")N=new M;else if(g==="p224")N=new S;else if(g==="p192")N=new v;else if(g==="p25519")N=new q;else throw new Error("Unknown prime "+g);return P[g]=N,N};function j(g){if(typeof g=="string"){var N=V._prime(g);this.m=N.p,this.prime=N}else Z(g.gtn(1),"modulus must be greater than 1"),this.m=g,this.prime=null}j.prototype._verify1=function(g){Z(g.negative===0,"red works only with positives"),Z(g.red,"red works only with red numbers")},j.prototype._verify2=function(g,N){Z((g.negative|N.negative)===0,"red works only with positives"),Z(g.red&&g.red===N.red,"red works only with red numbers")},j.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):(J(g,g.umod(this.m)._forceRed(this)),g)},j.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},j.prototype.add=function(g,N){this._verify2(g,N);var x=g.add(N);return x.cmp(this.m)>=0&&x.isub(this.m),x._forceRed(this)},j.prototype.iadd=function(g,N){this._verify2(g,N);var x=g.iadd(N);return x.cmp(this.m)>=0&&x.isub(this.m),x},j.prototype.sub=function(g,N){this._verify2(g,N);var x=g.sub(N);return x.cmpn(0)<0&&x.iadd(this.m),x._forceRed(this)},j.prototype.isub=function(g,N){this._verify2(g,N);var x=g.isub(N);return x.cmpn(0)<0&&x.iadd(this.m),x},j.prototype.shl=function(g,N){return this._verify1(g),this.imod(g.ushln(N))},j.prototype.imul=function(g,N){return this._verify2(g,N),this.imod(g.imul(N))},j.prototype.mul=function(g,N){return this._verify2(g,N),this.imod(g.mul(N))},j.prototype.isqr=function(g){return this.imul(g,g.clone())},j.prototype.sqr=function(g){return this.mul(g,g)},j.prototype.sqrt=function(g){if(g.isZero())return g.clone();var N=this.m.andln(3);if(Z(N%2===1),N===3){var x=this.m.add(new V(1)).iushrn(2);return this.pow(g,x)}for(var _=this.m.subn(1),B=0;!_.isZero()&&_.andln(1)===0;)B++,_.iushrn(1);Z(!_.isZero());var y=new V(1).toRed(this),w=y.redNeg(),f=this.m.subn(1).iushrn(1),p=this.m.bitLength();for(p=new V(2*p*p).toRed(this);this.pow(p,f).cmp(w)!==0;)p.redIAdd(w);for(var c=this.pow(p,_),h=this.pow(g,_.addn(1).iushrn(1)),d=this.pow(g,_),b=B;d.cmp(y)!==0;){for(var l=d,o=0;l.cmp(y)!==0;o++)l=l.redSqr();Z(o=0;B--){for(var c=N.words[B],h=p-1;h>=0;h--){var d=c>>h&1;if(y!==_[0]&&(y=this.sqr(y)),d===0&&w===0){f=0;continue}w<<=1,w|=d,f++,!(f!==x&&(B!==0||h!==0))&&(y=this.mul(y,_[w]),f=0,w=0)}p=26}return y},j.prototype.convertTo=function(g){var N=g.umod(this.m);return N===g?N.clone():N},j.prototype.convertFrom=function(g){var N=g.clone();return N.red=null,N},V.mont=function(g){return new k(g)};function k(g){j.call(this,g),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new V(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}G(k,j),k.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},k.prototype.convertFrom=function(g){var N=this.imod(g.mul(this.rinv));return N.red=null,N},k.prototype.imul=function(g,N){if(g.isZero()||N.isZero())return g.words[0]=0,g.length=1,g;var x=g.imul(N),_=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),B=x.isub(_).iushrn(this.shift),y=B;return B.cmp(this.m)>=0?y=B.isub(this.m):B.cmpn(0)<0&&(y=B.iadd(this.m)),y._forceRed(this)},k.prototype.mul=function(g,N){if(g.isZero()||N.isZero())return new V(0)._forceRed(this);var x=g.mul(N),_=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),B=x.isub(_).iushrn(this.shift),y=B;return B.cmp(this.m)>=0?y=B.isub(this.m):B.cmpn(0)<0&&(y=B.iadd(this.m)),y._forceRed(this)},k.prototype.invm=function(g){var N=this.imod(g._invmp(this.m).mul(this.r2));return N._forceRed(this)}})(typeof $>"u"||$,bZ)}}),wQ=P$({"node_modules/browserify-rsa/index.js"(bZ,$){var Q=yQ(),Y=S$();function Z(U){var X=G(U),K=X.toRed(Q.mont(U.modulus)).redPow(new Q(U.publicExponent)).fromRed();return{blinder:K,unblinder:X.invm(U.modulus)}}function G(U){var X=U.modulus.byteLength(),K;do K=new Q(Y(X));while(K.cmp(U.modulus)>=0||!K.umod(U.prime1)||!K.umod(U.prime2));return K}function V(U,X){var K=Z(X),I=X.modulus.byteLength(),J=new Q(U).mul(K.blinder).umod(X.modulus),O=J.toRed(Q.mont(X.prime1)),F=J.toRed(Q.mont(X.prime2)),A=X.coefficient,W=X.prime1,H=X.prime2,E=O.redPow(X.exponent1).fromRed(),T=F.redPow(X.exponent2).fromRed(),D=E.isub(T).imul(A).umod(W).imul(H);return T.iadd(D).imul(K.unblinder).umod(X.modulus).toArrayLike(Buffer,"be",I)}V.getr=G,$.exports=V}}),fQ=P$({"node_modules/elliptic/package.json"(bZ,$){$.exports={name:"elliptic",version:"6.5.4",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}}}),pQ=P$({"node_modules/elliptic/node_modules/bn.js/lib/bn.js"(bZ,$){(function(Q,Y){function Z(q,j){if(!q)throw new Error(j||"Assertion failed")}function G(q,j){q.super_=j;var k=function(){};k.prototype=j.prototype,q.prototype=new k,q.prototype.constructor=q}function V(q,j,k){if(V.isBN(q))return q;this.negative=0,this.words=null,this.length=0,this.red=null,q!==null&&((j==="le"||j==="be")&&(k=j,j=10),this._init(q||0,j||10,k||"be"))}typeof Q=="object"?Q.exports=V:Y.BN=V,V.BN=V,V.wordSize=26;var U;try{typeof window<"u"&&typeof window.Buffer<"u"?U=window.Buffer:U=L$("buffer").Buffer}catch{}V.isBN=function(q){return q instanceof V?!0:q!==null&&typeof q=="object"&&q.constructor.wordSize===V.wordSize&&Array.isArray(q.words)},V.max=function(q,j){return q.cmp(j)>0?q:j},V.min=function(q,j){return q.cmp(j)<0?q:j},V.prototype._init=function(q,j,k){if(typeof q=="number")return this._initNumber(q,j,k);if(typeof q=="object")return this._initArray(q,j,k);j==="hex"&&(j=16),Z(j===(j|0)&&j>=2&&j<=36),q=q.toString().replace(/\s+/g,"");var g=0;q[0]==="-"&&(g++,this.negative=1),g=0;g-=3)x=q[g]|q[g-1]<<8|q[g-2]<<16,this.words[N]|=x<<_&67108863,this.words[N+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);else if(k==="le")for(g=0,N=0;g>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);return this.strip()};function X(q,j){var k=q.charCodeAt(j);return k>=65&&k<=70?k-55:k>=97&&k<=102?k-87:k-48&15}function K(q,j,k){var g=X(q,k);return k-1>=j&&(g|=X(q,k-1)<<4),g}V.prototype._parseHex=function(q,j,k){this.length=Math.ceil((q.length-j)/6),this.words=new Array(this.length);for(var g=0;g=j;g-=2)_=K(q,j,g)<=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8;else{var B=q.length-j;for(g=B%2===0?j+1:j;g=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8}this.strip()};function I(q,j,k,g){for(var N=0,x=Math.min(q.length,k),_=j;_=49?N+=B-49+10:B>=17?N+=B-17+10:N+=B}return N}V.prototype._parseBase=function(q,j,k){this.words=[0],this.length=1;for(var g=0,N=1;N<=67108863;N*=j)g++;g--,N=N/j|0;for(var x=q.length-k,_=x%g,B=Math.min(x,x-_)+k,y=0,w=k;w1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},V.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},V.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],O=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],F=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];V.prototype.toString=function(q,j){q=q||10,j=j|0||1;var k;if(q===16||q==="hex"){k="";for(var g=0,N=0,x=0;x>>24-g&16777215,N!==0||x!==this.length-1?k=J[6-B.length]+B+k:k=B+k,g+=2,g>=26&&(g-=26,x--)}for(N!==0&&(k=N.toString(16)+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}if(q===(q|0)&&q>=2&&q<=36){var y=O[q],w=F[q];k="";var f=this.clone();for(f.negative=0;!f.isZero();){var p=f.modn(w).toString(q);f=f.idivn(w),f.isZero()?k=p+k:k=J[y-p.length]+p+k}for(this.isZero()&&(k="0"+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}Z(!1,"Base should be between 2 and 36")},V.prototype.toNumber=function(){var q=this.words[0];return this.length===2?q+=this.words[1]*67108864:this.length===3&&this.words[2]===1?q+=4503599627370496+this.words[1]*67108864:this.length>2&&Z(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-q:q},V.prototype.toJSON=function(){return this.toString(16)},V.prototype.toBuffer=function(q,j){return Z(typeof U<"u"),this.toArrayLike(U,q,j)},V.prototype.toArray=function(q,j){return this.toArrayLike(Array,q,j)},V.prototype.toArrayLike=function(q,j,k){var g=this.byteLength(),N=k||Math.max(1,g);Z(g<=N,"byte array longer than desired length"),Z(N>0,"Requested array length <= 0"),this.strip();var x=j==="le",_=new q(N),B,y,w=this.clone();if(x){for(y=0;!w.isZero();y++)B=w.andln(255),w.iushrn(8),_[y]=B;for(;y=4096&&(k+=13,j>>>=13),j>=64&&(k+=7,j>>>=7),j>=8&&(k+=4,j>>>=4),j>=2&&(k+=2,j>>>=2),k+j},V.prototype._zeroBits=function(q){if(q===0)return 26;var j=q,k=0;return(j&8191)===0&&(k+=13,j>>>=13),(j&127)===0&&(k+=7,j>>>=7),(j&15)===0&&(k+=4,j>>>=4),(j&3)===0&&(k+=2,j>>>=2),(j&1)===0&&k++,k},V.prototype.bitLength=function(){var q=this.words[this.length-1],j=this._countBits(q);return(this.length-1)*26+j};function A(q){for(var j=new Array(q.bitLength()),k=0;k>>N}return j}V.prototype.zeroBits=function(){if(this.isZero())return 0;for(var q=0,j=0;jq.length?this.clone().ior(q):q.clone().ior(this)},V.prototype.uor=function(q){return this.length>q.length?this.clone().iuor(q):q.clone().iuor(this)},V.prototype.iuand=function(q){var j;this.length>q.length?j=q:j=this;for(var k=0;kq.length?this.clone().iand(q):q.clone().iand(this)},V.prototype.uand=function(q){return this.length>q.length?this.clone().iuand(q):q.clone().iuand(this)},V.prototype.iuxor=function(q){var j,k;this.length>q.length?(j=this,k=q):(j=q,k=this);for(var g=0;gq.length?this.clone().ixor(q):q.clone().ixor(this)},V.prototype.uxor=function(q){return this.length>q.length?this.clone().iuxor(q):q.clone().iuxor(this)},V.prototype.inotn=function(q){Z(typeof q=="number"&&q>=0);var j=Math.ceil(q/26)|0,k=q%26;this._expand(j),k>0&&j--;for(var g=0;g0&&(this.words[g]=~this.words[g]&67108863>>26-k),this.strip()},V.prototype.notn=function(q){return this.clone().inotn(q)},V.prototype.setn=function(q,j){Z(typeof q=="number"&&q>=0);var k=q/26|0,g=q%26;return this._expand(k+1),j?this.words[k]=this.words[k]|1<q.length?(k=this,g=q):(k=q,g=this);for(var N=0,x=0;x>>26;for(;N!==0&&x>>26;if(this.length=k.length,N!==0)this.words[this.length]=N,this.length++;else if(k!==this)for(;xq.length?this.clone().iadd(q):q.clone().iadd(this)},V.prototype.isub=function(q){if(q.negative!==0){q.negative=0;var j=this.iadd(q);return q.negative=1,j._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(q),this.negative=1,this._normSign();var k=this.cmp(q);if(k===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,N;k>0?(g=this,N=q):(g=q,N=this);for(var x=0,_=0;_>26,this.words[_]=j&67108863;for(;x!==0&&_>26,this.words[_]=j&67108863;if(x===0&&_>>26,p=y&67108863,c=Math.min(w,j.length-1),h=Math.max(0,w-q.length+1);h<=c;h++){var d=w-h|0;N=q.words[d]|0,x=j.words[h]|0,_=N*x+p,f+=_/67108864|0,p=_&67108863}k.words[w]=p|0,y=f|0}return y!==0?k.words[w]=y|0:k.length--,k.strip()}var H=function(q,j,k){var g=q.words,N=j.words,x=k.words,_=0,B,y,w,f=g[0]|0,p=f&8191,c=f>>>13,h=g[1]|0,d=h&8191,b=h>>>13,l=g[2]|0,o=l&8191,u=l>>>13,n=g[3]|0,s=n&8191,t=n>>>13,m=g[4]|0,a=m&8191,r=m>>>13,e=g[5]|0,i=e&8191,$0=e>>>13,Q0=g[6]|0,Y0=Q0&8191,Z0=Q0>>>13,G0=g[7]|0,V0=G0&8191,U0=G0>>>13,X0=g[8]|0,K0=X0&8191,I0=X0>>>13,J0=g[9]|0,O0=J0&8191,F0=J0>>>13,A0=N[0]|0,W0=A0&8191,H0=A0>>>13,E0=N[1]|0,T0=E0&8191,D0=E0>>>13,C0=N[2]|0,L0=C0&8191,R0=C0>>>13,P0=N[3]|0,z0=P0&8191,M0=P0>>>13,S0=N[4]|0,v0=S0&8191,q0=S0>>>13,j0=N[5]|0,k0=j0&8191,g0=j0>>>13,N0=N[6]|0,x0=N0&8191,_0=N0>>>13,B0=N[7]|0,y0=B0&8191,w0=B0>>>13,f0=N[8]|0,p0=f0&8191,c0=f0>>>13,h0=N[9]|0,d0=h0&8191,b0=h0>>>13;k.negative=q.negative^j.negative,k.length=19,B=Math.imul(p,W0),y=Math.imul(p,H0),y=y+Math.imul(c,W0)|0,w=Math.imul(c,H0);var l0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(l0>>>26)|0,l0&=67108863,B=Math.imul(d,W0),y=Math.imul(d,H0),y=y+Math.imul(b,W0)|0,w=Math.imul(b,H0),B=B+Math.imul(p,T0)|0,y=y+Math.imul(p,D0)|0,y=y+Math.imul(c,T0)|0,w=w+Math.imul(c,D0)|0;var o0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(o0>>>26)|0,o0&=67108863,B=Math.imul(o,W0),y=Math.imul(o,H0),y=y+Math.imul(u,W0)|0,w=Math.imul(u,H0),B=B+Math.imul(d,T0)|0,y=y+Math.imul(d,D0)|0,y=y+Math.imul(b,T0)|0,w=w+Math.imul(b,D0)|0,B=B+Math.imul(p,L0)|0,y=y+Math.imul(p,R0)|0,y=y+Math.imul(c,L0)|0,w=w+Math.imul(c,R0)|0;var u0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(u0>>>26)|0,u0&=67108863,B=Math.imul(s,W0),y=Math.imul(s,H0),y=y+Math.imul(t,W0)|0,w=Math.imul(t,H0),B=B+Math.imul(o,T0)|0,y=y+Math.imul(o,D0)|0,y=y+Math.imul(u,T0)|0,w=w+Math.imul(u,D0)|0,B=B+Math.imul(d,L0)|0,y=y+Math.imul(d,R0)|0,y=y+Math.imul(b,L0)|0,w=w+Math.imul(b,R0)|0,B=B+Math.imul(p,z0)|0,y=y+Math.imul(p,M0)|0,y=y+Math.imul(c,z0)|0,w=w+Math.imul(c,M0)|0;var n0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(n0>>>26)|0,n0&=67108863,B=Math.imul(a,W0),y=Math.imul(a,H0),y=y+Math.imul(r,W0)|0,w=Math.imul(r,H0),B=B+Math.imul(s,T0)|0,y=y+Math.imul(s,D0)|0,y=y+Math.imul(t,T0)|0,w=w+Math.imul(t,D0)|0,B=B+Math.imul(o,L0)|0,y=y+Math.imul(o,R0)|0,y=y+Math.imul(u,L0)|0,w=w+Math.imul(u,R0)|0,B=B+Math.imul(d,z0)|0,y=y+Math.imul(d,M0)|0,y=y+Math.imul(b,z0)|0,w=w+Math.imul(b,M0)|0,B=B+Math.imul(p,v0)|0,y=y+Math.imul(p,q0)|0,y=y+Math.imul(c,v0)|0,w=w+Math.imul(c,q0)|0;var s0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(s0>>>26)|0,s0&=67108863,B=Math.imul(i,W0),y=Math.imul(i,H0),y=y+Math.imul($0,W0)|0,w=Math.imul($0,H0),B=B+Math.imul(a,T0)|0,y=y+Math.imul(a,D0)|0,y=y+Math.imul(r,T0)|0,w=w+Math.imul(r,D0)|0,B=B+Math.imul(s,L0)|0,y=y+Math.imul(s,R0)|0,y=y+Math.imul(t,L0)|0,w=w+Math.imul(t,R0)|0,B=B+Math.imul(o,z0)|0,y=y+Math.imul(o,M0)|0,y=y+Math.imul(u,z0)|0,w=w+Math.imul(u,M0)|0,B=B+Math.imul(d,v0)|0,y=y+Math.imul(d,q0)|0,y=y+Math.imul(b,v0)|0,w=w+Math.imul(b,q0)|0,B=B+Math.imul(p,k0)|0,y=y+Math.imul(p,g0)|0,y=y+Math.imul(c,k0)|0,w=w+Math.imul(c,g0)|0;var t0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(t0>>>26)|0,t0&=67108863,B=Math.imul(Y0,W0),y=Math.imul(Y0,H0),y=y+Math.imul(Z0,W0)|0,w=Math.imul(Z0,H0),B=B+Math.imul(i,T0)|0,y=y+Math.imul(i,D0)|0,y=y+Math.imul($0,T0)|0,w=w+Math.imul($0,D0)|0,B=B+Math.imul(a,L0)|0,y=y+Math.imul(a,R0)|0,y=y+Math.imul(r,L0)|0,w=w+Math.imul(r,R0)|0,B=B+Math.imul(s,z0)|0,y=y+Math.imul(s,M0)|0,y=y+Math.imul(t,z0)|0,w=w+Math.imul(t,M0)|0,B=B+Math.imul(o,v0)|0,y=y+Math.imul(o,q0)|0,y=y+Math.imul(u,v0)|0,w=w+Math.imul(u,q0)|0,B=B+Math.imul(d,k0)|0,y=y+Math.imul(d,g0)|0,y=y+Math.imul(b,k0)|0,w=w+Math.imul(b,g0)|0,B=B+Math.imul(p,x0)|0,y=y+Math.imul(p,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,_0)|0;var m0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(m0>>>26)|0,m0&=67108863,B=Math.imul(V0,W0),y=Math.imul(V0,H0),y=y+Math.imul(U0,W0)|0,w=Math.imul(U0,H0),B=B+Math.imul(Y0,T0)|0,y=y+Math.imul(Y0,D0)|0,y=y+Math.imul(Z0,T0)|0,w=w+Math.imul(Z0,D0)|0,B=B+Math.imul(i,L0)|0,y=y+Math.imul(i,R0)|0,y=y+Math.imul($0,L0)|0,w=w+Math.imul($0,R0)|0,B=B+Math.imul(a,z0)|0,y=y+Math.imul(a,M0)|0,y=y+Math.imul(r,z0)|0,w=w+Math.imul(r,M0)|0,B=B+Math.imul(s,v0)|0,y=y+Math.imul(s,q0)|0,y=y+Math.imul(t,v0)|0,w=w+Math.imul(t,q0)|0,B=B+Math.imul(o,k0)|0,y=y+Math.imul(o,g0)|0,y=y+Math.imul(u,k0)|0,w=w+Math.imul(u,g0)|0,B=B+Math.imul(d,x0)|0,y=y+Math.imul(d,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,_0)|0,B=B+Math.imul(p,y0)|0,y=y+Math.imul(p,w0)|0,y=y+Math.imul(c,y0)|0,w=w+Math.imul(c,w0)|0;var a0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(a0>>>26)|0,a0&=67108863,B=Math.imul(K0,W0),y=Math.imul(K0,H0),y=y+Math.imul(I0,W0)|0,w=Math.imul(I0,H0),B=B+Math.imul(V0,T0)|0,y=y+Math.imul(V0,D0)|0,y=y+Math.imul(U0,T0)|0,w=w+Math.imul(U0,D0)|0,B=B+Math.imul(Y0,L0)|0,y=y+Math.imul(Y0,R0)|0,y=y+Math.imul(Z0,L0)|0,w=w+Math.imul(Z0,R0)|0,B=B+Math.imul(i,z0)|0,y=y+Math.imul(i,M0)|0,y=y+Math.imul($0,z0)|0,w=w+Math.imul($0,M0)|0,B=B+Math.imul(a,v0)|0,y=y+Math.imul(a,q0)|0,y=y+Math.imul(r,v0)|0,w=w+Math.imul(r,q0)|0,B=B+Math.imul(s,k0)|0,y=y+Math.imul(s,g0)|0,y=y+Math.imul(t,k0)|0,w=w+Math.imul(t,g0)|0,B=B+Math.imul(o,x0)|0,y=y+Math.imul(o,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,_0)|0,B=B+Math.imul(d,y0)|0,y=y+Math.imul(d,w0)|0,y=y+Math.imul(b,y0)|0,w=w+Math.imul(b,w0)|0,B=B+Math.imul(p,p0)|0,y=y+Math.imul(p,c0)|0,y=y+Math.imul(c,p0)|0,w=w+Math.imul(c,c0)|0;var r0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(r0>>>26)|0,r0&=67108863,B=Math.imul(O0,W0),y=Math.imul(O0,H0),y=y+Math.imul(F0,W0)|0,w=Math.imul(F0,H0),B=B+Math.imul(K0,T0)|0,y=y+Math.imul(K0,D0)|0,y=y+Math.imul(I0,T0)|0,w=w+Math.imul(I0,D0)|0,B=B+Math.imul(V0,L0)|0,y=y+Math.imul(V0,R0)|0,y=y+Math.imul(U0,L0)|0,w=w+Math.imul(U0,R0)|0,B=B+Math.imul(Y0,z0)|0,y=y+Math.imul(Y0,M0)|0,y=y+Math.imul(Z0,z0)|0,w=w+Math.imul(Z0,M0)|0,B=B+Math.imul(i,v0)|0,y=y+Math.imul(i,q0)|0,y=y+Math.imul($0,v0)|0,w=w+Math.imul($0,q0)|0,B=B+Math.imul(a,k0)|0,y=y+Math.imul(a,g0)|0,y=y+Math.imul(r,k0)|0,w=w+Math.imul(r,g0)|0,B=B+Math.imul(s,x0)|0,y=y+Math.imul(s,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,_0)|0,B=B+Math.imul(o,y0)|0,y=y+Math.imul(o,w0)|0,y=y+Math.imul(u,y0)|0,w=w+Math.imul(u,w0)|0,B=B+Math.imul(d,p0)|0,y=y+Math.imul(d,c0)|0,y=y+Math.imul(b,p0)|0,w=w+Math.imul(b,c0)|0,B=B+Math.imul(p,d0)|0,y=y+Math.imul(p,b0)|0,y=y+Math.imul(c,d0)|0,w=w+Math.imul(c,b0)|0;var e0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(e0>>>26)|0,e0&=67108863,B=Math.imul(O0,T0),y=Math.imul(O0,D0),y=y+Math.imul(F0,T0)|0,w=Math.imul(F0,D0),B=B+Math.imul(K0,L0)|0,y=y+Math.imul(K0,R0)|0,y=y+Math.imul(I0,L0)|0,w=w+Math.imul(I0,R0)|0,B=B+Math.imul(V0,z0)|0,y=y+Math.imul(V0,M0)|0,y=y+Math.imul(U0,z0)|0,w=w+Math.imul(U0,M0)|0,B=B+Math.imul(Y0,v0)|0,y=y+Math.imul(Y0,q0)|0,y=y+Math.imul(Z0,v0)|0,w=w+Math.imul(Z0,q0)|0,B=B+Math.imul(i,k0)|0,y=y+Math.imul(i,g0)|0,y=y+Math.imul($0,k0)|0,w=w+Math.imul($0,g0)|0,B=B+Math.imul(a,x0)|0,y=y+Math.imul(a,_0)|0,y=y+Math.imul(r,x0)|0,w=w+Math.imul(r,_0)|0,B=B+Math.imul(s,y0)|0,y=y+Math.imul(s,w0)|0,y=y+Math.imul(t,y0)|0,w=w+Math.imul(t,w0)|0,B=B+Math.imul(o,p0)|0,y=y+Math.imul(o,c0)|0,y=y+Math.imul(u,p0)|0,w=w+Math.imul(u,c0)|0,B=B+Math.imul(d,d0)|0,y=y+Math.imul(d,b0)|0,y=y+Math.imul(b,d0)|0,w=w+Math.imul(b,b0)|0;var i0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(i0>>>26)|0,i0&=67108863,B=Math.imul(O0,L0),y=Math.imul(O0,R0),y=y+Math.imul(F0,L0)|0,w=Math.imul(F0,R0),B=B+Math.imul(K0,z0)|0,y=y+Math.imul(K0,M0)|0,y=y+Math.imul(I0,z0)|0,w=w+Math.imul(I0,M0)|0,B=B+Math.imul(V0,v0)|0,y=y+Math.imul(V0,q0)|0,y=y+Math.imul(U0,v0)|0,w=w+Math.imul(U0,q0)|0,B=B+Math.imul(Y0,k0)|0,y=y+Math.imul(Y0,g0)|0,y=y+Math.imul(Z0,k0)|0,w=w+Math.imul(Z0,g0)|0,B=B+Math.imul(i,x0)|0,y=y+Math.imul(i,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,_0)|0,B=B+Math.imul(a,y0)|0,y=y+Math.imul(a,w0)|0,y=y+Math.imul(r,y0)|0,w=w+Math.imul(r,w0)|0,B=B+Math.imul(s,p0)|0,y=y+Math.imul(s,c0)|0,y=y+Math.imul(t,p0)|0,w=w+Math.imul(t,c0)|0,B=B+Math.imul(o,d0)|0,y=y+Math.imul(o,b0)|0,y=y+Math.imul(u,d0)|0,w=w+Math.imul(u,b0)|0;var $$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+($$>>>26)|0,$$&=67108863,B=Math.imul(O0,z0),y=Math.imul(O0,M0),y=y+Math.imul(F0,z0)|0,w=Math.imul(F0,M0),B=B+Math.imul(K0,v0)|0,y=y+Math.imul(K0,q0)|0,y=y+Math.imul(I0,v0)|0,w=w+Math.imul(I0,q0)|0,B=B+Math.imul(V0,k0)|0,y=y+Math.imul(V0,g0)|0,y=y+Math.imul(U0,k0)|0,w=w+Math.imul(U0,g0)|0,B=B+Math.imul(Y0,x0)|0,y=y+Math.imul(Y0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,_0)|0,B=B+Math.imul(i,y0)|0,y=y+Math.imul(i,w0)|0,y=y+Math.imul($0,y0)|0,w=w+Math.imul($0,w0)|0,B=B+Math.imul(a,p0)|0,y=y+Math.imul(a,c0)|0,y=y+Math.imul(r,p0)|0,w=w+Math.imul(r,c0)|0,B=B+Math.imul(s,d0)|0,y=y+Math.imul(s,b0)|0,y=y+Math.imul(t,d0)|0,w=w+Math.imul(t,b0)|0;var Q$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,B=Math.imul(O0,v0),y=Math.imul(O0,q0),y=y+Math.imul(F0,v0)|0,w=Math.imul(F0,q0),B=B+Math.imul(K0,k0)|0,y=y+Math.imul(K0,g0)|0,y=y+Math.imul(I0,k0)|0,w=w+Math.imul(I0,g0)|0,B=B+Math.imul(V0,x0)|0,y=y+Math.imul(V0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,_0)|0,B=B+Math.imul(Y0,y0)|0,y=y+Math.imul(Y0,w0)|0,y=y+Math.imul(Z0,y0)|0,w=w+Math.imul(Z0,w0)|0,B=B+Math.imul(i,p0)|0,y=y+Math.imul(i,c0)|0,y=y+Math.imul($0,p0)|0,w=w+Math.imul($0,c0)|0,B=B+Math.imul(a,d0)|0,y=y+Math.imul(a,b0)|0,y=y+Math.imul(r,d0)|0,w=w+Math.imul(r,b0)|0;var Y$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,B=Math.imul(O0,k0),y=Math.imul(O0,g0),y=y+Math.imul(F0,k0)|0,w=Math.imul(F0,g0),B=B+Math.imul(K0,x0)|0,y=y+Math.imul(K0,_0)|0,y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,_0)|0,B=B+Math.imul(V0,y0)|0,y=y+Math.imul(V0,w0)|0,y=y+Math.imul(U0,y0)|0,w=w+Math.imul(U0,w0)|0,B=B+Math.imul(Y0,p0)|0,y=y+Math.imul(Y0,c0)|0,y=y+Math.imul(Z0,p0)|0,w=w+Math.imul(Z0,c0)|0,B=B+Math.imul(i,d0)|0,y=y+Math.imul(i,b0)|0,y=y+Math.imul($0,d0)|0,w=w+Math.imul($0,b0)|0;var Z$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,B=Math.imul(O0,x0),y=Math.imul(O0,_0),y=y+Math.imul(F0,x0)|0,w=Math.imul(F0,_0),B=B+Math.imul(K0,y0)|0,y=y+Math.imul(K0,w0)|0,y=y+Math.imul(I0,y0)|0,w=w+Math.imul(I0,w0)|0,B=B+Math.imul(V0,p0)|0,y=y+Math.imul(V0,c0)|0,y=y+Math.imul(U0,p0)|0,w=w+Math.imul(U0,c0)|0,B=B+Math.imul(Y0,d0)|0,y=y+Math.imul(Y0,b0)|0,y=y+Math.imul(Z0,d0)|0,w=w+Math.imul(Z0,b0)|0;var G$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(G$>>>26)|0,G$&=67108863,B=Math.imul(O0,y0),y=Math.imul(O0,w0),y=y+Math.imul(F0,y0)|0,w=Math.imul(F0,w0),B=B+Math.imul(K0,p0)|0,y=y+Math.imul(K0,c0)|0,y=y+Math.imul(I0,p0)|0,w=w+Math.imul(I0,c0)|0,B=B+Math.imul(V0,d0)|0,y=y+Math.imul(V0,b0)|0,y=y+Math.imul(U0,d0)|0,w=w+Math.imul(U0,b0)|0;var V$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(V$>>>26)|0,V$&=67108863,B=Math.imul(O0,p0),y=Math.imul(O0,c0),y=y+Math.imul(F0,p0)|0,w=Math.imul(F0,c0),B=B+Math.imul(K0,d0)|0,y=y+Math.imul(K0,b0)|0,y=y+Math.imul(I0,d0)|0,w=w+Math.imul(I0,b0)|0;var U$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(U$>>>26)|0,U$&=67108863,B=Math.imul(O0,d0),y=Math.imul(O0,b0),y=y+Math.imul(F0,d0)|0,w=Math.imul(F0,b0);var X$=(_+B|0)+((y&8191)<<13)|0;return _=(w+(y>>>13)|0)+(X$>>>26)|0,X$&=67108863,x[0]=l0,x[1]=o0,x[2]=u0,x[3]=n0,x[4]=s0,x[5]=t0,x[6]=m0,x[7]=a0,x[8]=r0,x[9]=e0,x[10]=i0,x[11]=$$,x[12]=Q$,x[13]=Y$,x[14]=Z$,x[15]=G$,x[16]=V$,x[17]=U$,x[18]=X$,_!==0&&(x[19]=_,k.length++),k};Math.imul||(H=W);function E(q,j,k){k.negative=j.negative^q.negative,k.length=q.length+j.length;for(var g=0,N=0,x=0;x>>26)|0,N+=_>>>26,_&=67108863}k.words[x]=B,g=_,_=N}return g!==0?k.words[x]=g:k.length--,k.strip()}function T(q,j,k){var g=new D;return g.mulp(q,j,k)}V.prototype.mulTo=function(q,j){var k,g=this.length+q.length;return this.length===10&&q.length===10?k=H(this,q,j):g<63?k=W(this,q,j):g<1024?k=E(this,q,j):k=T(this,q,j),k};function D(q,j){this.x=q,this.y=j}D.prototype.makeRBT=function(q){for(var j=new Array(q),k=V.prototype._countBits(q)-1,g=0;g>=1;return g},D.prototype.permute=function(q,j,k,g,N,x){for(var _=0;_>>1)N++;return 1<>>13,k[2*x+1]=N&8191,N=N>>>13;for(x=2*j;x>=26,j+=g/67108864|0,j+=N>>>26,this.words[k]=N&67108863}return j!==0&&(this.words[k]=j,this.length++),this},V.prototype.muln=function(q){return this.clone().imuln(q)},V.prototype.sqr=function(){return this.mul(this)},V.prototype.isqr=function(){return this.imul(this.clone())},V.prototype.pow=function(q){var j=A(q);if(j.length===0)return new V(1);for(var k=this,g=0;g=0);var j=q%26,k=(q-j)/26,g=67108863>>>26-j<<26-j,N;if(j!==0){var x=0;for(N=0;N>>26-j}x&&(this.words[N]=x,this.length++)}if(k!==0){for(N=this.length-1;N>=0;N--)this.words[N+k]=this.words[N];for(N=0;N=0);var g;j?g=(j-j%26)/26:g=0;var N=q%26,x=Math.min((q-N)/26,this.length),_=67108863^67108863>>>N<x)for(this.length-=x,y=0;y=0&&(w!==0||y>=g);y--){var f=this.words[y]|0;this.words[y]=w<<26-N|f>>>N,w=f&_}return B&&w!==0&&(B.words[B.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},V.prototype.ishrn=function(q,j,k){return Z(this.negative===0),this.iushrn(q,j,k)},V.prototype.shln=function(q){return this.clone().ishln(q)},V.prototype.ushln=function(q){return this.clone().iushln(q)},V.prototype.shrn=function(q){return this.clone().ishrn(q)},V.prototype.ushrn=function(q){return this.clone().iushrn(q)},V.prototype.testn=function(q){Z(typeof q=="number"&&q>=0);var j=q%26,k=(q-j)/26,g=1<=0);var j=q%26,k=(q-j)/26;if(Z(this.negative===0,"imaskn works only with positive numbers"),this.length<=k)return this;if(j!==0&&k++,this.length=Math.min(k,this.length),j!==0){var g=67108863^67108863>>>j<=67108864;j++)this.words[j]-=67108864,j===this.length-1?this.words[j+1]=1:this.words[j+1]++;return this.length=Math.max(this.length,j+1),this},V.prototype.isubn=function(q){if(Z(typeof q=="number"),Z(q<67108864),q<0)return this.iaddn(-q);if(this.negative!==0)return this.negative=0,this.iaddn(q),this.negative=1,this;if(this.words[0]-=q,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var j=0;j>26)-(B/67108864|0),this.words[N+k]=x&67108863}for(;N>26,this.words[N+k]=x&67108863;if(_===0)return this.strip();for(Z(_===-1),_=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},V.prototype._wordDiv=function(q,j){var k=this.length-q.length,g=this.clone(),N=q,x=N.words[N.length-1]|0,_=this._countBits(x);k=26-_,k!==0&&(N=N.ushln(k),g.iushln(k),x=N.words[N.length-1]|0);var B=g.length-N.length,y;if(j!=="mod"){y=new V(null),y.length=B+1,y.words=new Array(y.length);for(var w=0;w=0;p--){var c=(g.words[N.length+p]|0)*67108864+(g.words[N.length+p-1]|0);for(c=Math.min(c/x|0,67108863),g._ishlnsubmul(N,c,p);g.negative!==0;)c--,g.negative=0,g._ishlnsubmul(N,1,p),g.isZero()||(g.negative^=1);y&&(y.words[p]=c)}return y&&y.strip(),g.strip(),j!=="div"&&k!==0&&g.iushrn(k),{div:y||null,mod:g}},V.prototype.divmod=function(q,j,k){if(Z(!q.isZero()),this.isZero())return{div:new V(0),mod:new V(0)};var g,N,x;return this.negative!==0&&q.negative===0?(x=this.neg().divmod(q,j),j!=="mod"&&(g=x.div.neg()),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.iadd(q)),{div:g,mod:N}):this.negative===0&&q.negative!==0?(x=this.divmod(q.neg(),j),j!=="mod"&&(g=x.div.neg()),{div:g,mod:x.mod}):(this.negative&q.negative)!==0?(x=this.neg().divmod(q.neg(),j),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.isub(q)),{div:x.div,mod:N}):q.length>this.length||this.cmp(q)<0?{div:new V(0),mod:this}:q.length===1?j==="div"?{div:this.divn(q.words[0]),mod:null}:j==="mod"?{div:null,mod:new V(this.modn(q.words[0]))}:{div:this.divn(q.words[0]),mod:new V(this.modn(q.words[0]))}:this._wordDiv(q,j)},V.prototype.div=function(q){return this.divmod(q,"div",!1).div},V.prototype.mod=function(q){return this.divmod(q,"mod",!1).mod},V.prototype.umod=function(q){return this.divmod(q,"mod",!0).mod},V.prototype.divRound=function(q){var j=this.divmod(q);if(j.mod.isZero())return j.div;var k=j.div.negative!==0?j.mod.isub(q):j.mod,g=q.ushrn(1),N=q.andln(1),x=k.cmp(g);return x<0||N===1&&x===0?j.div:j.div.negative!==0?j.div.isubn(1):j.div.iaddn(1)},V.prototype.modn=function(q){Z(q<=67108863);for(var j=(1<<26)%q,k=0,g=this.length-1;g>=0;g--)k=(j*k+(this.words[g]|0))%q;return k},V.prototype.idivn=function(q){Z(q<=67108863);for(var j=0,k=this.length-1;k>=0;k--){var g=(this.words[k]|0)+j*67108864;this.words[k]=g/q|0,j=g%q}return this.strip()},V.prototype.divn=function(q){return this.clone().idivn(q)},V.prototype.egcd=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=new V(0),_=new V(1),B=0;j.isEven()&&k.isEven();)j.iushrn(1),k.iushrn(1),++B;for(var y=k.clone(),w=j.clone();!j.isZero();){for(var f=0,p=1;(j.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(j.iushrn(f);f-- >0;)(g.isOdd()||N.isOdd())&&(g.iadd(y),N.isub(w)),g.iushrn(1),N.iushrn(1);for(var c=0,h=1;(k.words[0]&h)===0&&c<26;++c,h<<=1);if(c>0)for(k.iushrn(c);c-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(y),_.isub(w)),x.iushrn(1),_.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(x),N.isub(_)):(k.isub(j),x.isub(g),_.isub(N))}return{a:x,b:_,gcd:k.iushln(B)}},V.prototype._invmp=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=k.clone();j.cmpn(1)>0&&k.cmpn(1)>0;){for(var _=0,B=1;(j.words[0]&B)===0&&_<26;++_,B<<=1);if(_>0)for(j.iushrn(_);_-- >0;)g.isOdd()&&g.iadd(x),g.iushrn(1);for(var y=0,w=1;(k.words[0]&w)===0&&y<26;++y,w<<=1);if(y>0)for(k.iushrn(y);y-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(N)):(k.isub(j),N.isub(g))}var f;return j.cmpn(1)===0?f=g:f=N,f.cmpn(0)<0&&f.iadd(q),f},V.prototype.gcd=function(q){if(this.isZero())return q.abs();if(q.isZero())return this.abs();var j=this.clone(),k=q.clone();j.negative=0,k.negative=0;for(var g=0;j.isEven()&&k.isEven();g++)j.iushrn(1),k.iushrn(1);do{for(;j.isEven();)j.iushrn(1);for(;k.isEven();)k.iushrn(1);var N=j.cmp(k);if(N<0){var x=j;j=k,k=x}else if(N===0||k.cmpn(1)===0)break;j.isub(k)}while(!0);return k.iushln(g)},V.prototype.invm=function(q){return this.egcd(q).a.umod(q)},V.prototype.isEven=function(){return(this.words[0]&1)===0},V.prototype.isOdd=function(){return(this.words[0]&1)===1},V.prototype.andln=function(q){return this.words[0]&q},V.prototype.bincn=function(q){Z(typeof q=="number");var j=q%26,k=(q-j)/26,g=1<>>26,_&=67108863,this.words[x]=_}return N!==0&&(this.words[x]=N,this.length++),this},V.prototype.isZero=function(){return this.length===1&&this.words[0]===0},V.prototype.cmpn=function(q){var j=q<0;if(this.negative!==0&&!j)return-1;if(this.negative===0&&j)return 1;this.strip();var k;if(this.length>1)k=1;else{j&&(q=-q),Z(q<=67108863,"Number is too big");var g=this.words[0]|0;k=g===q?0:gq.length)return 1;if(this.length=0;k--){var g=this.words[k]|0,N=q.words[k]|0;if(g!==N){gN&&(j=1);break}}return j},V.prototype.gtn=function(q){return this.cmpn(q)===1},V.prototype.gt=function(q){return this.cmp(q)===1},V.prototype.gten=function(q){return this.cmpn(q)>=0},V.prototype.gte=function(q){return this.cmp(q)>=0},V.prototype.ltn=function(q){return this.cmpn(q)===-1},V.prototype.lt=function(q){return this.cmp(q)===-1},V.prototype.lten=function(q){return this.cmpn(q)<=0},V.prototype.lte=function(q){return this.cmp(q)<=0},V.prototype.eqn=function(q){return this.cmpn(q)===0},V.prototype.eq=function(q){return this.cmp(q)===0},V.red=function(q){return new S(q)},V.prototype.toRed=function(q){return Z(!this.red,"Already a number in reduction context"),Z(this.negative===0,"red works only with positives"),q.convertTo(this)._forceRed(q)},V.prototype.fromRed=function(){return Z(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},V.prototype._forceRed=function(q){return this.red=q,this},V.prototype.forceRed=function(q){return Z(!this.red,"Already a number in reduction context"),this._forceRed(q)},V.prototype.redAdd=function(q){return Z(this.red,"redAdd works only with red numbers"),this.red.add(this,q)},V.prototype.redIAdd=function(q){return Z(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,q)},V.prototype.redSub=function(q){return Z(this.red,"redSub works only with red numbers"),this.red.sub(this,q)},V.prototype.redISub=function(q){return Z(this.red,"redISub works only with red numbers"),this.red.isub(this,q)},V.prototype.redShl=function(q){return Z(this.red,"redShl works only with red numbers"),this.red.shl(this,q)},V.prototype.redMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.mul(this,q)},V.prototype.redIMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.imul(this,q)},V.prototype.redSqr=function(){return Z(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},V.prototype.redISqr=function(){return Z(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},V.prototype.redSqrt=function(){return Z(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},V.prototype.redInvm=function(){return Z(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},V.prototype.redNeg=function(){return Z(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},V.prototype.redPow=function(q){return Z(this.red&&!q.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,q)};var C={k256:null,p224:null,p192:null,p25519:null};function L(q,j){this.name=q,this.p=new V(j,16),this.n=this.p.bitLength(),this.k=new V(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}L.prototype._tmp=function(){var q=new V(null);return q.words=new Array(Math.ceil(this.n/13)),q},L.prototype.ireduce=function(q){var j=q,k;do this.split(j,this.tmp),j=this.imulK(j),j=j.iadd(this.tmp),k=j.bitLength();while(k>this.n);var g=k0?j.isub(this.p):j.strip!==void 0?j.strip():j._strip(),j},L.prototype.split=function(q,j){q.iushrn(this.n,0,j)},L.prototype.imulK=function(q){return q.imul(this.k)};function R(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}G(R,L),R.prototype.split=function(q,j){for(var k=4194303,g=Math.min(q.length,9),N=0;N>>22,x=_}x>>>=22,q.words[N-10]=x,x===0&&q.length>10?q.length-=10:q.length-=9},R.prototype.imulK=function(q){q.words[q.length]=0,q.words[q.length+1]=0,q.length+=2;for(var j=0,k=0;k>>=26,q.words[k]=N,j=g}return j!==0&&(q.words[q.length++]=j),q},V._prime=function(q){if(C[q])return C[q];var j;if(q==="k256")j=new R;else if(q==="p224")j=new P;else if(q==="p192")j=new z;else if(q==="p25519")j=new M;else throw new Error("Unknown prime "+q);return C[q]=j,j};function S(q){if(typeof q=="string"){var j=V._prime(q);this.m=j.p,this.prime=j}else Z(q.gtn(1),"modulus must be greater than 1"),this.m=q,this.prime=null}S.prototype._verify1=function(q){Z(q.negative===0,"red works only with positives"),Z(q.red,"red works only with red numbers")},S.prototype._verify2=function(q,j){Z((q.negative|j.negative)===0,"red works only with positives"),Z(q.red&&q.red===j.red,"red works only with red numbers")},S.prototype.imod=function(q){return this.prime?this.prime.ireduce(q)._forceRed(this):q.umod(this.m)._forceRed(this)},S.prototype.neg=function(q){return q.isZero()?q.clone():this.m.sub(q)._forceRed(this)},S.prototype.add=function(q,j){this._verify2(q,j);var k=q.add(j);return k.cmp(this.m)>=0&&k.isub(this.m),k._forceRed(this)},S.prototype.iadd=function(q,j){this._verify2(q,j);var k=q.iadd(j);return k.cmp(this.m)>=0&&k.isub(this.m),k},S.prototype.sub=function(q,j){this._verify2(q,j);var k=q.sub(j);return k.cmpn(0)<0&&k.iadd(this.m),k._forceRed(this)},S.prototype.isub=function(q,j){this._verify2(q,j);var k=q.isub(j);return k.cmpn(0)<0&&k.iadd(this.m),k},S.prototype.shl=function(q,j){return this._verify1(q),this.imod(q.ushln(j))},S.prototype.imul=function(q,j){return this._verify2(q,j),this.imod(q.imul(j))},S.prototype.mul=function(q,j){return this._verify2(q,j),this.imod(q.mul(j))},S.prototype.isqr=function(q){return this.imul(q,q.clone())},S.prototype.sqr=function(q){return this.mul(q,q)},S.prototype.sqrt=function(q){if(q.isZero())return q.clone();var j=this.m.andln(3);if(Z(j%2===1),j===3){var k=this.m.add(new V(1)).iushrn(2);return this.pow(q,k)}for(var g=this.m.subn(1),N=0;!g.isZero()&&g.andln(1)===0;)N++,g.iushrn(1);Z(!g.isZero());var x=new V(1).toRed(this),_=x.redNeg(),B=this.m.subn(1).iushrn(1),y=this.m.bitLength();for(y=new V(2*y*y).toRed(this);this.pow(y,B).cmp(_)!==0;)y.redIAdd(_);for(var w=this.pow(y,g),f=this.pow(q,g.addn(1).iushrn(1)),p=this.pow(q,g),c=N;p.cmp(x)!==0;){for(var h=p,d=0;h.cmp(x)!==0;d++)h=h.redSqr();Z(d=0;N--){for(var w=j.words[N],f=y-1;f>=0;f--){var p=w>>f&1;if(x!==g[0]&&(x=this.sqr(x)),p===0&&_===0){B=0;continue}_<<=1,_|=p,B++,!(B!==k&&(N!==0||f!==0))&&(x=this.mul(x,g[_]),B=0,_=0)}y=26}return x},S.prototype.convertTo=function(q){var j=q.umod(this.m);return j===q?j.clone():j},S.prototype.convertFrom=function(q){var j=q.clone();return j.red=null,j},V.mont=function(q){return new v(q)};function v(q){S.call(this,q),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new V(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}G(v,S),v.prototype.convertTo=function(q){return this.imod(q.ushln(this.shift))},v.prototype.convertFrom=function(q){var j=this.imod(q.mul(this.rinv));return j.red=null,j},v.prototype.imul=function(q,j){if(q.isZero()||j.isZero())return q.words[0]=0,q.length=1,q;var k=q.imul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.mul=function(q,j){if(q.isZero()||j.isZero())return new V(0)._forceRed(this);var k=q.mul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.invm=function(q){var j=this.imod(q._invmp(this.m).mul(this.r2));return j._forceRed(this)}})(typeof $>"u"||$,bZ)}}),cQ=P$({"node_modules/minimalistic-crypto-utils/lib/utils.js"(bZ){var $=bZ;function Q(G,V){if(Array.isArray(G))return G.slice();if(!G)return[];var U=[];if(typeof G!="string"){for(var X=0;X>8,J=K&255;I?U.push(I,J):U.push(J)}return U}$.toArray=Q;function Y(G){return G.length===1?"0"+G:G}$.zero2=Y;function Z(G){for(var V="",U=0;U(A>>1)-1?E=(A>>1)-T:E=T,W.isubn(E)):E=0,F[H]=E,W.iushrn(1)}return F}$.getNAF=G;function V(I,J){var O=[[],[]];I=I.clone(),J=J.clone();for(var F=0,A=0,W;I.cmpn(-F)>0||J.cmpn(-A)>0;){var H=I.andln(3)+F&3,E=J.andln(3)+A&3;H===3&&(H=-1),E===3&&(E=-1);var T;(H&1)===0?T=0:(W=I.andln(7)+F&7,(W===3||W===5)&&E===2?T=-H:T=H),O[0].push(T);var D;(E&1)===0?D=0:(W=J.andln(7)+A&7,(W===3||W===5)&&H===2?D=-E:D=E),O[1].push(D),2*F===T+1&&(F=1-F),2*A===D+1&&(A=1-A),I.iushrn(1),J.iushrn(1)}return O}$.getJSF=V;function U(I,J,O){var F="_"+J;I.prototype[J]=function(){return this[F]!==void 0?this[F]:this[F]=O.call(this)}}$.cachedProperty=U;function X(I){return typeof I=="string"?$.toArray(I,"hex"):I}$.parseBytes=X;function K(I){return new Q(I,"hex","le")}$.intFromLE=K}}),dQ=P$({"node_modules/elliptic/lib/elliptic/curve/base.js"(bZ,$){var Q=pQ(),Y=hQ(),Z=Y.getNAF,G=Y.getJSF,V=Y.assert;function U(K,I){this.type=K,this.p=new Q(I.p,16),this.red=I.prime?Q.red(I.prime):Q.mont(this.p),this.zero=new Q(0).toRed(this.red),this.one=new Q(1).toRed(this.red),this.two=new Q(2).toRed(this.red),this.n=I.n&&new Q(I.n,16),this.g=I.g&&this.pointFromJSON(I.g,I.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var J=this.n&&this.p.div(this.n);!J||J.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}$.exports=U,U.prototype.point=function(){throw new Error("Not implemented")},U.prototype.validate=function(){throw new Error("Not implemented")},U.prototype._fixedNafMul=function(K,I){V(K.precomputed);var J=K._getDoubles(),O=Z(I,1,this._bitLength),F=(1<=W;E--)H=(H<<1)+O[E];A.push(H)}for(var T=this.jpoint(null,null,null),D=this.jpoint(null,null,null),C=F;C>0;C--){for(W=0;W=0;H--){for(var E=0;H>=0&&A[H]===0;H--)E++;if(H>=0&&E++,W=W.dblp(E),H<0)break;var T=A[H];V(T!==0),K.type==="affine"?T>0?W=W.mixedAdd(F[T-1>>1]):W=W.mixedAdd(F[-T-1>>1].neg()):T>0?W=W.add(F[T-1>>1]):W=W.add(F[-T-1>>1].neg())}return K.type==="affine"?W.toP():W},U.prototype._wnafMulAdd=function(K,I,J,O,F){var A=this._wnafT1,W=this._wnafT2,H=this._wnafT3,E=0,T,D,C;for(T=0;T=1;T-=2){var R=T-1,P=T;if(A[R]!==1||A[P]!==1){H[R]=Z(J[R],A[R],this._bitLength),H[P]=Z(J[P],A[P],this._bitLength),E=Math.max(H[R].length,E),E=Math.max(H[P].length,E);continue}var z=[I[R],null,null,I[P]];I[R].y.cmp(I[P].y)===0?(z[1]=I[R].add(I[P]),z[2]=I[R].toJ().mixedAdd(I[P].neg())):I[R].y.cmp(I[P].y.redNeg())===0?(z[1]=I[R].toJ().mixedAdd(I[P]),z[2]=I[R].add(I[P].neg())):(z[1]=I[R].toJ().mixedAdd(I[P]),z[2]=I[R].toJ().mixedAdd(I[P].neg()));var M=[-3,-1,-5,-7,0,7,5,1,3],S=G(J[R],J[P]);for(E=Math.max(S[0].length,E),H[R]=new Array(E),H[P]=new Array(E),D=0;D=0;T--){for(var g=0;T>=0;){var N=!0;for(D=0;D=0&&g++,j=j.dblp(g),T<0)break;for(D=0;D0?C=W[D][x-1>>1]:x<0&&(C=W[D][-x-1>>1].neg()),C.type==="affine"?j=j.mixedAdd(C):j=j.add(C))}}for(T=0;T=Math.ceil((K.bitLength()+1)/I.step):!1},X.prototype._getDoubles=function(K,I){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var J=[this],O=this,F=0;F=0&&(R=T,P=D),C.negative&&(C=C.neg(),L=L.neg()),R.negative&&(R=R.neg(),P=P.neg()),[{a:C,b:L},{a:R,b:P}]},U.prototype._endoSplit=function(I){var J=this.endo.basis,O=J[0],F=J[1],A=F.b.mul(I).divRound(this.n),W=O.b.neg().mul(I).divRound(this.n),H=A.mul(O.a),E=W.mul(F.a),T=A.mul(O.b),D=W.mul(F.b),C=I.sub(H).sub(E),L=T.add(D).neg();return{k1:C,k2:L}},U.prototype.pointFromX=function(I,J){I=new Y(I,16),I.red||(I=I.toRed(this.red));var O=I.redSqr().redMul(I).redIAdd(I.redMul(this.a)).redIAdd(this.b),F=O.redSqrt();if(F.redSqr().redSub(O).cmp(this.zero)!==0)throw new Error("invalid point");var A=F.fromRed().isOdd();return(J&&!A||!J&&A)&&(F=F.redNeg()),this.point(I,F)},U.prototype.validate=function(I){if(I.inf)return!0;var{x:J,y:O}=I,F=this.a.redMul(J),A=J.redSqr().redMul(J).redIAdd(F).redIAdd(this.b);return O.redSqr().redISub(A).cmpn(0)===0},U.prototype._endoWnafMulAdd=function(I,J,O){for(var F=this._endoWnafT1,A=this._endoWnafT2,W=0;W":""},X.prototype.isInfinity=function(){return this.inf},X.prototype.add=function(I){if(this.inf)return I;if(I.inf)return this;if(this.eq(I))return this.dbl();if(this.neg().eq(I))return this.curve.point(null,null);if(this.x.cmp(I.x)===0)return this.curve.point(null,null);var J=this.y.redSub(I.y);J.cmpn(0)!==0&&(J=J.redMul(this.x.redSub(I.x).redInvm()));var O=J.redSqr().redISub(this.x).redISub(I.x),F=J.redMul(this.x.redSub(O)).redISub(this.y);return this.curve.point(O,F)},X.prototype.dbl=function(){if(this.inf)return this;var I=this.y.redAdd(this.y);if(I.cmpn(0)===0)return this.curve.point(null,null);var J=this.curve.a,O=this.x.redSqr(),F=I.redInvm(),A=O.redAdd(O).redIAdd(O).redIAdd(J).redMul(F),W=A.redSqr().redISub(this.x.redAdd(this.x)),H=A.redMul(this.x.redSub(W)).redISub(this.y);return this.curve.point(W,H)},X.prototype.getX=function(){return this.x.fromRed()},X.prototype.getY=function(){return this.y.fromRed()},X.prototype.mul=function(I){return I=new Y(I,16),this.isInfinity()?this:this._hasDoubles(I)?this.curve._fixedNafMul(this,I):this.curve.endo?this.curve._endoWnafMulAdd([this],[I]):this.curve._wnafMul(this,I)},X.prototype.mulAdd=function(I,J,O){var F=[this,J],A=[I,O];return this.curve.endo?this.curve._endoWnafMulAdd(F,A):this.curve._wnafMulAdd(1,F,A,2)},X.prototype.jmulAdd=function(I,J,O){var F=[this,J],A=[I,O];return this.curve.endo?this.curve._endoWnafMulAdd(F,A,!0):this.curve._wnafMulAdd(1,F,A,2,!0)},X.prototype.eq=function(I){return this===I||this.inf===I.inf&&(this.inf||this.x.cmp(I.x)===0&&this.y.cmp(I.y)===0)},X.prototype.neg=function(I){if(this.inf)return this;var J=this.curve.point(this.x,this.y.redNeg());if(I&&this.precomputed){var O=this.precomputed,F=function(A){return A.neg()};J.precomputed={naf:O.naf&&{wnd:O.naf.wnd,points:O.naf.points.map(F)},doubles:O.doubles&&{step:O.doubles.step,points:O.doubles.points.map(F)}}}return J},X.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var I=this.curve.jpoint(this.x,this.y,this.curve.one);return I};function K(I,J,O,F){G.BasePoint.call(this,I,"jacobian"),J===null&&O===null&&F===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Y(0)):(this.x=new Y(J,16),this.y=new Y(O,16),this.z=new Y(F,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Z(K,G.BasePoint),U.prototype.jpoint=function(I,J,O){return new K(this,I,J,O)},K.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var I=this.z.redInvm(),J=I.redSqr(),O=this.x.redMul(J),F=this.y.redMul(J).redMul(I);return this.curve.point(O,F)},K.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},K.prototype.add=function(I){if(this.isInfinity())return I;if(I.isInfinity())return this;var J=I.z.redSqr(),O=this.z.redSqr(),F=this.x.redMul(J),A=I.x.redMul(O),W=this.y.redMul(J.redMul(I.z)),H=I.y.redMul(O.redMul(this.z)),E=F.redSub(A),T=W.redSub(H);if(E.cmpn(0)===0)return T.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var D=E.redSqr(),C=D.redMul(E),L=F.redMul(D),R=T.redSqr().redIAdd(C).redISub(L).redISub(L),P=T.redMul(L.redISub(R)).redISub(W.redMul(C)),z=this.z.redMul(I.z).redMul(E);return this.curve.jpoint(R,P,z)},K.prototype.mixedAdd=function(I){if(this.isInfinity())return I.toJ();if(I.isInfinity())return this;var J=this.z.redSqr(),O=this.x,F=I.x.redMul(J),A=this.y,W=I.y.redMul(J).redMul(this.z),H=O.redSub(F),E=A.redSub(W);if(H.cmpn(0)===0)return E.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var T=H.redSqr(),D=T.redMul(H),C=O.redMul(T),L=E.redSqr().redIAdd(D).redISub(C).redISub(C),R=E.redMul(C.redISub(L)).redISub(A.redMul(D)),P=this.z.redMul(H);return this.curve.jpoint(L,R,P)},K.prototype.dblp=function(I){if(I===0)return this;if(this.isInfinity())return this;if(!I)return this.dbl();var J;if(this.curve.zeroA||this.curve.threeA){var O=this;for(J=0;J=0)return!1;if(O.redIAdd(A),this.x.cmp(O)===0)return!0}},K.prototype.inspect=function(){return this.isInfinity()?"":""},K.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),lQ=P$({"node_modules/elliptic/lib/elliptic/curve/mont.js"(bZ,$){var Q=pQ(),Y=v$(),Z=dQ(),G=hQ();function V(X){Z.call(this,"mont",X),this.a=new Q(X.a,16).toRed(this.red),this.b=new Q(X.b,16).toRed(this.red),this.i4=new Q(4).toRed(this.red).redInvm(),this.two=new Q(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Y(V,Z),$.exports=V,V.prototype.validate=function(X){var K=X.normalize().x,I=K.redSqr(),J=I.redMul(K).redAdd(I.redMul(this.a)).redAdd(K),O=J.redSqrt();return O.redSqr().cmp(J)===0};function U(X,K,I){Z.BasePoint.call(this,X,"projective"),K===null&&I===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Q(K,16),this.z=new Q(I,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Y(U,Z.BasePoint),V.prototype.decodePoint=function(X,K){return this.point(G.toArray(X,K),1)},V.prototype.point=function(X,K){return new U(this,X,K)},V.prototype.pointFromJSON=function(X){return U.fromJSON(this,X)},U.prototype.precompute=function(){},U.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},U.fromJSON=function(X,K){return new U(X,K[0],K[1]||X.one)},U.prototype.inspect=function(){return this.isInfinity()?"":""},U.prototype.isInfinity=function(){return this.z.cmpn(0)===0},U.prototype.dbl=function(){var X=this.x.redAdd(this.z),K=X.redSqr(),I=this.x.redSub(this.z),J=I.redSqr(),O=K.redSub(J),F=K.redMul(J),A=O.redMul(J.redAdd(this.curve.a24.redMul(O)));return this.curve.point(F,A)},U.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},U.prototype.diffAdd=function(X,K){var I=this.x.redAdd(this.z),J=this.x.redSub(this.z),O=X.x.redAdd(X.z),F=X.x.redSub(X.z),A=F.redMul(I),W=O.redMul(J),H=K.z.redMul(A.redAdd(W).redSqr()),E=K.x.redMul(A.redISub(W).redSqr());return this.curve.point(H,E)},U.prototype.mul=function(X){for(var K=X.clone(),I=this,J=this.curve.point(null,null),O=this,F=[];K.cmpn(0)!==0;K.iushrn(1))F.push(K.andln(1));for(var A=F.length-1;A>=0;A--)F[A]===0?(I=I.diffAdd(J,O),J=J.dbl()):(J=I.diffAdd(J,O),I=I.dbl());return J},U.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},U.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},U.prototype.eq=function(X){return this.getX().cmp(X.getX())===0},U.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},U.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),oQ=P$({"node_modules/elliptic/lib/elliptic/curve/edwards.js"(bZ,$){var Q=hQ(),Y=pQ(),Z=v$(),G=dQ(),V=Q.assert;function U(K){this.twisted=(K.a|0)!==1,this.mOneA=this.twisted&&(K.a|0)===-1,this.extended=this.mOneA,G.call(this,"edwards",K),this.a=new Y(K.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Y(K.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Y(K.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),V(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(K.c|0)===1}Z(U,G),$.exports=U,U.prototype._mulA=function(K){return this.mOneA?K.redNeg():this.a.redMul(K)},U.prototype._mulC=function(K){return this.oneC?K:this.c.redMul(K)},U.prototype.jpoint=function(K,I,J,O){return this.point(K,I,J,O)},U.prototype.pointFromX=function(K,I){K=new Y(K,16),K.red||(K=K.toRed(this.red));var J=K.redSqr(),O=this.c2.redSub(this.a.redMul(J)),F=this.one.redSub(this.c2.redMul(this.d).redMul(J)),A=O.redMul(F.redInvm()),W=A.redSqrt();if(W.redSqr().redSub(A).cmp(this.zero)!==0)throw new Error("invalid point");var H=W.fromRed().isOdd();return(I&&!H||!I&&H)&&(W=W.redNeg()),this.point(K,W)},U.prototype.pointFromY=function(K,I){K=new Y(K,16),K.red||(K=K.toRed(this.red));var J=K.redSqr(),O=J.redSub(this.c2),F=J.redMul(this.d).redMul(this.c2).redSub(this.a),A=O.redMul(F.redInvm());if(A.cmp(this.zero)===0){if(I)throw new Error("invalid point");return this.point(this.zero,K)}var W=A.redSqrt();if(W.redSqr().redSub(A).cmp(this.zero)!==0)throw new Error("invalid point");return W.fromRed().isOdd()!==I&&(W=W.redNeg()),this.point(W,K)},U.prototype.validate=function(K){if(K.isInfinity())return!0;K.normalize();var I=K.x.redSqr(),J=K.y.redSqr(),O=I.redMul(this.a).redAdd(J),F=this.c2.redMul(this.one.redAdd(this.d.redMul(I).redMul(J)));return O.cmp(F)===0};function X(K,I,J,O,F){G.BasePoint.call(this,K,"projective"),I===null&&J===null&&O===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Y(I,16),this.y=new Y(J,16),this.z=O?new Y(O,16):this.curve.one,this.t=F&&new Y(F,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Z(X,G.BasePoint),U.prototype.pointFromJSON=function(K){return X.fromJSON(this,K)},U.prototype.point=function(K,I,J,O){return new X(this,K,I,J,O)},X.fromJSON=function(K,I){return new X(K,I[0],I[1],I[2])},X.prototype.inspect=function(){return this.isInfinity()?"":""},X.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},X.prototype._extDbl=function(){var K=this.x.redSqr(),I=this.y.redSqr(),J=this.z.redSqr();J=J.redIAdd(J);var O=this.curve._mulA(K),F=this.x.redAdd(this.y).redSqr().redISub(K).redISub(I),A=O.redAdd(I),W=A.redSub(J),H=O.redSub(I),E=F.redMul(W),T=A.redMul(H),D=F.redMul(H),C=W.redMul(A);return this.curve.point(E,T,C,D)},X.prototype._projDbl=function(){var K=this.x.redAdd(this.y).redSqr(),I=this.x.redSqr(),J=this.y.redSqr(),O,F,A,W,H,E;if(this.curve.twisted){W=this.curve._mulA(I);var T=W.redAdd(J);this.zOne?(O=K.redSub(I).redSub(J).redMul(T.redSub(this.curve.two)),F=T.redMul(W.redSub(J)),A=T.redSqr().redSub(T).redSub(T)):(H=this.z.redSqr(),E=T.redSub(H).redISub(H),O=K.redSub(I).redISub(J).redMul(E),F=T.redMul(W.redSub(J)),A=T.redMul(E))}else W=I.redAdd(J),H=this.curve._mulC(this.z).redSqr(),E=W.redSub(H).redSub(H),O=this.curve._mulC(K.redISub(W)).redMul(E),F=this.curve._mulC(W).redMul(I.redISub(J)),A=W.redMul(E);return this.curve.point(O,F,A)},X.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},X.prototype._extAdd=function(K){var I=this.y.redSub(this.x).redMul(K.y.redSub(K.x)),J=this.y.redAdd(this.x).redMul(K.y.redAdd(K.x)),O=this.t.redMul(this.curve.dd).redMul(K.t),F=this.z.redMul(K.z.redAdd(K.z)),A=J.redSub(I),W=F.redSub(O),H=F.redAdd(O),E=J.redAdd(I),T=A.redMul(W),D=H.redMul(E),C=A.redMul(E),L=W.redMul(H);return this.curve.point(T,D,L,C)},X.prototype._projAdd=function(K){var I=this.z.redMul(K.z),J=I.redSqr(),O=this.x.redMul(K.x),F=this.y.redMul(K.y),A=this.curve.d.redMul(O).redMul(F),W=J.redSub(A),H=J.redAdd(A),E=this.x.redAdd(this.y).redMul(K.x.redAdd(K.y)).redISub(O).redISub(F),T=I.redMul(W).redMul(E),D,C;return this.curve.twisted?(D=I.redMul(H).redMul(F.redSub(this.curve._mulA(O))),C=W.redMul(H)):(D=I.redMul(H).redMul(F.redSub(O)),C=this.curve._mulC(W).redMul(H)),this.curve.point(T,D,C)},X.prototype.add=function(K){return this.isInfinity()?K:K.isInfinity()?this:this.curve.extended?this._extAdd(K):this._projAdd(K)},X.prototype.mul=function(K){return this._hasDoubles(K)?this.curve._fixedNafMul(this,K):this.curve._wnafMul(this,K)},X.prototype.mulAdd=function(K,I,J){return this.curve._wnafMulAdd(1,[this,I],[K,J],2,!1)},X.prototype.jmulAdd=function(K,I,J){return this.curve._wnafMulAdd(1,[this,I],[K,J],2,!0)},X.prototype.normalize=function(){if(this.zOne)return this;var K=this.z.redInvm();return this.x=this.x.redMul(K),this.y=this.y.redMul(K),this.t&&(this.t=this.t.redMul(K)),this.z=this.curve.one,this.zOne=!0,this},X.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},X.prototype.getX=function(){return this.normalize(),this.x.fromRed()},X.prototype.getY=function(){return this.normalize(),this.y.fromRed()},X.prototype.eq=function(K){return this===K||this.getX().cmp(K.getX())===0&&this.getY().cmp(K.getY())===0},X.prototype.eqXToP=function(K){var I=K.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(I)===0)return!0;for(var J=K.clone(),O=this.curve.redN.redMul(this.z);;){if(J.iadd(this.curve.n),J.cmp(this.curve.p)>=0)return!1;if(I.redIAdd(O),this.x.cmp(I)===0)return!0}},X.prototype.toP=X.prototype.normalize,X.prototype.mixedAdd=X.prototype.add}}),uQ=P$({"node_modules/elliptic/lib/elliptic/curve/index.js"(bZ){var $=bZ;$.base=dQ(),$.short=bQ(),$.mont=lQ(),$.edwards=oQ()}}),nQ=P$({"node_modules/hash.js/lib/hash/utils.js"(bZ){var $=i$(),Q=v$();bZ.inherits=Q;function Y(j,k){return(j.charCodeAt(k)&64512)!==55296||k<0||k+1>=j.length?!1:(j.charCodeAt(k+1)&64512)===56320}function Z(j,k){if(Array.isArray(j))return j.slice();if(!j)return[];var g=[];if(typeof j=="string")if(k){if(k==="hex")for(j=j.replace(/[^a-z0-9]+/gi,""),j.length%2!==0&&(j="0"+j),x=0;x>6|192,g[N++]=_&63|128):Y(j,x)?(_=65536+((_&1023)<<10)+(j.charCodeAt(++x)&1023),g[N++]=_>>18|240,g[N++]=_>>12&63|128,g[N++]=_>>6&63|128,g[N++]=_&63|128):(g[N++]=_>>12|224,g[N++]=_>>6&63|128,g[N++]=_&63|128)}else for(x=0;x>>24|j>>>8&65280|j<<8&16711680|(j&255)<<24;return k>>>0}bZ.htonl=V;function U(j,k){for(var g="",N=0;N>>0}return _}bZ.join32=I;function J(j,k){for(var g=new Array(j.length*4),N=0,x=0;N>>24,g[x+1]=_>>>16&255,g[x+2]=_>>>8&255,g[x+3]=_&255):(g[x+3]=_>>>24,g[x+2]=_>>>16&255,g[x+1]=_>>>8&255,g[x]=_&255)}return g}bZ.split32=J;function O(j,k){return j>>>k|j<<32-k}bZ.rotr32=O;function F(j,k){return j<>>32-k}bZ.rotl32=F;function A(j,k){return j+k>>>0}bZ.sum32=A;function W(j,k,g){return j+k+g>>>0}bZ.sum32_3=W;function H(j,k,g,N){return j+k+g+N>>>0}bZ.sum32_4=H;function E(j,k,g,N,x){return j+k+g+N+x>>>0}bZ.sum32_5=E;function T(j,k,g,N){var x=j[k],_=j[k+1],B=N+_>>>0,y=(B>>0,j[k+1]=B}bZ.sum64=T;function D(j,k,g,N){var x=k+N>>>0,_=(x>>0}bZ.sum64_hi=D;function C(j,k,g,N){var x=k+N;return x>>>0}bZ.sum64_lo=C;function L(j,k,g,N,x,_,B,y){var w=0,f=k;f=f+N>>>0,w+=f>>0,w+=f<_?1:0,f=f+y>>>0,w+=f>>0}bZ.sum64_4_hi=L;function R(j,k,g,N,x,_,B,y){var w=k+N+_+y;return w>>>0}bZ.sum64_4_lo=R;function P(j,k,g,N,x,_,B,y,w,f){var p=0,c=k;c=c+N>>>0,p+=c>>0,p+=c<_?1:0,c=c+y>>>0,p+=c>>0,p+=c>>0}bZ.sum64_5_hi=P;function z(j,k,g,N,x,_,B,y,w,f){var p=k+N+_+y+f;return p>>>0}bZ.sum64_5_lo=z;function M(j,k,g){var N=k<<32-g|j>>>g;return N>>>0}bZ.rotr64_hi=M;function S(j,k,g){var N=j<<32-g|k>>>g;return N>>>0}bZ.rotr64_lo=S;function v(j,k,g){return j>>>g}bZ.shr64_hi=v;function q(j,k,g){var N=j<<32-g|k>>>g;return N>>>0}bZ.shr64_lo=q}}),sQ=P$({"node_modules/hash.js/lib/hash/common.js"(bZ){var $=nQ(),Q=i$();function Y(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}bZ.BlockHash=Y,Y.prototype.update=function(Z,G){if(Z=$.toArray(Z,G),this.pending?this.pending=this.pending.concat(Z):this.pending=Z,this.pendingTotal+=Z.length,this.pending.length>=this._delta8){Z=this.pending;var V=Z.length%this._delta8;this.pending=Z.slice(Z.length-V,Z.length),this.pending.length===0&&(this.pending=null),Z=$.join32(Z,0,Z.length-V,this.endian);for(var U=0;U>>24&255,U[X++]=Z>>>16&255,U[X++]=Z>>>8&255,U[X++]=Z&255}else for(U[X++]=Z&255,U[X++]=Z>>>8&255,U[X++]=Z>>>16&255,U[X++]=Z>>>24&255,U[X++]=0,U[X++]=0,U[X++]=0,U[X++]=0,K=8;K>>3}bZ.g0_256=K;function I(J){return Q(J,17)^Q(J,19)^J>>>10}bZ.g1_256=I}}),mQ=P$({"node_modules/hash.js/lib/hash/sha/1.js"(bZ,$){var Q=nQ(),Y=sQ(),Z=tQ(),G=Q.rotl32,V=Q.sum32,U=Q.sum32_5,X=Z.ft_1,K=Y.BlockHash,I=[1518500249,1859775393,2400959708,3395469782];function J(){if(!(this instanceof J))return new J;K.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Q.inherits(J,K),$.exports=J,J.blockSize=512,J.outSize=160,J.hmacStrength=80,J.padLength=64,J.prototype._update=function(O,F){for(var A=this.W,W=0;W<16;W++)A[W]=O[F+W];for(;Wthis.blockSize&&(G=new this.Hash().update(G).digest()),Y(G.length<=this.blockSize);for(var V=G.length;V=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(U,X,K)}$.exports=G,G.prototype._init=function(V,U,X){var K=V.concat(U).concat(X);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var I=0;I=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(V.concat(X||[])),this._reseed=1},G.prototype.generate=function(V,U,X,K){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof U!="string"&&(K=X,X=U,U=null),X&&(X=Y.toArray(X,K||"hex"),this._update(X));for(var I=[];I.length"}}}),KY=P$({"node_modules/elliptic/lib/elliptic/ec/signature.js"(bZ,$){var Q=pQ(),Y=hQ(),Z=Y.assert;function G(I,J){if(I instanceof G)return I;this._importDER(I,J)||(Z(I.r&&I.s,"Signature without r or s"),this.r=new Q(I.r,16),this.s=new Q(I.s,16),I.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=I.recoveryParam)}$.exports=G;function V(){this.place=0}function U(I,J){var O=I[J.place++];if(!(O&128))return O;var F=O&15;if(F===0||F>4)return!1;for(var A=0,W=0,H=J.place;W>>=0;return A<=127?!1:(J.place=H,A)}function X(I){for(var J=0,O=I.length-1;!I[J]&&!(I[J+1]&128)&&J>>3);for(I.push(O|128);--O;)I.push(J>>>(O<<3)&255);I.push(J)}G.prototype.toDER=function(I){var J=this.r.toArray(),O=this.s.toArray();for(J[0]&128&&(J=[0].concat(J)),O[0]&128&&(O=[0].concat(O)),J=X(J),O=X(O);!O[0]&&!(O[1]&128);)O=O.slice(1);var F=[2];K(F,J.length),F=F.concat(J),F.push(2),K(F,O.length);var A=F.concat(O),W=[48];return K(W,A.length),W=W.concat(A),Y.encode(W,I)}}}),IY=P$({"node_modules/elliptic/lib/elliptic/ec/index.js"(bZ,$){var Q=pQ(),Y=UY(),Z=hQ(),G=VY(),V=kQ(),U=Z.assert,X=XY(),K=KY();function I(J){if(!(this instanceof I))return new I(J);typeof J=="string"&&(U(Object.prototype.hasOwnProperty.call(G,J),"Unknown curve "+J),J=G[J]),J instanceof G.PresetCurve&&(J={curve:J}),this.curve=J.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=J.curve.g,this.g.precompute(J.curve.n.bitLength()+1),this.hash=J.hash||J.curve.hash}$.exports=I,I.prototype.keyPair=function(J){return new X(this,J)},I.prototype.keyFromPrivate=function(J,O){return X.fromPrivate(this,J,O)},I.prototype.keyFromPublic=function(J,O){return X.fromPublic(this,J,O)},I.prototype.genKeyPair=function(J){J||(J={});for(var O=new Y({hash:this.hash,pers:J.pers,persEnc:J.persEnc||"utf8",entropy:J.entropy||V(this.hash.hmacStrength),entropyEnc:J.entropy&&J.entropyEnc||"utf8",nonce:this.n.toArray()}),F=this.n.byteLength(),A=this.n.sub(new Q(2));;){var W=new Q(O.generate(F));if(!(W.cmp(A)>0))return W.iaddn(1),this.keyFromPrivate(W)}},I.prototype._truncateToN=function(J,O){var F=J.byteLength()*8-this.n.bitLength();return F>0&&(J=J.ushrn(F)),!O&&J.cmp(this.n)>=0?J.sub(this.n):J},I.prototype.sign=function(J,O,F,A){typeof F=="object"&&(A=F,F=null),A||(A={}),O=this.keyFromPrivate(O,F),J=this._truncateToN(new Q(J,16));for(var W=this.n.byteLength(),H=O.getPrivate().toArray("be",W),E=J.toArray("be",W),T=new Y({hash:this.hash,entropy:H,nonce:E,pers:A.pers,persEnc:A.persEnc||"utf8"}),D=this.n.sub(new Q(1)),C=0;;C++){var L=A.k?A.k(C):new Q(T.generate(this.n.byteLength()));if(L=this._truncateToN(L,!0),!(L.cmpn(1)<=0||L.cmp(D)>=0)){var R=this.g.mul(L);if(!R.isInfinity()){var P=R.getX(),z=P.umod(this.n);if(z.cmpn(0)!==0){var M=L.invm(this.n).mul(z.mul(O.getPrivate()).iadd(J));if(M=M.umod(this.n),M.cmpn(0)!==0){var S=(R.getY().isOdd()?1:0)|(P.cmp(z)!==0?2:0);return A.canonical&&M.cmp(this.nh)>0&&(M=this.n.sub(M),S^=1),new K({r:z,s:M,recoveryParam:S})}}}}}},I.prototype.verify=function(J,O,F,A){J=this._truncateToN(new Q(J,16)),F=this.keyFromPublic(F,A),O=new K(O,"hex");var{r:W,s:H}=O;if(W.cmpn(1)<0||W.cmp(this.n)>=0||H.cmpn(1)<0||H.cmp(this.n)>=0)return!1;var E=H.invm(this.n),T=E.mul(J).umod(this.n),D=E.mul(W).umod(this.n),C;return this.curve._maxwellTrick?(C=this.g.jmulAdd(T,F.getPublic(),D),C.isInfinity()?!1:C.eqXToP(W)):(C=this.g.mulAdd(T,F.getPublic(),D),C.isInfinity()?!1:C.getX().umod(this.n).cmp(W)===0)},I.prototype.recoverPubKey=function(J,O,F,A){U((3&F)===F,"The recovery param is more than two bits"),O=new K(O,A);var W=this.n,H=new Q(J),E=O.r,T=O.s,D=F&1,C=F>>1;if(E.cmp(this.curve.p.umod(this.curve.n))>=0&&C)throw new Error("Unable to find sencond key candinate");C?E=this.curve.pointFromX(E.add(this.curve.n),D):E=this.curve.pointFromX(E,D);var L=O.r.invm(W),R=W.sub(H).mul(L).umod(W),P=T.mul(L).umod(W);return this.g.mulAdd(R,E,P)},I.prototype.getKeyRecoveryParam=function(J,O,F,A){if(O=new K(O,A),O.recoveryParam!==null)return O.recoveryParam;for(var W=0;W<4;W++){var H;try{H=this.recoverPubKey(J,O,W)}catch{continue}if(H.eq(F))return W}throw new Error("Unable to find valid recovery factor")}}}),JY=P$({"node_modules/elliptic/lib/elliptic/eddsa/key.js"(bZ,$){var Q=hQ(),Y=Q.assert,Z=Q.parseBytes,G=Q.cachedProperty;function V(U,X){this.eddsa=U,this._secret=Z(X.secret),U.isPoint(X.pub)?this._pub=X.pub:this._pubBytes=Z(X.pub)}V.fromPublic=function(U,X){return X instanceof V?X:new V(U,{pub:X})},V.fromSecret=function(U,X){return X instanceof V?X:new V(U,{secret:X})},V.prototype.secret=function(){return this._secret},G(V,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),G(V,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),G(V,"privBytes",function(){var U=this.eddsa,X=this.hash(),K=U.encodingLength-1,I=X.slice(0,U.encodingLength);return I[0]&=248,I[K]&=127,I[K]|=64,I}),G(V,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),G(V,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),G(V,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),V.prototype.sign=function(U){return Y(this._secret,"KeyPair can only verify"),this.eddsa.sign(U,this)},V.prototype.verify=function(U,X){return this.eddsa.verify(U,X,this)},V.prototype.getSecret=function(U){return Y(this._secret,"KeyPair is public only"),Q.encode(this.secret(),U)},V.prototype.getPublic=function(U){return Q.encode(this.pubBytes(),U)},$.exports=V}}),OY=P$({"node_modules/elliptic/lib/elliptic/eddsa/signature.js"(bZ,$){var Q=pQ(),Y=hQ(),Z=Y.assert,G=Y.cachedProperty,V=Y.parseBytes;function U(X,K){this.eddsa=X,typeof K!="object"&&(K=V(K)),Array.isArray(K)&&(K={R:K.slice(0,X.encodingLength),S:K.slice(X.encodingLength)}),Z(K.R&&K.S,"Signature without R or S"),X.isPoint(K.R)&&(this._R=K.R),K.S instanceof Q&&(this._S=K.S),this._Rencoded=Array.isArray(K.R)?K.R:K.Rencoded,this._Sencoded=Array.isArray(K.S)?K.S:K.Sencoded}G(U,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),G(U,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),G(U,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),G(U,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),U.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},U.prototype.toHex=function(){return Y.encode(this.toBytes(),"hex").toUpperCase()},$.exports=U}}),FY=P$({"node_modules/elliptic/lib/elliptic/eddsa/index.js"(bZ,$){var Q=ZY(),Y=VY(),Z=hQ(),G=Z.assert,V=Z.parseBytes,U=JY(),X=OY();function K(I){if(G(I==="ed25519","only tested with ed25519 so far"),!(this instanceof K))return new K(I);I=Y[I].curve,this.curve=I,this.g=I.g,this.g.precompute(I.n.bitLength()+1),this.pointClass=I.point().constructor,this.encodingLength=Math.ceil(I.n.bitLength()/8),this.hash=Q.sha512}$.exports=K,K.prototype.sign=function(I,J){I=V(I);var O=this.keyFromSecret(J),F=this.hashInt(O.messagePrefix(),I),A=this.g.mul(F),W=this.encodePoint(A),H=this.hashInt(W,O.pubBytes(),I).mul(O.priv()),E=F.add(H).umod(this.curve.n);return this.makeSignature({R:A,S:E,Rencoded:W})},K.prototype.verify=function(I,J,O){I=V(I),J=this.makeSignature(J);var F=this.keyFromPublic(O),A=this.hashInt(J.Rencoded(),F.pubBytes(),I),W=this.g.mul(J.S()),H=J.R().add(F.pub().mul(A));return H.eq(W)},K.prototype.hashInt=function(){for(var I=this.hash(),J=0;J0?q:j},V.min=function(q,j){return q.cmp(j)<0?q:j},V.prototype._init=function(q,j,k){if(typeof q=="number")return this._initNumber(q,j,k);if(typeof q=="object")return this._initArray(q,j,k);j==="hex"&&(j=16),Z(j===(j|0)&&j>=2&&j<=36),q=q.toString().replace(/\s+/g,"");var g=0;q[0]==="-"&&(g++,this.negative=1),g=0;g-=3)x=q[g]|q[g-1]<<8|q[g-2]<<16,this.words[N]|=x<<_&67108863,this.words[N+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);else if(k==="le")for(g=0,N=0;g>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);return this.strip()};function X(q,j){var k=q.charCodeAt(j);return k>=65&&k<=70?k-55:k>=97&&k<=102?k-87:k-48&15}function K(q,j,k){var g=X(q,k);return k-1>=j&&(g|=X(q,k-1)<<4),g}V.prototype._parseHex=function(q,j,k){this.length=Math.ceil((q.length-j)/6),this.words=new Array(this.length);for(var g=0;g=j;g-=2)_=K(q,j,g)<=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8;else{var B=q.length-j;for(g=B%2===0?j+1:j;g=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8}this.strip()};function I(q,j,k,g){for(var N=0,x=Math.min(q.length,k),_=j;_=49?N+=B-49+10:B>=17?N+=B-17+10:N+=B}return N}V.prototype._parseBase=function(q,j,k){this.words=[0],this.length=1;for(var g=0,N=1;N<=67108863;N*=j)g++;g--,N=N/j|0;for(var x=q.length-k,_=x%g,B=Math.min(x,x-_)+k,y=0,w=k;w1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},V.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},V.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],O=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],F=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];V.prototype.toString=function(q,j){q=q||10,j=j|0||1;var k;if(q===16||q==="hex"){k="";for(var g=0,N=0,x=0;x>>24-g&16777215,N!==0||x!==this.length-1?k=J[6-B.length]+B+k:k=B+k,g+=2,g>=26&&(g-=26,x--)}for(N!==0&&(k=N.toString(16)+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}if(q===(q|0)&&q>=2&&q<=36){var y=O[q],w=F[q];k="";var f=this.clone();for(f.negative=0;!f.isZero();){var p=f.modn(w).toString(q);f=f.idivn(w),f.isZero()?k=p+k:k=J[y-p.length]+p+k}for(this.isZero()&&(k="0"+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}Z(!1,"Base should be between 2 and 36")},V.prototype.toNumber=function(){var q=this.words[0];return this.length===2?q+=this.words[1]*67108864:this.length===3&&this.words[2]===1?q+=4503599627370496+this.words[1]*67108864:this.length>2&&Z(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-q:q},V.prototype.toJSON=function(){return this.toString(16)},V.prototype.toBuffer=function(q,j){return Z(typeof U<"u"),this.toArrayLike(U,q,j)},V.prototype.toArray=function(q,j){return this.toArrayLike(Array,q,j)},V.prototype.toArrayLike=function(q,j,k){var g=this.byteLength(),N=k||Math.max(1,g);Z(g<=N,"byte array longer than desired length"),Z(N>0,"Requested array length <= 0"),this.strip();var x=j==="le",_=new q(N),B,y,w=this.clone();if(x){for(y=0;!w.isZero();y++)B=w.andln(255),w.iushrn(8),_[y]=B;for(;y=4096&&(k+=13,j>>>=13),j>=64&&(k+=7,j>>>=7),j>=8&&(k+=4,j>>>=4),j>=2&&(k+=2,j>>>=2),k+j},V.prototype._zeroBits=function(q){if(q===0)return 26;var j=q,k=0;return(j&8191)===0&&(k+=13,j>>>=13),(j&127)===0&&(k+=7,j>>>=7),(j&15)===0&&(k+=4,j>>>=4),(j&3)===0&&(k+=2,j>>>=2),(j&1)===0&&k++,k},V.prototype.bitLength=function(){var q=this.words[this.length-1],j=this._countBits(q);return(this.length-1)*26+j};function A(q){for(var j=new Array(q.bitLength()),k=0;k>>N}return j}V.prototype.zeroBits=function(){if(this.isZero())return 0;for(var q=0,j=0;jq.length?this.clone().ior(q):q.clone().ior(this)},V.prototype.uor=function(q){return this.length>q.length?this.clone().iuor(q):q.clone().iuor(this)},V.prototype.iuand=function(q){var j;this.length>q.length?j=q:j=this;for(var k=0;kq.length?this.clone().iand(q):q.clone().iand(this)},V.prototype.uand=function(q){return this.length>q.length?this.clone().iuand(q):q.clone().iuand(this)},V.prototype.iuxor=function(q){var j,k;this.length>q.length?(j=this,k=q):(j=q,k=this);for(var g=0;gq.length?this.clone().ixor(q):q.clone().ixor(this)},V.prototype.uxor=function(q){return this.length>q.length?this.clone().iuxor(q):q.clone().iuxor(this)},V.prototype.inotn=function(q){Z(typeof q=="number"&&q>=0);var j=Math.ceil(q/26)|0,k=q%26;this._expand(j),k>0&&j--;for(var g=0;g0&&(this.words[g]=~this.words[g]&67108863>>26-k),this.strip()},V.prototype.notn=function(q){return this.clone().inotn(q)},V.prototype.setn=function(q,j){Z(typeof q=="number"&&q>=0);var k=q/26|0,g=q%26;return this._expand(k+1),j?this.words[k]=this.words[k]|1<q.length?(k=this,g=q):(k=q,g=this);for(var N=0,x=0;x>>26;for(;N!==0&&x>>26;if(this.length=k.length,N!==0)this.words[this.length]=N,this.length++;else if(k!==this)for(;xq.length?this.clone().iadd(q):q.clone().iadd(this)},V.prototype.isub=function(q){if(q.negative!==0){q.negative=0;var j=this.iadd(q);return q.negative=1,j._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(q),this.negative=1,this._normSign();var k=this.cmp(q);if(k===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,N;k>0?(g=this,N=q):(g=q,N=this);for(var x=0,_=0;_>26,this.words[_]=j&67108863;for(;x!==0&&_>26,this.words[_]=j&67108863;if(x===0&&_>>26,p=y&67108863,c=Math.min(w,j.length-1),h=Math.max(0,w-q.length+1);h<=c;h++){var d=w-h|0;N=q.words[d]|0,x=j.words[h]|0,_=N*x+p,f+=_/67108864|0,p=_&67108863}k.words[w]=p|0,y=f|0}return y!==0?k.words[w]=y|0:k.length--,k.strip()}var H=function(q,j,k){var g=q.words,N=j.words,x=k.words,_=0,B,y,w,f=g[0]|0,p=f&8191,c=f>>>13,h=g[1]|0,d=h&8191,b=h>>>13,l=g[2]|0,o=l&8191,u=l>>>13,n=g[3]|0,s=n&8191,t=n>>>13,m=g[4]|0,a=m&8191,r=m>>>13,e=g[5]|0,i=e&8191,$0=e>>>13,Q0=g[6]|0,Y0=Q0&8191,Z0=Q0>>>13,G0=g[7]|0,V0=G0&8191,U0=G0>>>13,X0=g[8]|0,K0=X0&8191,I0=X0>>>13,J0=g[9]|0,O0=J0&8191,F0=J0>>>13,A0=N[0]|0,W0=A0&8191,H0=A0>>>13,E0=N[1]|0,T0=E0&8191,D0=E0>>>13,C0=N[2]|0,L0=C0&8191,R0=C0>>>13,P0=N[3]|0,z0=P0&8191,M0=P0>>>13,S0=N[4]|0,v0=S0&8191,q0=S0>>>13,j0=N[5]|0,k0=j0&8191,g0=j0>>>13,N0=N[6]|0,x0=N0&8191,_0=N0>>>13,B0=N[7]|0,y0=B0&8191,w0=B0>>>13,f0=N[8]|0,p0=f0&8191,c0=f0>>>13,h0=N[9]|0,d0=h0&8191,b0=h0>>>13;k.negative=q.negative^j.negative,k.length=19,B=Math.imul(p,W0),y=Math.imul(p,H0),y=y+Math.imul(c,W0)|0,w=Math.imul(c,H0);var l0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(l0>>>26)|0,l0&=67108863,B=Math.imul(d,W0),y=Math.imul(d,H0),y=y+Math.imul(b,W0)|0,w=Math.imul(b,H0),B=B+Math.imul(p,T0)|0,y=y+Math.imul(p,D0)|0,y=y+Math.imul(c,T0)|0,w=w+Math.imul(c,D0)|0;var o0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(o0>>>26)|0,o0&=67108863,B=Math.imul(o,W0),y=Math.imul(o,H0),y=y+Math.imul(u,W0)|0,w=Math.imul(u,H0),B=B+Math.imul(d,T0)|0,y=y+Math.imul(d,D0)|0,y=y+Math.imul(b,T0)|0,w=w+Math.imul(b,D0)|0,B=B+Math.imul(p,L0)|0,y=y+Math.imul(p,R0)|0,y=y+Math.imul(c,L0)|0,w=w+Math.imul(c,R0)|0;var u0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(u0>>>26)|0,u0&=67108863,B=Math.imul(s,W0),y=Math.imul(s,H0),y=y+Math.imul(t,W0)|0,w=Math.imul(t,H0),B=B+Math.imul(o,T0)|0,y=y+Math.imul(o,D0)|0,y=y+Math.imul(u,T0)|0,w=w+Math.imul(u,D0)|0,B=B+Math.imul(d,L0)|0,y=y+Math.imul(d,R0)|0,y=y+Math.imul(b,L0)|0,w=w+Math.imul(b,R0)|0,B=B+Math.imul(p,z0)|0,y=y+Math.imul(p,M0)|0,y=y+Math.imul(c,z0)|0,w=w+Math.imul(c,M0)|0;var n0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(n0>>>26)|0,n0&=67108863,B=Math.imul(a,W0),y=Math.imul(a,H0),y=y+Math.imul(r,W0)|0,w=Math.imul(r,H0),B=B+Math.imul(s,T0)|0,y=y+Math.imul(s,D0)|0,y=y+Math.imul(t,T0)|0,w=w+Math.imul(t,D0)|0,B=B+Math.imul(o,L0)|0,y=y+Math.imul(o,R0)|0,y=y+Math.imul(u,L0)|0,w=w+Math.imul(u,R0)|0,B=B+Math.imul(d,z0)|0,y=y+Math.imul(d,M0)|0,y=y+Math.imul(b,z0)|0,w=w+Math.imul(b,M0)|0,B=B+Math.imul(p,v0)|0,y=y+Math.imul(p,q0)|0,y=y+Math.imul(c,v0)|0,w=w+Math.imul(c,q0)|0;var s0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(s0>>>26)|0,s0&=67108863,B=Math.imul(i,W0),y=Math.imul(i,H0),y=y+Math.imul($0,W0)|0,w=Math.imul($0,H0),B=B+Math.imul(a,T0)|0,y=y+Math.imul(a,D0)|0,y=y+Math.imul(r,T0)|0,w=w+Math.imul(r,D0)|0,B=B+Math.imul(s,L0)|0,y=y+Math.imul(s,R0)|0,y=y+Math.imul(t,L0)|0,w=w+Math.imul(t,R0)|0,B=B+Math.imul(o,z0)|0,y=y+Math.imul(o,M0)|0,y=y+Math.imul(u,z0)|0,w=w+Math.imul(u,M0)|0,B=B+Math.imul(d,v0)|0,y=y+Math.imul(d,q0)|0,y=y+Math.imul(b,v0)|0,w=w+Math.imul(b,q0)|0,B=B+Math.imul(p,k0)|0,y=y+Math.imul(p,g0)|0,y=y+Math.imul(c,k0)|0,w=w+Math.imul(c,g0)|0;var t0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(t0>>>26)|0,t0&=67108863,B=Math.imul(Y0,W0),y=Math.imul(Y0,H0),y=y+Math.imul(Z0,W0)|0,w=Math.imul(Z0,H0),B=B+Math.imul(i,T0)|0,y=y+Math.imul(i,D0)|0,y=y+Math.imul($0,T0)|0,w=w+Math.imul($0,D0)|0,B=B+Math.imul(a,L0)|0,y=y+Math.imul(a,R0)|0,y=y+Math.imul(r,L0)|0,w=w+Math.imul(r,R0)|0,B=B+Math.imul(s,z0)|0,y=y+Math.imul(s,M0)|0,y=y+Math.imul(t,z0)|0,w=w+Math.imul(t,M0)|0,B=B+Math.imul(o,v0)|0,y=y+Math.imul(o,q0)|0,y=y+Math.imul(u,v0)|0,w=w+Math.imul(u,q0)|0,B=B+Math.imul(d,k0)|0,y=y+Math.imul(d,g0)|0,y=y+Math.imul(b,k0)|0,w=w+Math.imul(b,g0)|0,B=B+Math.imul(p,x0)|0,y=y+Math.imul(p,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,_0)|0;var m0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(m0>>>26)|0,m0&=67108863,B=Math.imul(V0,W0),y=Math.imul(V0,H0),y=y+Math.imul(U0,W0)|0,w=Math.imul(U0,H0),B=B+Math.imul(Y0,T0)|0,y=y+Math.imul(Y0,D0)|0,y=y+Math.imul(Z0,T0)|0,w=w+Math.imul(Z0,D0)|0,B=B+Math.imul(i,L0)|0,y=y+Math.imul(i,R0)|0,y=y+Math.imul($0,L0)|0,w=w+Math.imul($0,R0)|0,B=B+Math.imul(a,z0)|0,y=y+Math.imul(a,M0)|0,y=y+Math.imul(r,z0)|0,w=w+Math.imul(r,M0)|0,B=B+Math.imul(s,v0)|0,y=y+Math.imul(s,q0)|0,y=y+Math.imul(t,v0)|0,w=w+Math.imul(t,q0)|0,B=B+Math.imul(o,k0)|0,y=y+Math.imul(o,g0)|0,y=y+Math.imul(u,k0)|0,w=w+Math.imul(u,g0)|0,B=B+Math.imul(d,x0)|0,y=y+Math.imul(d,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,_0)|0,B=B+Math.imul(p,y0)|0,y=y+Math.imul(p,w0)|0,y=y+Math.imul(c,y0)|0,w=w+Math.imul(c,w0)|0;var a0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(a0>>>26)|0,a0&=67108863,B=Math.imul(K0,W0),y=Math.imul(K0,H0),y=y+Math.imul(I0,W0)|0,w=Math.imul(I0,H0),B=B+Math.imul(V0,T0)|0,y=y+Math.imul(V0,D0)|0,y=y+Math.imul(U0,T0)|0,w=w+Math.imul(U0,D0)|0,B=B+Math.imul(Y0,L0)|0,y=y+Math.imul(Y0,R0)|0,y=y+Math.imul(Z0,L0)|0,w=w+Math.imul(Z0,R0)|0,B=B+Math.imul(i,z0)|0,y=y+Math.imul(i,M0)|0,y=y+Math.imul($0,z0)|0,w=w+Math.imul($0,M0)|0,B=B+Math.imul(a,v0)|0,y=y+Math.imul(a,q0)|0,y=y+Math.imul(r,v0)|0,w=w+Math.imul(r,q0)|0,B=B+Math.imul(s,k0)|0,y=y+Math.imul(s,g0)|0,y=y+Math.imul(t,k0)|0,w=w+Math.imul(t,g0)|0,B=B+Math.imul(o,x0)|0,y=y+Math.imul(o,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,_0)|0,B=B+Math.imul(d,y0)|0,y=y+Math.imul(d,w0)|0,y=y+Math.imul(b,y0)|0,w=w+Math.imul(b,w0)|0,B=B+Math.imul(p,p0)|0,y=y+Math.imul(p,c0)|0,y=y+Math.imul(c,p0)|0,w=w+Math.imul(c,c0)|0;var r0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(r0>>>26)|0,r0&=67108863,B=Math.imul(O0,W0),y=Math.imul(O0,H0),y=y+Math.imul(F0,W0)|0,w=Math.imul(F0,H0),B=B+Math.imul(K0,T0)|0,y=y+Math.imul(K0,D0)|0,y=y+Math.imul(I0,T0)|0,w=w+Math.imul(I0,D0)|0,B=B+Math.imul(V0,L0)|0,y=y+Math.imul(V0,R0)|0,y=y+Math.imul(U0,L0)|0,w=w+Math.imul(U0,R0)|0,B=B+Math.imul(Y0,z0)|0,y=y+Math.imul(Y0,M0)|0,y=y+Math.imul(Z0,z0)|0,w=w+Math.imul(Z0,M0)|0,B=B+Math.imul(i,v0)|0,y=y+Math.imul(i,q0)|0,y=y+Math.imul($0,v0)|0,w=w+Math.imul($0,q0)|0,B=B+Math.imul(a,k0)|0,y=y+Math.imul(a,g0)|0,y=y+Math.imul(r,k0)|0,w=w+Math.imul(r,g0)|0,B=B+Math.imul(s,x0)|0,y=y+Math.imul(s,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,_0)|0,B=B+Math.imul(o,y0)|0,y=y+Math.imul(o,w0)|0,y=y+Math.imul(u,y0)|0,w=w+Math.imul(u,w0)|0,B=B+Math.imul(d,p0)|0,y=y+Math.imul(d,c0)|0,y=y+Math.imul(b,p0)|0,w=w+Math.imul(b,c0)|0,B=B+Math.imul(p,d0)|0,y=y+Math.imul(p,b0)|0,y=y+Math.imul(c,d0)|0,w=w+Math.imul(c,b0)|0;var e0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(e0>>>26)|0,e0&=67108863,B=Math.imul(O0,T0),y=Math.imul(O0,D0),y=y+Math.imul(F0,T0)|0,w=Math.imul(F0,D0),B=B+Math.imul(K0,L0)|0,y=y+Math.imul(K0,R0)|0,y=y+Math.imul(I0,L0)|0,w=w+Math.imul(I0,R0)|0,B=B+Math.imul(V0,z0)|0,y=y+Math.imul(V0,M0)|0,y=y+Math.imul(U0,z0)|0,w=w+Math.imul(U0,M0)|0,B=B+Math.imul(Y0,v0)|0,y=y+Math.imul(Y0,q0)|0,y=y+Math.imul(Z0,v0)|0,w=w+Math.imul(Z0,q0)|0,B=B+Math.imul(i,k0)|0,y=y+Math.imul(i,g0)|0,y=y+Math.imul($0,k0)|0,w=w+Math.imul($0,g0)|0,B=B+Math.imul(a,x0)|0,y=y+Math.imul(a,_0)|0,y=y+Math.imul(r,x0)|0,w=w+Math.imul(r,_0)|0,B=B+Math.imul(s,y0)|0,y=y+Math.imul(s,w0)|0,y=y+Math.imul(t,y0)|0,w=w+Math.imul(t,w0)|0,B=B+Math.imul(o,p0)|0,y=y+Math.imul(o,c0)|0,y=y+Math.imul(u,p0)|0,w=w+Math.imul(u,c0)|0,B=B+Math.imul(d,d0)|0,y=y+Math.imul(d,b0)|0,y=y+Math.imul(b,d0)|0,w=w+Math.imul(b,b0)|0;var i0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(i0>>>26)|0,i0&=67108863,B=Math.imul(O0,L0),y=Math.imul(O0,R0),y=y+Math.imul(F0,L0)|0,w=Math.imul(F0,R0),B=B+Math.imul(K0,z0)|0,y=y+Math.imul(K0,M0)|0,y=y+Math.imul(I0,z0)|0,w=w+Math.imul(I0,M0)|0,B=B+Math.imul(V0,v0)|0,y=y+Math.imul(V0,q0)|0,y=y+Math.imul(U0,v0)|0,w=w+Math.imul(U0,q0)|0,B=B+Math.imul(Y0,k0)|0,y=y+Math.imul(Y0,g0)|0,y=y+Math.imul(Z0,k0)|0,w=w+Math.imul(Z0,g0)|0,B=B+Math.imul(i,x0)|0,y=y+Math.imul(i,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,_0)|0,B=B+Math.imul(a,y0)|0,y=y+Math.imul(a,w0)|0,y=y+Math.imul(r,y0)|0,w=w+Math.imul(r,w0)|0,B=B+Math.imul(s,p0)|0,y=y+Math.imul(s,c0)|0,y=y+Math.imul(t,p0)|0,w=w+Math.imul(t,c0)|0,B=B+Math.imul(o,d0)|0,y=y+Math.imul(o,b0)|0,y=y+Math.imul(u,d0)|0,w=w+Math.imul(u,b0)|0;var $$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+($$>>>26)|0,$$&=67108863,B=Math.imul(O0,z0),y=Math.imul(O0,M0),y=y+Math.imul(F0,z0)|0,w=Math.imul(F0,M0),B=B+Math.imul(K0,v0)|0,y=y+Math.imul(K0,q0)|0,y=y+Math.imul(I0,v0)|0,w=w+Math.imul(I0,q0)|0,B=B+Math.imul(V0,k0)|0,y=y+Math.imul(V0,g0)|0,y=y+Math.imul(U0,k0)|0,w=w+Math.imul(U0,g0)|0,B=B+Math.imul(Y0,x0)|0,y=y+Math.imul(Y0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,_0)|0,B=B+Math.imul(i,y0)|0,y=y+Math.imul(i,w0)|0,y=y+Math.imul($0,y0)|0,w=w+Math.imul($0,w0)|0,B=B+Math.imul(a,p0)|0,y=y+Math.imul(a,c0)|0,y=y+Math.imul(r,p0)|0,w=w+Math.imul(r,c0)|0,B=B+Math.imul(s,d0)|0,y=y+Math.imul(s,b0)|0,y=y+Math.imul(t,d0)|0,w=w+Math.imul(t,b0)|0;var Q$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,B=Math.imul(O0,v0),y=Math.imul(O0,q0),y=y+Math.imul(F0,v0)|0,w=Math.imul(F0,q0),B=B+Math.imul(K0,k0)|0,y=y+Math.imul(K0,g0)|0,y=y+Math.imul(I0,k0)|0,w=w+Math.imul(I0,g0)|0,B=B+Math.imul(V0,x0)|0,y=y+Math.imul(V0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,_0)|0,B=B+Math.imul(Y0,y0)|0,y=y+Math.imul(Y0,w0)|0,y=y+Math.imul(Z0,y0)|0,w=w+Math.imul(Z0,w0)|0,B=B+Math.imul(i,p0)|0,y=y+Math.imul(i,c0)|0,y=y+Math.imul($0,p0)|0,w=w+Math.imul($0,c0)|0,B=B+Math.imul(a,d0)|0,y=y+Math.imul(a,b0)|0,y=y+Math.imul(r,d0)|0,w=w+Math.imul(r,b0)|0;var Y$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,B=Math.imul(O0,k0),y=Math.imul(O0,g0),y=y+Math.imul(F0,k0)|0,w=Math.imul(F0,g0),B=B+Math.imul(K0,x0)|0,y=y+Math.imul(K0,_0)|0,y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,_0)|0,B=B+Math.imul(V0,y0)|0,y=y+Math.imul(V0,w0)|0,y=y+Math.imul(U0,y0)|0,w=w+Math.imul(U0,w0)|0,B=B+Math.imul(Y0,p0)|0,y=y+Math.imul(Y0,c0)|0,y=y+Math.imul(Z0,p0)|0,w=w+Math.imul(Z0,c0)|0,B=B+Math.imul(i,d0)|0,y=y+Math.imul(i,b0)|0,y=y+Math.imul($0,d0)|0,w=w+Math.imul($0,b0)|0;var Z$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,B=Math.imul(O0,x0),y=Math.imul(O0,_0),y=y+Math.imul(F0,x0)|0,w=Math.imul(F0,_0),B=B+Math.imul(K0,y0)|0,y=y+Math.imul(K0,w0)|0,y=y+Math.imul(I0,y0)|0,w=w+Math.imul(I0,w0)|0,B=B+Math.imul(V0,p0)|0,y=y+Math.imul(V0,c0)|0,y=y+Math.imul(U0,p0)|0,w=w+Math.imul(U0,c0)|0,B=B+Math.imul(Y0,d0)|0,y=y+Math.imul(Y0,b0)|0,y=y+Math.imul(Z0,d0)|0,w=w+Math.imul(Z0,b0)|0;var G$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(G$>>>26)|0,G$&=67108863,B=Math.imul(O0,y0),y=Math.imul(O0,w0),y=y+Math.imul(F0,y0)|0,w=Math.imul(F0,w0),B=B+Math.imul(K0,p0)|0,y=y+Math.imul(K0,c0)|0,y=y+Math.imul(I0,p0)|0,w=w+Math.imul(I0,c0)|0,B=B+Math.imul(V0,d0)|0,y=y+Math.imul(V0,b0)|0,y=y+Math.imul(U0,d0)|0,w=w+Math.imul(U0,b0)|0;var V$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(V$>>>26)|0,V$&=67108863,B=Math.imul(O0,p0),y=Math.imul(O0,c0),y=y+Math.imul(F0,p0)|0,w=Math.imul(F0,c0),B=B+Math.imul(K0,d0)|0,y=y+Math.imul(K0,b0)|0,y=y+Math.imul(I0,d0)|0,w=w+Math.imul(I0,b0)|0;var U$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(U$>>>26)|0,U$&=67108863,B=Math.imul(O0,d0),y=Math.imul(O0,b0),y=y+Math.imul(F0,d0)|0,w=Math.imul(F0,b0);var X$=(_+B|0)+((y&8191)<<13)|0;return _=(w+(y>>>13)|0)+(X$>>>26)|0,X$&=67108863,x[0]=l0,x[1]=o0,x[2]=u0,x[3]=n0,x[4]=s0,x[5]=t0,x[6]=m0,x[7]=a0,x[8]=r0,x[9]=e0,x[10]=i0,x[11]=$$,x[12]=Q$,x[13]=Y$,x[14]=Z$,x[15]=G$,x[16]=V$,x[17]=U$,x[18]=X$,_!==0&&(x[19]=_,k.length++),k};Math.imul||(H=W);function E(q,j,k){k.negative=j.negative^q.negative,k.length=q.length+j.length;for(var g=0,N=0,x=0;x>>26)|0,N+=_>>>26,_&=67108863}k.words[x]=B,g=_,_=N}return g!==0?k.words[x]=g:k.length--,k.strip()}function T(q,j,k){var g=new D;return g.mulp(q,j,k)}V.prototype.mulTo=function(q,j){var k,g=this.length+q.length;return this.length===10&&q.length===10?k=H(this,q,j):g<63?k=W(this,q,j):g<1024?k=E(this,q,j):k=T(this,q,j),k};function D(q,j){this.x=q,this.y=j}D.prototype.makeRBT=function(q){for(var j=new Array(q),k=V.prototype._countBits(q)-1,g=0;g>=1;return g},D.prototype.permute=function(q,j,k,g,N,x){for(var _=0;_>>1)N++;return 1<>>13,k[2*x+1]=N&8191,N=N>>>13;for(x=2*j;x>=26,j+=g/67108864|0,j+=N>>>26,this.words[k]=N&67108863}return j!==0&&(this.words[k]=j,this.length++),this},V.prototype.muln=function(q){return this.clone().imuln(q)},V.prototype.sqr=function(){return this.mul(this)},V.prototype.isqr=function(){return this.imul(this.clone())},V.prototype.pow=function(q){var j=A(q);if(j.length===0)return new V(1);for(var k=this,g=0;g=0);var j=q%26,k=(q-j)/26,g=67108863>>>26-j<<26-j,N;if(j!==0){var x=0;for(N=0;N>>26-j}x&&(this.words[N]=x,this.length++)}if(k!==0){for(N=this.length-1;N>=0;N--)this.words[N+k]=this.words[N];for(N=0;N=0);var g;j?g=(j-j%26)/26:g=0;var N=q%26,x=Math.min((q-N)/26,this.length),_=67108863^67108863>>>N<x)for(this.length-=x,y=0;y=0&&(w!==0||y>=g);y--){var f=this.words[y]|0;this.words[y]=w<<26-N|f>>>N,w=f&_}return B&&w!==0&&(B.words[B.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},V.prototype.ishrn=function(q,j,k){return Z(this.negative===0),this.iushrn(q,j,k)},V.prototype.shln=function(q){return this.clone().ishln(q)},V.prototype.ushln=function(q){return this.clone().iushln(q)},V.prototype.shrn=function(q){return this.clone().ishrn(q)},V.prototype.ushrn=function(q){return this.clone().iushrn(q)},V.prototype.testn=function(q){Z(typeof q=="number"&&q>=0);var j=q%26,k=(q-j)/26,g=1<=0);var j=q%26,k=(q-j)/26;if(Z(this.negative===0,"imaskn works only with positive numbers"),this.length<=k)return this;if(j!==0&&k++,this.length=Math.min(k,this.length),j!==0){var g=67108863^67108863>>>j<=67108864;j++)this.words[j]-=67108864,j===this.length-1?this.words[j+1]=1:this.words[j+1]++;return this.length=Math.max(this.length,j+1),this},V.prototype.isubn=function(q){if(Z(typeof q=="number"),Z(q<67108864),q<0)return this.iaddn(-q);if(this.negative!==0)return this.negative=0,this.iaddn(q),this.negative=1,this;if(this.words[0]-=q,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var j=0;j>26)-(B/67108864|0),this.words[N+k]=x&67108863}for(;N>26,this.words[N+k]=x&67108863;if(_===0)return this.strip();for(Z(_===-1),_=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},V.prototype._wordDiv=function(q,j){var k=this.length-q.length,g=this.clone(),N=q,x=N.words[N.length-1]|0,_=this._countBits(x);k=26-_,k!==0&&(N=N.ushln(k),g.iushln(k),x=N.words[N.length-1]|0);var B=g.length-N.length,y;if(j!=="mod"){y=new V(null),y.length=B+1,y.words=new Array(y.length);for(var w=0;w=0;p--){var c=(g.words[N.length+p]|0)*67108864+(g.words[N.length+p-1]|0);for(c=Math.min(c/x|0,67108863),g._ishlnsubmul(N,c,p);g.negative!==0;)c--,g.negative=0,g._ishlnsubmul(N,1,p),g.isZero()||(g.negative^=1);y&&(y.words[p]=c)}return y&&y.strip(),g.strip(),j!=="div"&&k!==0&&g.iushrn(k),{div:y||null,mod:g}},V.prototype.divmod=function(q,j,k){if(Z(!q.isZero()),this.isZero())return{div:new V(0),mod:new V(0)};var g,N,x;return this.negative!==0&&q.negative===0?(x=this.neg().divmod(q,j),j!=="mod"&&(g=x.div.neg()),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.iadd(q)),{div:g,mod:N}):this.negative===0&&q.negative!==0?(x=this.divmod(q.neg(),j),j!=="mod"&&(g=x.div.neg()),{div:g,mod:x.mod}):(this.negative&q.negative)!==0?(x=this.neg().divmod(q.neg(),j),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.isub(q)),{div:x.div,mod:N}):q.length>this.length||this.cmp(q)<0?{div:new V(0),mod:this}:q.length===1?j==="div"?{div:this.divn(q.words[0]),mod:null}:j==="mod"?{div:null,mod:new V(this.modn(q.words[0]))}:{div:this.divn(q.words[0]),mod:new V(this.modn(q.words[0]))}:this._wordDiv(q,j)},V.prototype.div=function(q){return this.divmod(q,"div",!1).div},V.prototype.mod=function(q){return this.divmod(q,"mod",!1).mod},V.prototype.umod=function(q){return this.divmod(q,"mod",!0).mod},V.prototype.divRound=function(q){var j=this.divmod(q);if(j.mod.isZero())return j.div;var k=j.div.negative!==0?j.mod.isub(q):j.mod,g=q.ushrn(1),N=q.andln(1),x=k.cmp(g);return x<0||N===1&&x===0?j.div:j.div.negative!==0?j.div.isubn(1):j.div.iaddn(1)},V.prototype.modn=function(q){Z(q<=67108863);for(var j=(1<<26)%q,k=0,g=this.length-1;g>=0;g--)k=(j*k+(this.words[g]|0))%q;return k},V.prototype.idivn=function(q){Z(q<=67108863);for(var j=0,k=this.length-1;k>=0;k--){var g=(this.words[k]|0)+j*67108864;this.words[k]=g/q|0,j=g%q}return this.strip()},V.prototype.divn=function(q){return this.clone().idivn(q)},V.prototype.egcd=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=new V(0),_=new V(1),B=0;j.isEven()&&k.isEven();)j.iushrn(1),k.iushrn(1),++B;for(var y=k.clone(),w=j.clone();!j.isZero();){for(var f=0,p=1;(j.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(j.iushrn(f);f-- >0;)(g.isOdd()||N.isOdd())&&(g.iadd(y),N.isub(w)),g.iushrn(1),N.iushrn(1);for(var c=0,h=1;(k.words[0]&h)===0&&c<26;++c,h<<=1);if(c>0)for(k.iushrn(c);c-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(y),_.isub(w)),x.iushrn(1),_.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(x),N.isub(_)):(k.isub(j),x.isub(g),_.isub(N))}return{a:x,b:_,gcd:k.iushln(B)}},V.prototype._invmp=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=k.clone();j.cmpn(1)>0&&k.cmpn(1)>0;){for(var _=0,B=1;(j.words[0]&B)===0&&_<26;++_,B<<=1);if(_>0)for(j.iushrn(_);_-- >0;)g.isOdd()&&g.iadd(x),g.iushrn(1);for(var y=0,w=1;(k.words[0]&w)===0&&y<26;++y,w<<=1);if(y>0)for(k.iushrn(y);y-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(N)):(k.isub(j),N.isub(g))}var f;return j.cmpn(1)===0?f=g:f=N,f.cmpn(0)<0&&f.iadd(q),f},V.prototype.gcd=function(q){if(this.isZero())return q.abs();if(q.isZero())return this.abs();var j=this.clone(),k=q.clone();j.negative=0,k.negative=0;for(var g=0;j.isEven()&&k.isEven();g++)j.iushrn(1),k.iushrn(1);do{for(;j.isEven();)j.iushrn(1);for(;k.isEven();)k.iushrn(1);var N=j.cmp(k);if(N<0){var x=j;j=k,k=x}else if(N===0||k.cmpn(1)===0)break;j.isub(k)}while(!0);return k.iushln(g)},V.prototype.invm=function(q){return this.egcd(q).a.umod(q)},V.prototype.isEven=function(){return(this.words[0]&1)===0},V.prototype.isOdd=function(){return(this.words[0]&1)===1},V.prototype.andln=function(q){return this.words[0]&q},V.prototype.bincn=function(q){Z(typeof q=="number");var j=q%26,k=(q-j)/26,g=1<>>26,_&=67108863,this.words[x]=_}return N!==0&&(this.words[x]=N,this.length++),this},V.prototype.isZero=function(){return this.length===1&&this.words[0]===0},V.prototype.cmpn=function(q){var j=q<0;if(this.negative!==0&&!j)return-1;if(this.negative===0&&j)return 1;this.strip();var k;if(this.length>1)k=1;else{j&&(q=-q),Z(q<=67108863,"Number is too big");var g=this.words[0]|0;k=g===q?0:gq.length)return 1;if(this.length=0;k--){var g=this.words[k]|0,N=q.words[k]|0;if(g!==N){gN&&(j=1);break}}return j},V.prototype.gtn=function(q){return this.cmpn(q)===1},V.prototype.gt=function(q){return this.cmp(q)===1},V.prototype.gten=function(q){return this.cmpn(q)>=0},V.prototype.gte=function(q){return this.cmp(q)>=0},V.prototype.ltn=function(q){return this.cmpn(q)===-1},V.prototype.lt=function(q){return this.cmp(q)===-1},V.prototype.lten=function(q){return this.cmpn(q)<=0},V.prototype.lte=function(q){return this.cmp(q)<=0},V.prototype.eqn=function(q){return this.cmpn(q)===0},V.prototype.eq=function(q){return this.cmp(q)===0},V.red=function(q){return new S(q)},V.prototype.toRed=function(q){return Z(!this.red,"Already a number in reduction context"),Z(this.negative===0,"red works only with positives"),q.convertTo(this)._forceRed(q)},V.prototype.fromRed=function(){return Z(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},V.prototype._forceRed=function(q){return this.red=q,this},V.prototype.forceRed=function(q){return Z(!this.red,"Already a number in reduction context"),this._forceRed(q)},V.prototype.redAdd=function(q){return Z(this.red,"redAdd works only with red numbers"),this.red.add(this,q)},V.prototype.redIAdd=function(q){return Z(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,q)},V.prototype.redSub=function(q){return Z(this.red,"redSub works only with red numbers"),this.red.sub(this,q)},V.prototype.redISub=function(q){return Z(this.red,"redISub works only with red numbers"),this.red.isub(this,q)},V.prototype.redShl=function(q){return Z(this.red,"redShl works only with red numbers"),this.red.shl(this,q)},V.prototype.redMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.mul(this,q)},V.prototype.redIMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.imul(this,q)},V.prototype.redSqr=function(){return Z(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},V.prototype.redISqr=function(){return Z(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},V.prototype.redSqrt=function(){return Z(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},V.prototype.redInvm=function(){return Z(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},V.prototype.redNeg=function(){return Z(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},V.prototype.redPow=function(q){return Z(this.red&&!q.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,q)};var C={k256:null,p224:null,p192:null,p25519:null};function L(q,j){this.name=q,this.p=new V(j,16),this.n=this.p.bitLength(),this.k=new V(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}L.prototype._tmp=function(){var q=new V(null);return q.words=new Array(Math.ceil(this.n/13)),q},L.prototype.ireduce=function(q){var j=q,k;do this.split(j,this.tmp),j=this.imulK(j),j=j.iadd(this.tmp),k=j.bitLength();while(k>this.n);var g=k0?j.isub(this.p):j.strip!==void 0?j.strip():j._strip(),j},L.prototype.split=function(q,j){q.iushrn(this.n,0,j)},L.prototype.imulK=function(q){return q.imul(this.k)};function R(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}G(R,L),R.prototype.split=function(q,j){for(var k=4194303,g=Math.min(q.length,9),N=0;N>>22,x=_}x>>>=22,q.words[N-10]=x,x===0&&q.length>10?q.length-=10:q.length-=9},R.prototype.imulK=function(q){q.words[q.length]=0,q.words[q.length+1]=0,q.length+=2;for(var j=0,k=0;k>>=26,q.words[k]=N,j=g}return j!==0&&(q.words[q.length++]=j),q},V._prime=function(q){if(C[q])return C[q];var j;if(q==="k256")j=new R;else if(q==="p224")j=new P;else if(q==="p192")j=new z;else if(q==="p25519")j=new M;else throw new Error("Unknown prime "+q);return C[q]=j,j};function S(q){if(typeof q=="string"){var j=V._prime(q);this.m=j.p,this.prime=j}else Z(q.gtn(1),"modulus must be greater than 1"),this.m=q,this.prime=null}S.prototype._verify1=function(q){Z(q.negative===0,"red works only with positives"),Z(q.red,"red works only with red numbers")},S.prototype._verify2=function(q,j){Z((q.negative|j.negative)===0,"red works only with positives"),Z(q.red&&q.red===j.red,"red works only with red numbers")},S.prototype.imod=function(q){return this.prime?this.prime.ireduce(q)._forceRed(this):q.umod(this.m)._forceRed(this)},S.prototype.neg=function(q){return q.isZero()?q.clone():this.m.sub(q)._forceRed(this)},S.prototype.add=function(q,j){this._verify2(q,j);var k=q.add(j);return k.cmp(this.m)>=0&&k.isub(this.m),k._forceRed(this)},S.prototype.iadd=function(q,j){this._verify2(q,j);var k=q.iadd(j);return k.cmp(this.m)>=0&&k.isub(this.m),k},S.prototype.sub=function(q,j){this._verify2(q,j);var k=q.sub(j);return k.cmpn(0)<0&&k.iadd(this.m),k._forceRed(this)},S.prototype.isub=function(q,j){this._verify2(q,j);var k=q.isub(j);return k.cmpn(0)<0&&k.iadd(this.m),k},S.prototype.shl=function(q,j){return this._verify1(q),this.imod(q.ushln(j))},S.prototype.imul=function(q,j){return this._verify2(q,j),this.imod(q.imul(j))},S.prototype.mul=function(q,j){return this._verify2(q,j),this.imod(q.mul(j))},S.prototype.isqr=function(q){return this.imul(q,q.clone())},S.prototype.sqr=function(q){return this.mul(q,q)},S.prototype.sqrt=function(q){if(q.isZero())return q.clone();var j=this.m.andln(3);if(Z(j%2===1),j===3){var k=this.m.add(new V(1)).iushrn(2);return this.pow(q,k)}for(var g=this.m.subn(1),N=0;!g.isZero()&&g.andln(1)===0;)N++,g.iushrn(1);Z(!g.isZero());var x=new V(1).toRed(this),_=x.redNeg(),B=this.m.subn(1).iushrn(1),y=this.m.bitLength();for(y=new V(2*y*y).toRed(this);this.pow(y,B).cmp(_)!==0;)y.redIAdd(_);for(var w=this.pow(y,g),f=this.pow(q,g.addn(1).iushrn(1)),p=this.pow(q,g),c=N;p.cmp(x)!==0;){for(var h=p,d=0;h.cmp(x)!==0;d++)h=h.redSqr();Z(d=0;N--){for(var w=j.words[N],f=y-1;f>=0;f--){var p=w>>f&1;if(x!==g[0]&&(x=this.sqr(x)),p===0&&_===0){B=0;continue}_<<=1,_|=p,B++,!(B!==k&&(N!==0||f!==0))&&(x=this.mul(x,g[_]),B=0,_=0)}y=26}return x},S.prototype.convertTo=function(q){var j=q.umod(this.m);return j===q?j.clone():j},S.prototype.convertFrom=function(q){var j=q.clone();return j.red=null,j},V.mont=function(q){return new v(q)};function v(q){S.call(this,q),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new V(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}G(v,S),v.prototype.convertTo=function(q){return this.imod(q.ushln(this.shift))},v.prototype.convertFrom=function(q){var j=this.imod(q.mul(this.rinv));return j.red=null,j},v.prototype.imul=function(q,j){if(q.isZero()||j.isZero())return q.words[0]=0,q.length=1,q;var k=q.imul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.mul=function(q,j){if(q.isZero()||j.isZero())return new V(0)._forceRed(this);var k=q.mul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.invm=function(q){var j=this.imod(q._invmp(this.m).mul(this.r2));return j._forceRed(this)}})(typeof $>"u"||$,bZ)}}),HY=P$({"node_modules/safer-buffer/safer.js"(bZ,$){var Q=L$("buffer"),Y=Q.Buffer,Z={},G;for(G in Q)!Q.hasOwnProperty(G)||G==="SlowBuffer"||G==="Buffer"||(Z[G]=Q[G]);var V=Z.Buffer={};for(G in Y)!Y.hasOwnProperty(G)||G==="allocUnsafe"||G==="allocUnsafeSlow"||(V[G]=Y[G]);if(Z.Buffer.prototype=Y.prototype,(!V.from||V.from===Uint8Array.from)&&(V.from=function(U,X,K){if(typeof U=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof U);if(U&&typeof U.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof U);return Y(U,X,K)}),V.alloc||(V.alloc=function(U,X,K){if(typeof U!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof U);if(U<0||U>=2*(1<<30))throw new RangeError('The value "'+U+'" is invalid for option "size"');var I=Y(U);return!X||X.length===0?I.fill(0):typeof K=="string"?I.fill(X,K):I.fill(X),I}),!Z.kStringMaxLength)try{Z.kStringMaxLength=C$}catch{}Z.constants||(Z.constants={MAX_LENGTH:Z.kMaxLength},Z.kStringMaxLength&&(Z.constants.MAX_STRING_LENGTH=Z.kStringMaxLength)),$.exports=Z}}),EY=P$({"node_modules/asn1.js/lib/asn1/base/reporter.js"(bZ){var $=v$();function Q(Z){this._reporterState={obj:null,path:[],options:Z||{},errors:[]}}bZ.Reporter=Q,Q.prototype.isError=function(Z){return Z instanceof Y},Q.prototype.save=function(){let Z=this._reporterState;return{obj:Z.obj,pathLen:Z.path.length}},Q.prototype.restore=function(Z){let G=this._reporterState;G.obj=Z.obj,G.path=G.path.slice(0,Z.pathLen)},Q.prototype.enterKey=function(Z){return this._reporterState.path.push(Z)},Q.prototype.exitKey=function(Z){let G=this._reporterState;G.path=G.path.slice(0,Z-1)},Q.prototype.leaveKey=function(Z,G,V){let U=this._reporterState;this.exitKey(Z),U.obj!==null&&(U.obj[G]=V)},Q.prototype.path=function(){return this._reporterState.path.join("/")},Q.prototype.enterObject=function(){let Z=this._reporterState,G=Z.obj;return Z.obj={},G},Q.prototype.leaveObject=function(Z){let G=this._reporterState,V=G.obj;return G.obj=Z,V},Q.prototype.error=function(Z){let G,V=this._reporterState,U=Z instanceof Y;if(U?G=Z:G=new Y(V.path.map(function(X){return"["+JSON.stringify(X)+"]"}).join(""),Z.message||Z,Z.stack),!V.options.partial)throw G;return U||V.errors.push(G),G},Q.prototype.wrapResult=function(Z){let G=this._reporterState;return G.options.partial?{result:this.isError(Z)?null:Z,errors:G.errors}:Z};function Y(Z,G){this.path=Z,this.rethrow(G)}$(Y,Error),Y.prototype.rethrow=function(Z){if(this.message=Z+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,Y),!this.stack)try{throw new Error(this.message)}catch(G){this.stack=G.stack}return this}}}),A$=P$({"node_modules/asn1.js/lib/asn1/base/buffer.js"(bZ){var $=v$(),Q=EY().Reporter,Y=HY().Buffer;function Z(V,U){if(Q.call(this,U),!Y.isBuffer(V)){this.error("Input not Buffer");return}this.base=V,this.offset=0,this.length=V.length}$(Z,Q),bZ.DecoderBuffer=Z,Z.isDecoderBuffer=function(V){return V instanceof Z?!0:typeof V=="object"&&Y.isBuffer(V.base)&&V.constructor.name==="DecoderBuffer"&&typeof V.offset=="number"&&typeof V.length=="number"&&typeof V.save=="function"&&typeof V.restore=="function"&&typeof V.isEmpty=="function"&&typeof V.readUInt8=="function"&&typeof V.skip=="function"&&typeof V.raw=="function"},Z.prototype.save=function(){return{offset:this.offset,reporter:Q.prototype.save.call(this)}},Z.prototype.restore=function(V){let U=new Z(this.base);return U.offset=V.offset,U.length=this.offset,this.offset=V.offset,Q.prototype.restore.call(this,V.reporter),U},Z.prototype.isEmpty=function(){return this.offset===this.length},Z.prototype.readUInt8=function(V){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(V||"DecoderBuffer overrun")},Z.prototype.skip=function(V,U){if(!(this.offset+V<=this.length))return this.error(U||"DecoderBuffer overrun");let X=new Z(this.base);return X._reporterState=this._reporterState,X.offset=this.offset,X.length=this.offset+V,this.offset+=V,X},Z.prototype.raw=function(V){return this.base.slice(V?V.offset:this.offset,this.length)};function G(V,U){if(Array.isArray(V))this.length=0,this.value=V.map(function(X){return G.isEncoderBuffer(X)||(X=new G(X,U)),this.length+=X.length,X},this);else if(typeof V=="number"){if(!(0<=V&&V<=255))return U.error("non-byte EncoderBuffer value");this.value=V,this.length=1}else if(typeof V=="string")this.value=V,this.length=Y.byteLength(V);else if(Y.isBuffer(V))this.value=V,this.length=V.length;else return U.error("Unsupported type: "+typeof V)}bZ.EncoderBuffer=G,G.isEncoderBuffer=function(V){return V instanceof G?!0:typeof V=="object"&&V.constructor.name==="EncoderBuffer"&&typeof V.length=="number"&&typeof V.join=="function"},G.prototype.join=function(V,U){return V||(V=Y.alloc(this.length)),U||(U=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(X){X.join(V,U),U+=X.length}):(typeof this.value=="number"?V[U]=this.value:typeof this.value=="string"?V.write(this.value,U):Y.isBuffer(this.value)&&this.value.copy(V,U),U+=this.length)),V}}}),TY=P$({"node_modules/asn1.js/lib/asn1/base/node.js"(bZ,$){var Q=EY().Reporter,Y=A$().EncoderBuffer,Z=A$().DecoderBuffer,G=i$(),V=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],U=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(V),X=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function K(J,O,F){let A={};this._baseState=A,A.name=F,A.enc=J,A.parent=O||null,A.children=null,A.tag=null,A.args=null,A.reverseArgs=null,A.choice=null,A.optional=!1,A.any=!1,A.obj=!1,A.use=null,A.useDecoder=null,A.key=null,A.default=null,A.explicit=null,A.implicit=null,A.contains=null,A.parent||(A.children=[],this._wrap())}$.exports=K;var I=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];K.prototype.clone=function(){let J=this._baseState,O={};I.forEach(function(A){O[A]=J[A]});let F=new this.constructor(O.parent);return F._baseState=O,F},K.prototype._wrap=function(){let J=this._baseState;U.forEach(function(O){this[O]=function(){let F=new this.constructor(this);return J.children.push(F),F[O].apply(F,arguments)}},this)},K.prototype._init=function(J){let O=this._baseState;G(O.parent===null),J.call(this),O.children=O.children.filter(function(F){return F._baseState.parent===this},this),G.equal(O.children.length,1,"Root node can have only one child")},K.prototype._useArgs=function(J){let O=this._baseState,F=J.filter(function(A){return A instanceof this.constructor},this);J=J.filter(function(A){return!(A instanceof this.constructor)},this),F.length!==0&&(G(O.children===null),O.children=F,F.forEach(function(A){A._baseState.parent=this},this)),J.length!==0&&(G(O.args===null),O.args=J,O.reverseArgs=J.map(function(A){if(typeof A!="object"||A.constructor!==Object)return A;let W={};return Object.keys(A).forEach(function(H){H==(H|0)&&(H|=0);let E=A[H];W[E]=H}),W}))},X.forEach(function(J){K.prototype[J]=function(){let O=this._baseState;throw new Error(J+" not implemented for encoding: "+O.enc)}}),V.forEach(function(J){K.prototype[J]=function(){let O=this._baseState,F=Array.prototype.slice.call(arguments);return G(O.tag===null),O.tag=J,this._useArgs(F),this}}),K.prototype.use=function(J){G(J);let O=this._baseState;return G(O.use===null),O.use=J,this},K.prototype.optional=function(){let J=this._baseState;return J.optional=!0,this},K.prototype.def=function(J){let O=this._baseState;return G(O.default===null),O.default=J,O.optional=!0,this},K.prototype.explicit=function(J){let O=this._baseState;return G(O.explicit===null&&O.implicit===null),O.explicit=J,this},K.prototype.implicit=function(J){let O=this._baseState;return G(O.explicit===null&&O.implicit===null),O.implicit=J,this},K.prototype.obj=function(){let J=this._baseState,O=Array.prototype.slice.call(arguments);return J.obj=!0,O.length!==0&&this._useArgs(O),this},K.prototype.key=function(J){let O=this._baseState;return G(O.key===null),O.key=J,this},K.prototype.any=function(){let J=this._baseState;return J.any=!0,this},K.prototype.choice=function(J){let O=this._baseState;return G(O.choice===null),O.choice=J,this._useArgs(Object.keys(J).map(function(F){return J[F]})),this},K.prototype.contains=function(J){let O=this._baseState;return G(O.use===null),O.contains=J,this},K.prototype._decode=function(J,O){let F=this._baseState;if(F.parent===null)return J.wrapResult(F.children[0]._decode(J,O));let A=F.default,W=!0,H=null;if(F.key!==null&&(H=J.enterKey(F.key)),F.optional){let T=null;if(F.explicit!==null?T=F.explicit:F.implicit!==null?T=F.implicit:F.tag!==null&&(T=F.tag),T===null&&!F.any){let D=J.save();try{F.choice===null?this._decodeGeneric(F.tag,J,O):this._decodeChoice(J,O),W=!0}catch{W=!1}J.restore(D)}else if(W=this._peekTag(J,T,F.any),J.isError(W))return W}let E;if(F.obj&&W&&(E=J.enterObject()),W){if(F.explicit!==null){let D=this._decodeTag(J,F.explicit);if(J.isError(D))return D;J=D}let T=J.offset;if(F.use===null&&F.choice===null){let D;F.any&&(D=J.save());let C=this._decodeTag(J,F.implicit!==null?F.implicit:F.tag,F.any);if(J.isError(C))return C;F.any?A=J.raw(D):J=C}if(O&&O.track&&F.tag!==null&&O.track(J.path(),T,J.length,"tagged"),O&&O.track&&F.tag!==null&&O.track(J.path(),J.offset,J.length,"content"),F.any||(F.choice===null?A=this._decodeGeneric(F.tag,J,O):A=this._decodeChoice(J,O)),J.isError(A))return A;if(!F.any&&F.choice===null&&F.children!==null&&F.children.forEach(function(D){D._decode(J,O)}),F.contains&&(F.tag==="octstr"||F.tag==="bitstr")){let D=new Z(A);A=this._getUse(F.contains,J._reporterState.obj)._decode(D,O)}}return F.obj&&W&&(A=J.leaveObject(E)),F.key!==null&&(A!==null||W===!0)?J.leaveKey(H,F.key,A):H!==null&&J.exitKey(H),A},K.prototype._decodeGeneric=function(J,O,F){let A=this._baseState;return J==="seq"||J==="set"?null:J==="seqof"||J==="setof"?this._decodeList(O,J,A.args[0],F):/str$/.test(J)?this._decodeStr(O,J,F):J==="objid"&&A.args?this._decodeObjid(O,A.args[0],A.args[1],F):J==="objid"?this._decodeObjid(O,null,null,F):J==="gentime"||J==="utctime"?this._decodeTime(O,J,F):J==="null_"?this._decodeNull(O,F):J==="bool"?this._decodeBool(O,F):J==="objDesc"?this._decodeStr(O,J,F):J==="int"||J==="enum"?this._decodeInt(O,A.args&&A.args[0],F):A.use!==null?this._getUse(A.use,O._reporterState.obj)._decode(O,F):O.error("unknown tag: "+J)},K.prototype._getUse=function(J,O){let F=this._baseState;return F.useDecoder=this._use(J,O),G(F.useDecoder._baseState.parent===null),F.useDecoder=F.useDecoder._baseState.children[0],F.implicit!==F.useDecoder._baseState.implicit&&(F.useDecoder=F.useDecoder.clone(),F.useDecoder._baseState.implicit=F.implicit),F.useDecoder},K.prototype._decodeChoice=function(J,O){let F=this._baseState,A=null,W=!1;return Object.keys(F.choice).some(function(H){let E=J.save(),T=F.choice[H];try{let D=T._decode(J,O);if(J.isError(D))return!1;A={type:H,value:D},W=!0}catch{return J.restore(E),!1}return!0},this),W?A:J.error("Choice not matched")},K.prototype._createEncoderBuffer=function(J){return new Y(J,this.reporter)},K.prototype._encode=function(J,O,F){let A=this._baseState;if(A.default!==null&&A.default===J)return;let W=this._encodeValue(J,O,F);if(W!==void 0&&!this._skipDefault(W,O,F))return W},K.prototype._encodeValue=function(J,O,F){let A=this._baseState;if(A.parent===null)return A.children[0]._encode(J,O||new Q);let W=null;if(this.reporter=O,A.optional&&J===void 0)if(A.default!==null)J=A.default;else return;let H=null,E=!1;if(A.any)W=this._createEncoderBuffer(J);else if(A.choice)W=this._encodeChoice(J,O);else if(A.contains)H=this._getUse(A.contains,F)._encode(J,O),E=!0;else if(A.children)H=A.children.map(function(T){if(T._baseState.tag==="null_")return T._encode(null,O,J);if(T._baseState.key===null)return O.error("Child should have a key");let D=O.enterKey(T._baseState.key);if(typeof J!="object")return O.error("Child expected, but input is not object");let C=T._encode(J[T._baseState.key],O,J);return O.leaveKey(D),C},this).filter(function(T){return T}),H=this._createEncoderBuffer(H);else if(A.tag==="seqof"||A.tag==="setof"){if(!(A.args&&A.args.length===1))return O.error("Too many args for : "+A.tag);if(!Array.isArray(J))return O.error("seqof/setof, but data is not Array");let T=this.clone();T._baseState.implicit=null,H=this._createEncoderBuffer(J.map(function(D){let C=this._baseState;return this._getUse(C.args[0],J)._encode(D,O)},T))}else A.use!==null?W=this._getUse(A.use,F)._encode(J,O):(H=this._encodePrimitive(A.tag,J),E=!0);if(!A.any&&A.choice===null){let T=A.implicit!==null?A.implicit:A.tag,D=A.implicit===null?"universal":"context";T===null?A.use===null&&O.error("Tag could be omitted only for .use()"):A.use===null&&(W=this._encodeComposite(T,E,D,H))}return A.explicit!==null&&(W=this._encodeComposite(A.explicit,!1,"context",W)),W},K.prototype._encodeChoice=function(J,O){let F=this._baseState,A=F.choice[J.type];return A||G(!1,J.type+" not found in "+JSON.stringify(Object.keys(F.choice))),A._encode(J.value,O)},K.prototype._encodePrimitive=function(J,O){let F=this._baseState;if(/str$/.test(J))return this._encodeStr(O,J);if(J==="objid"&&F.args)return this._encodeObjid(O,F.reverseArgs[0],F.args[1]);if(J==="objid")return this._encodeObjid(O,null,null);if(J==="gentime"||J==="utctime")return this._encodeTime(O,J);if(J==="null_")return this._encodeNull();if(J==="int"||J==="enum")return this._encodeInt(O,F.args&&F.reverseArgs[0]);if(J==="bool")return this._encodeBool(O);if(J==="objDesc")return this._encodeStr(O,J);throw new Error("Unsupported tag: "+J)},K.prototype._isNumstr=function(J){return/^[0-9 ]*$/.test(J)},K.prototype._isPrintstr=function(J){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(J)}}}),DY=P$({"node_modules/asn1.js/lib/asn1/constants/der.js"(bZ){function $(Q){let Y={};return Object.keys(Q).forEach(function(Z){(Z|0)==Z&&(Z=Z|0);let G=Q[Z];Y[G]=Z}),Y}bZ.tagClass={0:"universal",1:"application",2:"context",3:"private"},bZ.tagClassByName=$(bZ.tagClass),bZ.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},bZ.tagByName=$(bZ.tag)}}),CY=P$({"node_modules/asn1.js/lib/asn1/encoders/der.js"(bZ,$){var Q=v$(),Y=HY().Buffer,Z=TY(),G=DY();function V(I){this.enc="der",this.name=I.name,this.entity=I,this.tree=new U,this.tree._init(I.body)}$.exports=V,V.prototype.encode=function(I,J){return this.tree._encode(I,J).join()};function U(I){Z.call(this,"der",I)}Q(U,Z),U.prototype._encodeComposite=function(I,J,O,F){let A=K(I,J,O,this.reporter);if(F.length<128){let E=Y.alloc(2);return E[0]=A,E[1]=F.length,this._createEncoderBuffer([E,F])}let W=1;for(let E=F.length;E>=256;E>>=8)W++;let H=Y.alloc(2+W);H[0]=A,H[1]=128|W;for(let E=1+W,T=F.length;T>0;E--,T>>=8)H[E]=T&255;return this._createEncoderBuffer([H,F])},U.prototype._encodeStr=function(I,J){if(J==="bitstr")return this._createEncoderBuffer([I.unused|0,I.data]);if(J==="bmpstr"){let O=Y.alloc(I.length*2);for(let F=0;F=40)return this.reporter.error("Second objid identifier OOB");I.splice(0,2,I[0]*40+I[1])}let F=0;for(let H=0;H=128;E>>=7)F++}let A=Y.alloc(F),W=A.length-1;for(let H=I.length-1;H>=0;H--){let E=I[H];for(A[W--]=E&127;(E>>=7)>0;)A[W--]=128|E&127}return this._createEncoderBuffer(A)};function X(I){return I<10?"0"+I:I}U.prototype._encodeTime=function(I,J){let O,F=new Date(I);return J==="gentime"?O=[X(F.getUTCFullYear()),X(F.getUTCMonth()+1),X(F.getUTCDate()),X(F.getUTCHours()),X(F.getUTCMinutes()),X(F.getUTCSeconds()),"Z"].join(""):J==="utctime"?O=[X(F.getUTCFullYear()%100),X(F.getUTCMonth()+1),X(F.getUTCDate()),X(F.getUTCHours()),X(F.getUTCMinutes()),X(F.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+J+" time is not supported yet"),this._encodeStr(O,"octstr")},U.prototype._encodeNull=function(){return this._createEncoderBuffer("")},U.prototype._encodeInt=function(I,J){if(typeof I=="string"){if(!J)return this.reporter.error("String int or enum given, but no values map");if(!J.hasOwnProperty(I))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(I));I=J[I]}if(typeof I!="number"&&!Y.isBuffer(I)){let A=I.toArray();!I.sign&&A[0]&128&&A.unshift(0),I=Y.from(A)}if(Y.isBuffer(I)){let A=I.length;I.length===0&&A++;let W=Y.alloc(A);return I.copy(W),I.length===0&&(W[0]=0),this._createEncoderBuffer(W)}if(I<128)return this._createEncoderBuffer(I);if(I<256)return this._createEncoderBuffer([0,I]);let O=1;for(let A=I;A>=256;A>>=8)O++;let F=new Array(O);for(let A=F.length-1;A>=0;A--)F[A]=I&255,I>>=8;return F[0]&128&&F.unshift(0),this._createEncoderBuffer(Y.from(F))},U.prototype._encodeBool=function(I){return this._createEncoderBuffer(I?255:0)},U.prototype._use=function(I,J){return typeof I=="function"&&(I=I(J)),I._getEncoder("der").tree},U.prototype._skipDefault=function(I,J,O){let F=this._baseState,A;if(F.default===null)return!1;let W=I.join();if(F.defaultBuffer===void 0&&(F.defaultBuffer=this._encodeValue(F.default,J,O).join()),W.length!==F.defaultBuffer.length)return!1;for(A=0;A=31?F.error("Multi-octet tag encoding unsupported"):(J||(A|=32),A|=G.tagClassByName[O||"universal"]<<6,A)}}}),LY=P$({"node_modules/asn1.js/lib/asn1/encoders/pem.js"(bZ,$){var Q=v$(),Y=CY();function Z(G){Y.call(this,G),this.enc="pem"}Q(Z,Y),$.exports=Z,Z.prototype.encode=function(G,V){let U=Y.prototype.encode.call(this,G).toString("base64"),X=["-----BEGIN "+V.label+"-----"];for(let K=0;K>6],W=(F&32)===0;if((F&31)===31){let E=F;for(F=0;(E&128)===128;){if(E=J.readUInt8(O),J.isError(E))return E;F<<=7,F|=E&127}}else F&=31;let H=V.tag[F];return{cls:A,primitive:W,tag:F,tagStr:H}}function I(J,O,F){let A=J.readUInt8(F);if(J.isError(A))return A;if(!O&&A===128)return null;if((A&128)===0)return A;let W=A&127;if(W>4)return J.error("length octect is too long");A=0;for(let H=0;H0&&C.ishrn(L),C}function W(T,D){T=A(T,D),T=T.mod(D);var C=Q.from(T.toArray());if(C.length=O)throw new Error("invalid sig")}$.exports=U}}),fY=P$({"node_modules/browserify-sign/browser/index.js"(bZ,$){var Q=M$().Buffer,Y=h$(),Z=L$("readable-stream"),G=v$(),V=yY(),U=wY(),X=o$();Object.keys(X).forEach(function(F){X[F].id=Q.from(X[F].id,"hex"),X[F.toLowerCase()]=X[F]});function K(F){Z.Writable.call(this);var A=X[F];if(!A)throw new Error("Unknown message digest");this._hashType=A.hash,this._hash=Y(A.hash),this._tag=A.id,this._signType=A.sign}G(K,Z.Writable),K.prototype._write=function(F,A,W){this._hash.update(F),W()},K.prototype.update=function(F,A){return typeof F=="string"&&(F=Q.from(F,A)),this._hash.update(F),this},K.prototype.sign=function(F,A){this.end();var W=this._hash.digest(),H=V(W,F,this._hashType,this._signType,this._tag);return A?H.toString(A):H};function I(F){Z.Writable.call(this);var A=X[F];if(!A)throw new Error("Unknown message digest");this._hash=Y(A.hash),this._tag=A.id,this._signType=A.sign}G(I,Z.Writable),I.prototype._write=function(F,A,W){this._hash.update(F),W()},I.prototype.update=function(F,A){return typeof F=="string"&&(F=Q.from(F,A)),this._hash.update(F),this},I.prototype.verify=function(F,A,W){typeof A=="string"&&(A=Q.from(A,W)),this.end();var H=this._hash.digest();return U(A,H,F,this._signType,this._tag)};function J(F){return new K(F)}function O(F){return new I(F)}$.exports={Sign:J,Verify:O,createSign:J,createVerify:O}}}),pY=P$({"node_modules/create-ecdh/node_modules/bn.js/lib/bn.js"(bZ,$){(function(Q,Y){function Z(q,j){if(!q)throw new Error(j||"Assertion failed")}function G(q,j){q.super_=j;var k=function(){};k.prototype=j.prototype,q.prototype=new k,q.prototype.constructor=q}function V(q,j,k){if(V.isBN(q))return q;this.negative=0,this.words=null,this.length=0,this.red=null,q!==null&&((j==="le"||j==="be")&&(k=j,j=10),this._init(q||0,j||10,k||"be"))}typeof Q=="object"?Q.exports=V:Y.BN=V,V.BN=V,V.wordSize=26;var U;try{typeof window<"u"&&typeof window.Buffer<"u"?U=window.Buffer:U=L$("buffer").Buffer}catch{}V.isBN=function(q){return q instanceof V?!0:q!==null&&typeof q=="object"&&q.constructor.wordSize===V.wordSize&&Array.isArray(q.words)},V.max=function(q,j){return q.cmp(j)>0?q:j},V.min=function(q,j){return q.cmp(j)<0?q:j},V.prototype._init=function(q,j,k){if(typeof q=="number")return this._initNumber(q,j,k);if(typeof q=="object")return this._initArray(q,j,k);j==="hex"&&(j=16),Z(j===(j|0)&&j>=2&&j<=36),q=q.toString().replace(/\s+/g,"");var g=0;q[0]==="-"&&(g++,this.negative=1),g=0;g-=3)x=q[g]|q[g-1]<<8|q[g-2]<<16,this.words[N]|=x<<_&67108863,this.words[N+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);else if(k==="le")for(g=0,N=0;g>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);return this.strip()};function X(q,j){var k=q.charCodeAt(j);return k>=65&&k<=70?k-55:k>=97&&k<=102?k-87:k-48&15}function K(q,j,k){var g=X(q,k);return k-1>=j&&(g|=X(q,k-1)<<4),g}V.prototype._parseHex=function(q,j,k){this.length=Math.ceil((q.length-j)/6),this.words=new Array(this.length);for(var g=0;g=j;g-=2)_=K(q,j,g)<=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8;else{var B=q.length-j;for(g=B%2===0?j+1:j;g=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8}this.strip()};function I(q,j,k,g){for(var N=0,x=Math.min(q.length,k),_=j;_=49?N+=B-49+10:B>=17?N+=B-17+10:N+=B}return N}V.prototype._parseBase=function(q,j,k){this.words=[0],this.length=1;for(var g=0,N=1;N<=67108863;N*=j)g++;g--,N=N/j|0;for(var x=q.length-k,_=x%g,B=Math.min(x,x-_)+k,y=0,w=k;w1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},V.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},V.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],O=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],F=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];V.prototype.toString=function(q,j){q=q||10,j=j|0||1;var k;if(q===16||q==="hex"){k="";for(var g=0,N=0,x=0;x>>24-g&16777215,N!==0||x!==this.length-1?k=J[6-B.length]+B+k:k=B+k,g+=2,g>=26&&(g-=26,x--)}for(N!==0&&(k=N.toString(16)+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}if(q===(q|0)&&q>=2&&q<=36){var y=O[q],w=F[q];k="";var f=this.clone();for(f.negative=0;!f.isZero();){var p=f.modn(w).toString(q);f=f.idivn(w),f.isZero()?k=p+k:k=J[y-p.length]+p+k}for(this.isZero()&&(k="0"+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}Z(!1,"Base should be between 2 and 36")},V.prototype.toNumber=function(){var q=this.words[0];return this.length===2?q+=this.words[1]*67108864:this.length===3&&this.words[2]===1?q+=4503599627370496+this.words[1]*67108864:this.length>2&&Z(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-q:q},V.prototype.toJSON=function(){return this.toString(16)},V.prototype.toBuffer=function(q,j){return Z(typeof U<"u"),this.toArrayLike(U,q,j)},V.prototype.toArray=function(q,j){return this.toArrayLike(Array,q,j)},V.prototype.toArrayLike=function(q,j,k){var g=this.byteLength(),N=k||Math.max(1,g);Z(g<=N,"byte array longer than desired length"),Z(N>0,"Requested array length <= 0"),this.strip();var x=j==="le",_=new q(N),B,y,w=this.clone();if(x){for(y=0;!w.isZero();y++)B=w.andln(255),w.iushrn(8),_[y]=B;for(;y=4096&&(k+=13,j>>>=13),j>=64&&(k+=7,j>>>=7),j>=8&&(k+=4,j>>>=4),j>=2&&(k+=2,j>>>=2),k+j},V.prototype._zeroBits=function(q){if(q===0)return 26;var j=q,k=0;return(j&8191)===0&&(k+=13,j>>>=13),(j&127)===0&&(k+=7,j>>>=7),(j&15)===0&&(k+=4,j>>>=4),(j&3)===0&&(k+=2,j>>>=2),(j&1)===0&&k++,k},V.prototype.bitLength=function(){var q=this.words[this.length-1],j=this._countBits(q);return(this.length-1)*26+j};function A(q){for(var j=new Array(q.bitLength()),k=0;k>>N}return j}V.prototype.zeroBits=function(){if(this.isZero())return 0;for(var q=0,j=0;jq.length?this.clone().ior(q):q.clone().ior(this)},V.prototype.uor=function(q){return this.length>q.length?this.clone().iuor(q):q.clone().iuor(this)},V.prototype.iuand=function(q){var j;this.length>q.length?j=q:j=this;for(var k=0;kq.length?this.clone().iand(q):q.clone().iand(this)},V.prototype.uand=function(q){return this.length>q.length?this.clone().iuand(q):q.clone().iuand(this)},V.prototype.iuxor=function(q){var j,k;this.length>q.length?(j=this,k=q):(j=q,k=this);for(var g=0;gq.length?this.clone().ixor(q):q.clone().ixor(this)},V.prototype.uxor=function(q){return this.length>q.length?this.clone().iuxor(q):q.clone().iuxor(this)},V.prototype.inotn=function(q){Z(typeof q=="number"&&q>=0);var j=Math.ceil(q/26)|0,k=q%26;this._expand(j),k>0&&j--;for(var g=0;g0&&(this.words[g]=~this.words[g]&67108863>>26-k),this.strip()},V.prototype.notn=function(q){return this.clone().inotn(q)},V.prototype.setn=function(q,j){Z(typeof q=="number"&&q>=0);var k=q/26|0,g=q%26;return this._expand(k+1),j?this.words[k]=this.words[k]|1<q.length?(k=this,g=q):(k=q,g=this);for(var N=0,x=0;x>>26;for(;N!==0&&x>>26;if(this.length=k.length,N!==0)this.words[this.length]=N,this.length++;else if(k!==this)for(;xq.length?this.clone().iadd(q):q.clone().iadd(this)},V.prototype.isub=function(q){if(q.negative!==0){q.negative=0;var j=this.iadd(q);return q.negative=1,j._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(q),this.negative=1,this._normSign();var k=this.cmp(q);if(k===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,N;k>0?(g=this,N=q):(g=q,N=this);for(var x=0,_=0;_>26,this.words[_]=j&67108863;for(;x!==0&&_>26,this.words[_]=j&67108863;if(x===0&&_>>26,p=y&67108863,c=Math.min(w,j.length-1),h=Math.max(0,w-q.length+1);h<=c;h++){var d=w-h|0;N=q.words[d]|0,x=j.words[h]|0,_=N*x+p,f+=_/67108864|0,p=_&67108863}k.words[w]=p|0,y=f|0}return y!==0?k.words[w]=y|0:k.length--,k.strip()}var H=function(q,j,k){var g=q.words,N=j.words,x=k.words,_=0,B,y,w,f=g[0]|0,p=f&8191,c=f>>>13,h=g[1]|0,d=h&8191,b=h>>>13,l=g[2]|0,o=l&8191,u=l>>>13,n=g[3]|0,s=n&8191,t=n>>>13,m=g[4]|0,a=m&8191,r=m>>>13,e=g[5]|0,i=e&8191,$0=e>>>13,Q0=g[6]|0,Y0=Q0&8191,Z0=Q0>>>13,G0=g[7]|0,V0=G0&8191,U0=G0>>>13,X0=g[8]|0,K0=X0&8191,I0=X0>>>13,J0=g[9]|0,O0=J0&8191,F0=J0>>>13,A0=N[0]|0,W0=A0&8191,H0=A0>>>13,E0=N[1]|0,T0=E0&8191,D0=E0>>>13,C0=N[2]|0,L0=C0&8191,R0=C0>>>13,P0=N[3]|0,z0=P0&8191,M0=P0>>>13,S0=N[4]|0,v0=S0&8191,q0=S0>>>13,j0=N[5]|0,k0=j0&8191,g0=j0>>>13,N0=N[6]|0,x0=N0&8191,_0=N0>>>13,B0=N[7]|0,y0=B0&8191,w0=B0>>>13,f0=N[8]|0,p0=f0&8191,c0=f0>>>13,h0=N[9]|0,d0=h0&8191,b0=h0>>>13;k.negative=q.negative^j.negative,k.length=19,B=Math.imul(p,W0),y=Math.imul(p,H0),y=y+Math.imul(c,W0)|0,w=Math.imul(c,H0);var l0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(l0>>>26)|0,l0&=67108863,B=Math.imul(d,W0),y=Math.imul(d,H0),y=y+Math.imul(b,W0)|0,w=Math.imul(b,H0),B=B+Math.imul(p,T0)|0,y=y+Math.imul(p,D0)|0,y=y+Math.imul(c,T0)|0,w=w+Math.imul(c,D0)|0;var o0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(o0>>>26)|0,o0&=67108863,B=Math.imul(o,W0),y=Math.imul(o,H0),y=y+Math.imul(u,W0)|0,w=Math.imul(u,H0),B=B+Math.imul(d,T0)|0,y=y+Math.imul(d,D0)|0,y=y+Math.imul(b,T0)|0,w=w+Math.imul(b,D0)|0,B=B+Math.imul(p,L0)|0,y=y+Math.imul(p,R0)|0,y=y+Math.imul(c,L0)|0,w=w+Math.imul(c,R0)|0;var u0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(u0>>>26)|0,u0&=67108863,B=Math.imul(s,W0),y=Math.imul(s,H0),y=y+Math.imul(t,W0)|0,w=Math.imul(t,H0),B=B+Math.imul(o,T0)|0,y=y+Math.imul(o,D0)|0,y=y+Math.imul(u,T0)|0,w=w+Math.imul(u,D0)|0,B=B+Math.imul(d,L0)|0,y=y+Math.imul(d,R0)|0,y=y+Math.imul(b,L0)|0,w=w+Math.imul(b,R0)|0,B=B+Math.imul(p,z0)|0,y=y+Math.imul(p,M0)|0,y=y+Math.imul(c,z0)|0,w=w+Math.imul(c,M0)|0;var n0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(n0>>>26)|0,n0&=67108863,B=Math.imul(a,W0),y=Math.imul(a,H0),y=y+Math.imul(r,W0)|0,w=Math.imul(r,H0),B=B+Math.imul(s,T0)|0,y=y+Math.imul(s,D0)|0,y=y+Math.imul(t,T0)|0,w=w+Math.imul(t,D0)|0,B=B+Math.imul(o,L0)|0,y=y+Math.imul(o,R0)|0,y=y+Math.imul(u,L0)|0,w=w+Math.imul(u,R0)|0,B=B+Math.imul(d,z0)|0,y=y+Math.imul(d,M0)|0,y=y+Math.imul(b,z0)|0,w=w+Math.imul(b,M0)|0,B=B+Math.imul(p,v0)|0,y=y+Math.imul(p,q0)|0,y=y+Math.imul(c,v0)|0,w=w+Math.imul(c,q0)|0;var s0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(s0>>>26)|0,s0&=67108863,B=Math.imul(i,W0),y=Math.imul(i,H0),y=y+Math.imul($0,W0)|0,w=Math.imul($0,H0),B=B+Math.imul(a,T0)|0,y=y+Math.imul(a,D0)|0,y=y+Math.imul(r,T0)|0,w=w+Math.imul(r,D0)|0,B=B+Math.imul(s,L0)|0,y=y+Math.imul(s,R0)|0,y=y+Math.imul(t,L0)|0,w=w+Math.imul(t,R0)|0,B=B+Math.imul(o,z0)|0,y=y+Math.imul(o,M0)|0,y=y+Math.imul(u,z0)|0,w=w+Math.imul(u,M0)|0,B=B+Math.imul(d,v0)|0,y=y+Math.imul(d,q0)|0,y=y+Math.imul(b,v0)|0,w=w+Math.imul(b,q0)|0,B=B+Math.imul(p,k0)|0,y=y+Math.imul(p,g0)|0,y=y+Math.imul(c,k0)|0,w=w+Math.imul(c,g0)|0;var t0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(t0>>>26)|0,t0&=67108863,B=Math.imul(Y0,W0),y=Math.imul(Y0,H0),y=y+Math.imul(Z0,W0)|0,w=Math.imul(Z0,H0),B=B+Math.imul(i,T0)|0,y=y+Math.imul(i,D0)|0,y=y+Math.imul($0,T0)|0,w=w+Math.imul($0,D0)|0,B=B+Math.imul(a,L0)|0,y=y+Math.imul(a,R0)|0,y=y+Math.imul(r,L0)|0,w=w+Math.imul(r,R0)|0,B=B+Math.imul(s,z0)|0,y=y+Math.imul(s,M0)|0,y=y+Math.imul(t,z0)|0,w=w+Math.imul(t,M0)|0,B=B+Math.imul(o,v0)|0,y=y+Math.imul(o,q0)|0,y=y+Math.imul(u,v0)|0,w=w+Math.imul(u,q0)|0,B=B+Math.imul(d,k0)|0,y=y+Math.imul(d,g0)|0,y=y+Math.imul(b,k0)|0,w=w+Math.imul(b,g0)|0,B=B+Math.imul(p,x0)|0,y=y+Math.imul(p,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,_0)|0;var m0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(m0>>>26)|0,m0&=67108863,B=Math.imul(V0,W0),y=Math.imul(V0,H0),y=y+Math.imul(U0,W0)|0,w=Math.imul(U0,H0),B=B+Math.imul(Y0,T0)|0,y=y+Math.imul(Y0,D0)|0,y=y+Math.imul(Z0,T0)|0,w=w+Math.imul(Z0,D0)|0,B=B+Math.imul(i,L0)|0,y=y+Math.imul(i,R0)|0,y=y+Math.imul($0,L0)|0,w=w+Math.imul($0,R0)|0,B=B+Math.imul(a,z0)|0,y=y+Math.imul(a,M0)|0,y=y+Math.imul(r,z0)|0,w=w+Math.imul(r,M0)|0,B=B+Math.imul(s,v0)|0,y=y+Math.imul(s,q0)|0,y=y+Math.imul(t,v0)|0,w=w+Math.imul(t,q0)|0,B=B+Math.imul(o,k0)|0,y=y+Math.imul(o,g0)|0,y=y+Math.imul(u,k0)|0,w=w+Math.imul(u,g0)|0,B=B+Math.imul(d,x0)|0,y=y+Math.imul(d,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,_0)|0,B=B+Math.imul(p,y0)|0,y=y+Math.imul(p,w0)|0,y=y+Math.imul(c,y0)|0,w=w+Math.imul(c,w0)|0;var a0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(a0>>>26)|0,a0&=67108863,B=Math.imul(K0,W0),y=Math.imul(K0,H0),y=y+Math.imul(I0,W0)|0,w=Math.imul(I0,H0),B=B+Math.imul(V0,T0)|0,y=y+Math.imul(V0,D0)|0,y=y+Math.imul(U0,T0)|0,w=w+Math.imul(U0,D0)|0,B=B+Math.imul(Y0,L0)|0,y=y+Math.imul(Y0,R0)|0,y=y+Math.imul(Z0,L0)|0,w=w+Math.imul(Z0,R0)|0,B=B+Math.imul(i,z0)|0,y=y+Math.imul(i,M0)|0,y=y+Math.imul($0,z0)|0,w=w+Math.imul($0,M0)|0,B=B+Math.imul(a,v0)|0,y=y+Math.imul(a,q0)|0,y=y+Math.imul(r,v0)|0,w=w+Math.imul(r,q0)|0,B=B+Math.imul(s,k0)|0,y=y+Math.imul(s,g0)|0,y=y+Math.imul(t,k0)|0,w=w+Math.imul(t,g0)|0,B=B+Math.imul(o,x0)|0,y=y+Math.imul(o,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,_0)|0,B=B+Math.imul(d,y0)|0,y=y+Math.imul(d,w0)|0,y=y+Math.imul(b,y0)|0,w=w+Math.imul(b,w0)|0,B=B+Math.imul(p,p0)|0,y=y+Math.imul(p,c0)|0,y=y+Math.imul(c,p0)|0,w=w+Math.imul(c,c0)|0;var r0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(r0>>>26)|0,r0&=67108863,B=Math.imul(O0,W0),y=Math.imul(O0,H0),y=y+Math.imul(F0,W0)|0,w=Math.imul(F0,H0),B=B+Math.imul(K0,T0)|0,y=y+Math.imul(K0,D0)|0,y=y+Math.imul(I0,T0)|0,w=w+Math.imul(I0,D0)|0,B=B+Math.imul(V0,L0)|0,y=y+Math.imul(V0,R0)|0,y=y+Math.imul(U0,L0)|0,w=w+Math.imul(U0,R0)|0,B=B+Math.imul(Y0,z0)|0,y=y+Math.imul(Y0,M0)|0,y=y+Math.imul(Z0,z0)|0,w=w+Math.imul(Z0,M0)|0,B=B+Math.imul(i,v0)|0,y=y+Math.imul(i,q0)|0,y=y+Math.imul($0,v0)|0,w=w+Math.imul($0,q0)|0,B=B+Math.imul(a,k0)|0,y=y+Math.imul(a,g0)|0,y=y+Math.imul(r,k0)|0,w=w+Math.imul(r,g0)|0,B=B+Math.imul(s,x0)|0,y=y+Math.imul(s,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,_0)|0,B=B+Math.imul(o,y0)|0,y=y+Math.imul(o,w0)|0,y=y+Math.imul(u,y0)|0,w=w+Math.imul(u,w0)|0,B=B+Math.imul(d,p0)|0,y=y+Math.imul(d,c0)|0,y=y+Math.imul(b,p0)|0,w=w+Math.imul(b,c0)|0,B=B+Math.imul(p,d0)|0,y=y+Math.imul(p,b0)|0,y=y+Math.imul(c,d0)|0,w=w+Math.imul(c,b0)|0;var e0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(e0>>>26)|0,e0&=67108863,B=Math.imul(O0,T0),y=Math.imul(O0,D0),y=y+Math.imul(F0,T0)|0,w=Math.imul(F0,D0),B=B+Math.imul(K0,L0)|0,y=y+Math.imul(K0,R0)|0,y=y+Math.imul(I0,L0)|0,w=w+Math.imul(I0,R0)|0,B=B+Math.imul(V0,z0)|0,y=y+Math.imul(V0,M0)|0,y=y+Math.imul(U0,z0)|0,w=w+Math.imul(U0,M0)|0,B=B+Math.imul(Y0,v0)|0,y=y+Math.imul(Y0,q0)|0,y=y+Math.imul(Z0,v0)|0,w=w+Math.imul(Z0,q0)|0,B=B+Math.imul(i,k0)|0,y=y+Math.imul(i,g0)|0,y=y+Math.imul($0,k0)|0,w=w+Math.imul($0,g0)|0,B=B+Math.imul(a,x0)|0,y=y+Math.imul(a,_0)|0,y=y+Math.imul(r,x0)|0,w=w+Math.imul(r,_0)|0,B=B+Math.imul(s,y0)|0,y=y+Math.imul(s,w0)|0,y=y+Math.imul(t,y0)|0,w=w+Math.imul(t,w0)|0,B=B+Math.imul(o,p0)|0,y=y+Math.imul(o,c0)|0,y=y+Math.imul(u,p0)|0,w=w+Math.imul(u,c0)|0,B=B+Math.imul(d,d0)|0,y=y+Math.imul(d,b0)|0,y=y+Math.imul(b,d0)|0,w=w+Math.imul(b,b0)|0;var i0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(i0>>>26)|0,i0&=67108863,B=Math.imul(O0,L0),y=Math.imul(O0,R0),y=y+Math.imul(F0,L0)|0,w=Math.imul(F0,R0),B=B+Math.imul(K0,z0)|0,y=y+Math.imul(K0,M0)|0,y=y+Math.imul(I0,z0)|0,w=w+Math.imul(I0,M0)|0,B=B+Math.imul(V0,v0)|0,y=y+Math.imul(V0,q0)|0,y=y+Math.imul(U0,v0)|0,w=w+Math.imul(U0,q0)|0,B=B+Math.imul(Y0,k0)|0,y=y+Math.imul(Y0,g0)|0,y=y+Math.imul(Z0,k0)|0,w=w+Math.imul(Z0,g0)|0,B=B+Math.imul(i,x0)|0,y=y+Math.imul(i,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,_0)|0,B=B+Math.imul(a,y0)|0,y=y+Math.imul(a,w0)|0,y=y+Math.imul(r,y0)|0,w=w+Math.imul(r,w0)|0,B=B+Math.imul(s,p0)|0,y=y+Math.imul(s,c0)|0,y=y+Math.imul(t,p0)|0,w=w+Math.imul(t,c0)|0,B=B+Math.imul(o,d0)|0,y=y+Math.imul(o,b0)|0,y=y+Math.imul(u,d0)|0,w=w+Math.imul(u,b0)|0;var $$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+($$>>>26)|0,$$&=67108863,B=Math.imul(O0,z0),y=Math.imul(O0,M0),y=y+Math.imul(F0,z0)|0,w=Math.imul(F0,M0),B=B+Math.imul(K0,v0)|0,y=y+Math.imul(K0,q0)|0,y=y+Math.imul(I0,v0)|0,w=w+Math.imul(I0,q0)|0,B=B+Math.imul(V0,k0)|0,y=y+Math.imul(V0,g0)|0,y=y+Math.imul(U0,k0)|0,w=w+Math.imul(U0,g0)|0,B=B+Math.imul(Y0,x0)|0,y=y+Math.imul(Y0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,_0)|0,B=B+Math.imul(i,y0)|0,y=y+Math.imul(i,w0)|0,y=y+Math.imul($0,y0)|0,w=w+Math.imul($0,w0)|0,B=B+Math.imul(a,p0)|0,y=y+Math.imul(a,c0)|0,y=y+Math.imul(r,p0)|0,w=w+Math.imul(r,c0)|0,B=B+Math.imul(s,d0)|0,y=y+Math.imul(s,b0)|0,y=y+Math.imul(t,d0)|0,w=w+Math.imul(t,b0)|0;var Q$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,B=Math.imul(O0,v0),y=Math.imul(O0,q0),y=y+Math.imul(F0,v0)|0,w=Math.imul(F0,q0),B=B+Math.imul(K0,k0)|0,y=y+Math.imul(K0,g0)|0,y=y+Math.imul(I0,k0)|0,w=w+Math.imul(I0,g0)|0,B=B+Math.imul(V0,x0)|0,y=y+Math.imul(V0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,_0)|0,B=B+Math.imul(Y0,y0)|0,y=y+Math.imul(Y0,w0)|0,y=y+Math.imul(Z0,y0)|0,w=w+Math.imul(Z0,w0)|0,B=B+Math.imul(i,p0)|0,y=y+Math.imul(i,c0)|0,y=y+Math.imul($0,p0)|0,w=w+Math.imul($0,c0)|0,B=B+Math.imul(a,d0)|0,y=y+Math.imul(a,b0)|0,y=y+Math.imul(r,d0)|0,w=w+Math.imul(r,b0)|0;var Y$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,B=Math.imul(O0,k0),y=Math.imul(O0,g0),y=y+Math.imul(F0,k0)|0,w=Math.imul(F0,g0),B=B+Math.imul(K0,x0)|0,y=y+Math.imul(K0,_0)|0,y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,_0)|0,B=B+Math.imul(V0,y0)|0,y=y+Math.imul(V0,w0)|0,y=y+Math.imul(U0,y0)|0,w=w+Math.imul(U0,w0)|0,B=B+Math.imul(Y0,p0)|0,y=y+Math.imul(Y0,c0)|0,y=y+Math.imul(Z0,p0)|0,w=w+Math.imul(Z0,c0)|0,B=B+Math.imul(i,d0)|0,y=y+Math.imul(i,b0)|0,y=y+Math.imul($0,d0)|0,w=w+Math.imul($0,b0)|0;var Z$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,B=Math.imul(O0,x0),y=Math.imul(O0,_0),y=y+Math.imul(F0,x0)|0,w=Math.imul(F0,_0),B=B+Math.imul(K0,y0)|0,y=y+Math.imul(K0,w0)|0,y=y+Math.imul(I0,y0)|0,w=w+Math.imul(I0,w0)|0,B=B+Math.imul(V0,p0)|0,y=y+Math.imul(V0,c0)|0,y=y+Math.imul(U0,p0)|0,w=w+Math.imul(U0,c0)|0,B=B+Math.imul(Y0,d0)|0,y=y+Math.imul(Y0,b0)|0,y=y+Math.imul(Z0,d0)|0,w=w+Math.imul(Z0,b0)|0;var G$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(G$>>>26)|0,G$&=67108863,B=Math.imul(O0,y0),y=Math.imul(O0,w0),y=y+Math.imul(F0,y0)|0,w=Math.imul(F0,w0),B=B+Math.imul(K0,p0)|0,y=y+Math.imul(K0,c0)|0,y=y+Math.imul(I0,p0)|0,w=w+Math.imul(I0,c0)|0,B=B+Math.imul(V0,d0)|0,y=y+Math.imul(V0,b0)|0,y=y+Math.imul(U0,d0)|0,w=w+Math.imul(U0,b0)|0;var V$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(V$>>>26)|0,V$&=67108863,B=Math.imul(O0,p0),y=Math.imul(O0,c0),y=y+Math.imul(F0,p0)|0,w=Math.imul(F0,c0),B=B+Math.imul(K0,d0)|0,y=y+Math.imul(K0,b0)|0,y=y+Math.imul(I0,d0)|0,w=w+Math.imul(I0,b0)|0;var U$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(U$>>>26)|0,U$&=67108863,B=Math.imul(O0,d0),y=Math.imul(O0,b0),y=y+Math.imul(F0,d0)|0,w=Math.imul(F0,b0);var X$=(_+B|0)+((y&8191)<<13)|0;return _=(w+(y>>>13)|0)+(X$>>>26)|0,X$&=67108863,x[0]=l0,x[1]=o0,x[2]=u0,x[3]=n0,x[4]=s0,x[5]=t0,x[6]=m0,x[7]=a0,x[8]=r0,x[9]=e0,x[10]=i0,x[11]=$$,x[12]=Q$,x[13]=Y$,x[14]=Z$,x[15]=G$,x[16]=V$,x[17]=U$,x[18]=X$,_!==0&&(x[19]=_,k.length++),k};Math.imul||(H=W);function E(q,j,k){k.negative=j.negative^q.negative,k.length=q.length+j.length;for(var g=0,N=0,x=0;x>>26)|0,N+=_>>>26,_&=67108863}k.words[x]=B,g=_,_=N}return g!==0?k.words[x]=g:k.length--,k.strip()}function T(q,j,k){var g=new D;return g.mulp(q,j,k)}V.prototype.mulTo=function(q,j){var k,g=this.length+q.length;return this.length===10&&q.length===10?k=H(this,q,j):g<63?k=W(this,q,j):g<1024?k=E(this,q,j):k=T(this,q,j),k};function D(q,j){this.x=q,this.y=j}D.prototype.makeRBT=function(q){for(var j=new Array(q),k=V.prototype._countBits(q)-1,g=0;g>=1;return g},D.prototype.permute=function(q,j,k,g,N,x){for(var _=0;_>>1)N++;return 1<>>13,k[2*x+1]=N&8191,N=N>>>13;for(x=2*j;x>=26,j+=g/67108864|0,j+=N>>>26,this.words[k]=N&67108863}return j!==0&&(this.words[k]=j,this.length++),this},V.prototype.muln=function(q){return this.clone().imuln(q)},V.prototype.sqr=function(){return this.mul(this)},V.prototype.isqr=function(){return this.imul(this.clone())},V.prototype.pow=function(q){var j=A(q);if(j.length===0)return new V(1);for(var k=this,g=0;g=0);var j=q%26,k=(q-j)/26,g=67108863>>>26-j<<26-j,N;if(j!==0){var x=0;for(N=0;N>>26-j}x&&(this.words[N]=x,this.length++)}if(k!==0){for(N=this.length-1;N>=0;N--)this.words[N+k]=this.words[N];for(N=0;N=0);var g;j?g=(j-j%26)/26:g=0;var N=q%26,x=Math.min((q-N)/26,this.length),_=67108863^67108863>>>N<x)for(this.length-=x,y=0;y=0&&(w!==0||y>=g);y--){var f=this.words[y]|0;this.words[y]=w<<26-N|f>>>N,w=f&_}return B&&w!==0&&(B.words[B.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},V.prototype.ishrn=function(q,j,k){return Z(this.negative===0),this.iushrn(q,j,k)},V.prototype.shln=function(q){return this.clone().ishln(q)},V.prototype.ushln=function(q){return this.clone().iushln(q)},V.prototype.shrn=function(q){return this.clone().ishrn(q)},V.prototype.ushrn=function(q){return this.clone().iushrn(q)},V.prototype.testn=function(q){Z(typeof q=="number"&&q>=0);var j=q%26,k=(q-j)/26,g=1<=0);var j=q%26,k=(q-j)/26;if(Z(this.negative===0,"imaskn works only with positive numbers"),this.length<=k)return this;if(j!==0&&k++,this.length=Math.min(k,this.length),j!==0){var g=67108863^67108863>>>j<=67108864;j++)this.words[j]-=67108864,j===this.length-1?this.words[j+1]=1:this.words[j+1]++;return this.length=Math.max(this.length,j+1),this},V.prototype.isubn=function(q){if(Z(typeof q=="number"),Z(q<67108864),q<0)return this.iaddn(-q);if(this.negative!==0)return this.negative=0,this.iaddn(q),this.negative=1,this;if(this.words[0]-=q,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var j=0;j>26)-(B/67108864|0),this.words[N+k]=x&67108863}for(;N>26,this.words[N+k]=x&67108863;if(_===0)return this.strip();for(Z(_===-1),_=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},V.prototype._wordDiv=function(q,j){var k=this.length-q.length,g=this.clone(),N=q,x=N.words[N.length-1]|0,_=this._countBits(x);k=26-_,k!==0&&(N=N.ushln(k),g.iushln(k),x=N.words[N.length-1]|0);var B=g.length-N.length,y;if(j!=="mod"){y=new V(null),y.length=B+1,y.words=new Array(y.length);for(var w=0;w=0;p--){var c=(g.words[N.length+p]|0)*67108864+(g.words[N.length+p-1]|0);for(c=Math.min(c/x|0,67108863),g._ishlnsubmul(N,c,p);g.negative!==0;)c--,g.negative=0,g._ishlnsubmul(N,1,p),g.isZero()||(g.negative^=1);y&&(y.words[p]=c)}return y&&y.strip(),g.strip(),j!=="div"&&k!==0&&g.iushrn(k),{div:y||null,mod:g}},V.prototype.divmod=function(q,j,k){if(Z(!q.isZero()),this.isZero())return{div:new V(0),mod:new V(0)};var g,N,x;return this.negative!==0&&q.negative===0?(x=this.neg().divmod(q,j),j!=="mod"&&(g=x.div.neg()),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.iadd(q)),{div:g,mod:N}):this.negative===0&&q.negative!==0?(x=this.divmod(q.neg(),j),j!=="mod"&&(g=x.div.neg()),{div:g,mod:x.mod}):(this.negative&q.negative)!==0?(x=this.neg().divmod(q.neg(),j),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.isub(q)),{div:x.div,mod:N}):q.length>this.length||this.cmp(q)<0?{div:new V(0),mod:this}:q.length===1?j==="div"?{div:this.divn(q.words[0]),mod:null}:j==="mod"?{div:null,mod:new V(this.modn(q.words[0]))}:{div:this.divn(q.words[0]),mod:new V(this.modn(q.words[0]))}:this._wordDiv(q,j)},V.prototype.div=function(q){return this.divmod(q,"div",!1).div},V.prototype.mod=function(q){return this.divmod(q,"mod",!1).mod},V.prototype.umod=function(q){return this.divmod(q,"mod",!0).mod},V.prototype.divRound=function(q){var j=this.divmod(q);if(j.mod.isZero())return j.div;var k=j.div.negative!==0?j.mod.isub(q):j.mod,g=q.ushrn(1),N=q.andln(1),x=k.cmp(g);return x<0||N===1&&x===0?j.div:j.div.negative!==0?j.div.isubn(1):j.div.iaddn(1)},V.prototype.modn=function(q){Z(q<=67108863);for(var j=(1<<26)%q,k=0,g=this.length-1;g>=0;g--)k=(j*k+(this.words[g]|0))%q;return k},V.prototype.idivn=function(q){Z(q<=67108863);for(var j=0,k=this.length-1;k>=0;k--){var g=(this.words[k]|0)+j*67108864;this.words[k]=g/q|0,j=g%q}return this.strip()},V.prototype.divn=function(q){return this.clone().idivn(q)},V.prototype.egcd=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=new V(0),_=new V(1),B=0;j.isEven()&&k.isEven();)j.iushrn(1),k.iushrn(1),++B;for(var y=k.clone(),w=j.clone();!j.isZero();){for(var f=0,p=1;(j.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(j.iushrn(f);f-- >0;)(g.isOdd()||N.isOdd())&&(g.iadd(y),N.isub(w)),g.iushrn(1),N.iushrn(1);for(var c=0,h=1;(k.words[0]&h)===0&&c<26;++c,h<<=1);if(c>0)for(k.iushrn(c);c-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(y),_.isub(w)),x.iushrn(1),_.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(x),N.isub(_)):(k.isub(j),x.isub(g),_.isub(N))}return{a:x,b:_,gcd:k.iushln(B)}},V.prototype._invmp=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=k.clone();j.cmpn(1)>0&&k.cmpn(1)>0;){for(var _=0,B=1;(j.words[0]&B)===0&&_<26;++_,B<<=1);if(_>0)for(j.iushrn(_);_-- >0;)g.isOdd()&&g.iadd(x),g.iushrn(1);for(var y=0,w=1;(k.words[0]&w)===0&&y<26;++y,w<<=1);if(y>0)for(k.iushrn(y);y-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(N)):(k.isub(j),N.isub(g))}var f;return j.cmpn(1)===0?f=g:f=N,f.cmpn(0)<0&&f.iadd(q),f},V.prototype.gcd=function(q){if(this.isZero())return q.abs();if(q.isZero())return this.abs();var j=this.clone(),k=q.clone();j.negative=0,k.negative=0;for(var g=0;j.isEven()&&k.isEven();g++)j.iushrn(1),k.iushrn(1);do{for(;j.isEven();)j.iushrn(1);for(;k.isEven();)k.iushrn(1);var N=j.cmp(k);if(N<0){var x=j;j=k,k=x}else if(N===0||k.cmpn(1)===0)break;j.isub(k)}while(!0);return k.iushln(g)},V.prototype.invm=function(q){return this.egcd(q).a.umod(q)},V.prototype.isEven=function(){return(this.words[0]&1)===0},V.prototype.isOdd=function(){return(this.words[0]&1)===1},V.prototype.andln=function(q){return this.words[0]&q},V.prototype.bincn=function(q){Z(typeof q=="number");var j=q%26,k=(q-j)/26,g=1<>>26,_&=67108863,this.words[x]=_}return N!==0&&(this.words[x]=N,this.length++),this},V.prototype.isZero=function(){return this.length===1&&this.words[0]===0},V.prototype.cmpn=function(q){var j=q<0;if(this.negative!==0&&!j)return-1;if(this.negative===0&&j)return 1;this.strip();var k;if(this.length>1)k=1;else{j&&(q=-q),Z(q<=67108863,"Number is too big");var g=this.words[0]|0;k=g===q?0:gq.length)return 1;if(this.length=0;k--){var g=this.words[k]|0,N=q.words[k]|0;if(g!==N){gN&&(j=1);break}}return j},V.prototype.gtn=function(q){return this.cmpn(q)===1},V.prototype.gt=function(q){return this.cmp(q)===1},V.prototype.gten=function(q){return this.cmpn(q)>=0},V.prototype.gte=function(q){return this.cmp(q)>=0},V.prototype.ltn=function(q){return this.cmpn(q)===-1},V.prototype.lt=function(q){return this.cmp(q)===-1},V.prototype.lten=function(q){return this.cmpn(q)<=0},V.prototype.lte=function(q){return this.cmp(q)<=0},V.prototype.eqn=function(q){return this.cmpn(q)===0},V.prototype.eq=function(q){return this.cmp(q)===0},V.red=function(q){return new S(q)},V.prototype.toRed=function(q){return Z(!this.red,"Already a number in reduction context"),Z(this.negative===0,"red works only with positives"),q.convertTo(this)._forceRed(q)},V.prototype.fromRed=function(){return Z(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},V.prototype._forceRed=function(q){return this.red=q,this},V.prototype.forceRed=function(q){return Z(!this.red,"Already a number in reduction context"),this._forceRed(q)},V.prototype.redAdd=function(q){return Z(this.red,"redAdd works only with red numbers"),this.red.add(this,q)},V.prototype.redIAdd=function(q){return Z(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,q)},V.prototype.redSub=function(q){return Z(this.red,"redSub works only with red numbers"),this.red.sub(this,q)},V.prototype.redISub=function(q){return Z(this.red,"redISub works only with red numbers"),this.red.isub(this,q)},V.prototype.redShl=function(q){return Z(this.red,"redShl works only with red numbers"),this.red.shl(this,q)},V.prototype.redMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.mul(this,q)},V.prototype.redIMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.imul(this,q)},V.prototype.redSqr=function(){return Z(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},V.prototype.redISqr=function(){return Z(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},V.prototype.redSqrt=function(){return Z(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},V.prototype.redInvm=function(){return Z(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},V.prototype.redNeg=function(){return Z(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},V.prototype.redPow=function(q){return Z(this.red&&!q.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,q)};var C={k256:null,p224:null,p192:null,p25519:null};function L(q,j){this.name=q,this.p=new V(j,16),this.n=this.p.bitLength(),this.k=new V(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}L.prototype._tmp=function(){var q=new V(null);return q.words=new Array(Math.ceil(this.n/13)),q},L.prototype.ireduce=function(q){var j=q,k;do this.split(j,this.tmp),j=this.imulK(j),j=j.iadd(this.tmp),k=j.bitLength();while(k>this.n);var g=k0?j.isub(this.p):j.strip!==void 0?j.strip():j._strip(),j},L.prototype.split=function(q,j){q.iushrn(this.n,0,j)},L.prototype.imulK=function(q){return q.imul(this.k)};function R(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}G(R,L),R.prototype.split=function(q,j){for(var k=4194303,g=Math.min(q.length,9),N=0;N>>22,x=_}x>>>=22,q.words[N-10]=x,x===0&&q.length>10?q.length-=10:q.length-=9},R.prototype.imulK=function(q){q.words[q.length]=0,q.words[q.length+1]=0,q.length+=2;for(var j=0,k=0;k>>=26,q.words[k]=N,j=g}return j!==0&&(q.words[q.length++]=j),q},V._prime=function(q){if(C[q])return C[q];var j;if(q==="k256")j=new R;else if(q==="p224")j=new P;else if(q==="p192")j=new z;else if(q==="p25519")j=new M;else throw new Error("Unknown prime "+q);return C[q]=j,j};function S(q){if(typeof q=="string"){var j=V._prime(q);this.m=j.p,this.prime=j}else Z(q.gtn(1),"modulus must be greater than 1"),this.m=q,this.prime=null}S.prototype._verify1=function(q){Z(q.negative===0,"red works only with positives"),Z(q.red,"red works only with red numbers")},S.prototype._verify2=function(q,j){Z((q.negative|j.negative)===0,"red works only with positives"),Z(q.red&&q.red===j.red,"red works only with red numbers")},S.prototype.imod=function(q){return this.prime?this.prime.ireduce(q)._forceRed(this):q.umod(this.m)._forceRed(this)},S.prototype.neg=function(q){return q.isZero()?q.clone():this.m.sub(q)._forceRed(this)},S.prototype.add=function(q,j){this._verify2(q,j);var k=q.add(j);return k.cmp(this.m)>=0&&k.isub(this.m),k._forceRed(this)},S.prototype.iadd=function(q,j){this._verify2(q,j);var k=q.iadd(j);return k.cmp(this.m)>=0&&k.isub(this.m),k},S.prototype.sub=function(q,j){this._verify2(q,j);var k=q.sub(j);return k.cmpn(0)<0&&k.iadd(this.m),k._forceRed(this)},S.prototype.isub=function(q,j){this._verify2(q,j);var k=q.isub(j);return k.cmpn(0)<0&&k.iadd(this.m),k},S.prototype.shl=function(q,j){return this._verify1(q),this.imod(q.ushln(j))},S.prototype.imul=function(q,j){return this._verify2(q,j),this.imod(q.imul(j))},S.prototype.mul=function(q,j){return this._verify2(q,j),this.imod(q.mul(j))},S.prototype.isqr=function(q){return this.imul(q,q.clone())},S.prototype.sqr=function(q){return this.mul(q,q)},S.prototype.sqrt=function(q){if(q.isZero())return q.clone();var j=this.m.andln(3);if(Z(j%2===1),j===3){var k=this.m.add(new V(1)).iushrn(2);return this.pow(q,k)}for(var g=this.m.subn(1),N=0;!g.isZero()&&g.andln(1)===0;)N++,g.iushrn(1);Z(!g.isZero());var x=new V(1).toRed(this),_=x.redNeg(),B=this.m.subn(1).iushrn(1),y=this.m.bitLength();for(y=new V(2*y*y).toRed(this);this.pow(y,B).cmp(_)!==0;)y.redIAdd(_);for(var w=this.pow(y,g),f=this.pow(q,g.addn(1).iushrn(1)),p=this.pow(q,g),c=N;p.cmp(x)!==0;){for(var h=p,d=0;h.cmp(x)!==0;d++)h=h.redSqr();Z(d=0;N--){for(var w=j.words[N],f=y-1;f>=0;f--){var p=w>>f&1;if(x!==g[0]&&(x=this.sqr(x)),p===0&&_===0){B=0;continue}_<<=1,_|=p,B++,!(B!==k&&(N!==0||f!==0))&&(x=this.mul(x,g[_]),B=0,_=0)}y=26}return x},S.prototype.convertTo=function(q){var j=q.umod(this.m);return j===q?j.clone():j},S.prototype.convertFrom=function(q){var j=q.clone();return j.red=null,j},V.mont=function(q){return new v(q)};function v(q){S.call(this,q),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new V(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}G(v,S),v.prototype.convertTo=function(q){return this.imod(q.ushln(this.shift))},v.prototype.convertFrom=function(q){var j=this.imod(q.mul(this.rinv));return j.red=null,j},v.prototype.imul=function(q,j){if(q.isZero()||j.isZero())return q.words[0]=0,q.length=1,q;var k=q.imul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.mul=function(q,j){if(q.isZero()||j.isZero())return new V(0)._forceRed(this);var k=q.mul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.invm=function(q){var j=this.imod(q._invmp(this.m).mul(this.r2));return j._forceRed(this)}})(typeof $>"u"||$,bZ)}}),cY=P$({"node_modules/create-ecdh/browser.js"(bZ,$){var Q=AY(),Y=pY();$.exports=function(U){return new G(U)};var Z={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};Z.p224=Z.secp224r1,Z.p256=Z.secp256r1=Z.prime256v1,Z.p192=Z.secp192r1=Z.prime192v1,Z.p384=Z.secp384r1,Z.p521=Z.secp521r1;function G(U){this.curveType=Z[U],this.curveType||(this.curveType={name:U}),this.curve=new Q.ec(this.curveType.name),this.keys=void 0}G.prototype.generateKeys=function(U,X){return this.keys=this.curve.genKeyPair(),this.getPublicKey(U,X)},G.prototype.computeSecret=function(U,X,K){X=X||"utf8",Buffer.isBuffer(U)||(U=new Buffer(U,X));var I=this.curve.keyFromPublic(U).getPublic(),J=I.mul(this.keys.getPrivate()).getX();return V(J,K,this.curveType.byteLength)},G.prototype.getPublicKey=function(U,X){var K=this.keys.getPublic(X==="compressed",!0);return X==="hybrid"&&(K[K.length-1]%2?K[0]=7:K[0]=6),V(K,U)},G.prototype.getPrivateKey=function(U){return V(this.keys.getPrivate(),U)},G.prototype.setPublicKey=function(U,X){return X=X||"utf8",Buffer.isBuffer(U)||(U=new Buffer(U,X)),this.keys._importPublic(U),this},G.prototype.setPrivateKey=function(U,X){X=X||"utf8",Buffer.isBuffer(U)||(U=new Buffer(U,X));var K=new Y(U);return K=K.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(K),this};function V(U,X,K){Array.isArray(U)||(U=U.toArray());var I=new Buffer(U);if(K&&I.length0?q:j},V.min=function(q,j){return q.cmp(j)<0?q:j},V.prototype._init=function(q,j,k){if(typeof q=="number")return this._initNumber(q,j,k);if(typeof q=="object")return this._initArray(q,j,k);j==="hex"&&(j=16),Z(j===(j|0)&&j>=2&&j<=36),q=q.toString().replace(/\s+/g,"");var g=0;q[0]==="-"&&(g++,this.negative=1),g=0;g-=3)x=q[g]|q[g-1]<<8|q[g-2]<<16,this.words[N]|=x<<_&67108863,this.words[N+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);else if(k==="le")for(g=0,N=0;g>>26-_&67108863,_+=24,_>=26&&(_-=26,N++);return this.strip()};function X(q,j){var k=q.charCodeAt(j);return k>=65&&k<=70?k-55:k>=97&&k<=102?k-87:k-48&15}function K(q,j,k){var g=X(q,k);return k-1>=j&&(g|=X(q,k-1)<<4),g}V.prototype._parseHex=function(q,j,k){this.length=Math.ceil((q.length-j)/6),this.words=new Array(this.length);for(var g=0;g=j;g-=2)_=K(q,j,g)<=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8;else{var B=q.length-j;for(g=B%2===0?j+1:j;g=18?(N-=18,x+=1,this.words[x]|=_>>>26):N+=8}this.strip()};function I(q,j,k,g){for(var N=0,x=Math.min(q.length,k),_=j;_=49?N+=B-49+10:B>=17?N+=B-17+10:N+=B}return N}V.prototype._parseBase=function(q,j,k){this.words=[0],this.length=1;for(var g=0,N=1;N<=67108863;N*=j)g++;g--,N=N/j|0;for(var x=q.length-k,_=x%g,B=Math.min(x,x-_)+k,y=0,w=k;w1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},V.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},V.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],O=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],F=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];V.prototype.toString=function(q,j){q=q||10,j=j|0||1;var k;if(q===16||q==="hex"){k="";for(var g=0,N=0,x=0;x>>24-g&16777215,N!==0||x!==this.length-1?k=J[6-B.length]+B+k:k=B+k,g+=2,g>=26&&(g-=26,x--)}for(N!==0&&(k=N.toString(16)+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}if(q===(q|0)&&q>=2&&q<=36){var y=O[q],w=F[q];k="";var f=this.clone();for(f.negative=0;!f.isZero();){var p=f.modn(w).toString(q);f=f.idivn(w),f.isZero()?k=p+k:k=J[y-p.length]+p+k}for(this.isZero()&&(k="0"+k);k.length%j!==0;)k="0"+k;return this.negative!==0&&(k="-"+k),k}Z(!1,"Base should be between 2 and 36")},V.prototype.toNumber=function(){var q=this.words[0];return this.length===2?q+=this.words[1]*67108864:this.length===3&&this.words[2]===1?q+=4503599627370496+this.words[1]*67108864:this.length>2&&Z(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-q:q},V.prototype.toJSON=function(){return this.toString(16)},V.prototype.toBuffer=function(q,j){return Z(typeof U<"u"),this.toArrayLike(U,q,j)},V.prototype.toArray=function(q,j){return this.toArrayLike(Array,q,j)},V.prototype.toArrayLike=function(q,j,k){var g=this.byteLength(),N=k||Math.max(1,g);Z(g<=N,"byte array longer than desired length"),Z(N>0,"Requested array length <= 0"),this.strip();var x=j==="le",_=new q(N),B,y,w=this.clone();if(x){for(y=0;!w.isZero();y++)B=w.andln(255),w.iushrn(8),_[y]=B;for(;y=4096&&(k+=13,j>>>=13),j>=64&&(k+=7,j>>>=7),j>=8&&(k+=4,j>>>=4),j>=2&&(k+=2,j>>>=2),k+j},V.prototype._zeroBits=function(q){if(q===0)return 26;var j=q,k=0;return(j&8191)===0&&(k+=13,j>>>=13),(j&127)===0&&(k+=7,j>>>=7),(j&15)===0&&(k+=4,j>>>=4),(j&3)===0&&(k+=2,j>>>=2),(j&1)===0&&k++,k},V.prototype.bitLength=function(){var q=this.words[this.length-1],j=this._countBits(q);return(this.length-1)*26+j};function A(q){for(var j=new Array(q.bitLength()),k=0;k>>N}return j}V.prototype.zeroBits=function(){if(this.isZero())return 0;for(var q=0,j=0;jq.length?this.clone().ior(q):q.clone().ior(this)},V.prototype.uor=function(q){return this.length>q.length?this.clone().iuor(q):q.clone().iuor(this)},V.prototype.iuand=function(q){var j;this.length>q.length?j=q:j=this;for(var k=0;kq.length?this.clone().iand(q):q.clone().iand(this)},V.prototype.uand=function(q){return this.length>q.length?this.clone().iuand(q):q.clone().iuand(this)},V.prototype.iuxor=function(q){var j,k;this.length>q.length?(j=this,k=q):(j=q,k=this);for(var g=0;gq.length?this.clone().ixor(q):q.clone().ixor(this)},V.prototype.uxor=function(q){return this.length>q.length?this.clone().iuxor(q):q.clone().iuxor(this)},V.prototype.inotn=function(q){Z(typeof q=="number"&&q>=0);var j=Math.ceil(q/26)|0,k=q%26;this._expand(j),k>0&&j--;for(var g=0;g0&&(this.words[g]=~this.words[g]&67108863>>26-k),this.strip()},V.prototype.notn=function(q){return this.clone().inotn(q)},V.prototype.setn=function(q,j){Z(typeof q=="number"&&q>=0);var k=q/26|0,g=q%26;return this._expand(k+1),j?this.words[k]=this.words[k]|1<q.length?(k=this,g=q):(k=q,g=this);for(var N=0,x=0;x>>26;for(;N!==0&&x>>26;if(this.length=k.length,N!==0)this.words[this.length]=N,this.length++;else if(k!==this)for(;xq.length?this.clone().iadd(q):q.clone().iadd(this)},V.prototype.isub=function(q){if(q.negative!==0){q.negative=0;var j=this.iadd(q);return q.negative=1,j._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(q),this.negative=1,this._normSign();var k=this.cmp(q);if(k===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,N;k>0?(g=this,N=q):(g=q,N=this);for(var x=0,_=0;_>26,this.words[_]=j&67108863;for(;x!==0&&_>26,this.words[_]=j&67108863;if(x===0&&_>>26,p=y&67108863,c=Math.min(w,j.length-1),h=Math.max(0,w-q.length+1);h<=c;h++){var d=w-h|0;N=q.words[d]|0,x=j.words[h]|0,_=N*x+p,f+=_/67108864|0,p=_&67108863}k.words[w]=p|0,y=f|0}return y!==0?k.words[w]=y|0:k.length--,k.strip()}var H=function(q,j,k){var g=q.words,N=j.words,x=k.words,_=0,B,y,w,f=g[0]|0,p=f&8191,c=f>>>13,h=g[1]|0,d=h&8191,b=h>>>13,l=g[2]|0,o=l&8191,u=l>>>13,n=g[3]|0,s=n&8191,t=n>>>13,m=g[4]|0,a=m&8191,r=m>>>13,e=g[5]|0,i=e&8191,$0=e>>>13,Q0=g[6]|0,Y0=Q0&8191,Z0=Q0>>>13,G0=g[7]|0,V0=G0&8191,U0=G0>>>13,X0=g[8]|0,K0=X0&8191,I0=X0>>>13,J0=g[9]|0,O0=J0&8191,F0=J0>>>13,A0=N[0]|0,W0=A0&8191,H0=A0>>>13,E0=N[1]|0,T0=E0&8191,D0=E0>>>13,C0=N[2]|0,L0=C0&8191,R0=C0>>>13,P0=N[3]|0,z0=P0&8191,M0=P0>>>13,S0=N[4]|0,v0=S0&8191,q0=S0>>>13,j0=N[5]|0,k0=j0&8191,g0=j0>>>13,N0=N[6]|0,x0=N0&8191,_0=N0>>>13,B0=N[7]|0,y0=B0&8191,w0=B0>>>13,f0=N[8]|0,p0=f0&8191,c0=f0>>>13,h0=N[9]|0,d0=h0&8191,b0=h0>>>13;k.negative=q.negative^j.negative,k.length=19,B=Math.imul(p,W0),y=Math.imul(p,H0),y=y+Math.imul(c,W0)|0,w=Math.imul(c,H0);var l0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(l0>>>26)|0,l0&=67108863,B=Math.imul(d,W0),y=Math.imul(d,H0),y=y+Math.imul(b,W0)|0,w=Math.imul(b,H0),B=B+Math.imul(p,T0)|0,y=y+Math.imul(p,D0)|0,y=y+Math.imul(c,T0)|0,w=w+Math.imul(c,D0)|0;var o0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(o0>>>26)|0,o0&=67108863,B=Math.imul(o,W0),y=Math.imul(o,H0),y=y+Math.imul(u,W0)|0,w=Math.imul(u,H0),B=B+Math.imul(d,T0)|0,y=y+Math.imul(d,D0)|0,y=y+Math.imul(b,T0)|0,w=w+Math.imul(b,D0)|0,B=B+Math.imul(p,L0)|0,y=y+Math.imul(p,R0)|0,y=y+Math.imul(c,L0)|0,w=w+Math.imul(c,R0)|0;var u0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(u0>>>26)|0,u0&=67108863,B=Math.imul(s,W0),y=Math.imul(s,H0),y=y+Math.imul(t,W0)|0,w=Math.imul(t,H0),B=B+Math.imul(o,T0)|0,y=y+Math.imul(o,D0)|0,y=y+Math.imul(u,T0)|0,w=w+Math.imul(u,D0)|0,B=B+Math.imul(d,L0)|0,y=y+Math.imul(d,R0)|0,y=y+Math.imul(b,L0)|0,w=w+Math.imul(b,R0)|0,B=B+Math.imul(p,z0)|0,y=y+Math.imul(p,M0)|0,y=y+Math.imul(c,z0)|0,w=w+Math.imul(c,M0)|0;var n0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(n0>>>26)|0,n0&=67108863,B=Math.imul(a,W0),y=Math.imul(a,H0),y=y+Math.imul(r,W0)|0,w=Math.imul(r,H0),B=B+Math.imul(s,T0)|0,y=y+Math.imul(s,D0)|0,y=y+Math.imul(t,T0)|0,w=w+Math.imul(t,D0)|0,B=B+Math.imul(o,L0)|0,y=y+Math.imul(o,R0)|0,y=y+Math.imul(u,L0)|0,w=w+Math.imul(u,R0)|0,B=B+Math.imul(d,z0)|0,y=y+Math.imul(d,M0)|0,y=y+Math.imul(b,z0)|0,w=w+Math.imul(b,M0)|0,B=B+Math.imul(p,v0)|0,y=y+Math.imul(p,q0)|0,y=y+Math.imul(c,v0)|0,w=w+Math.imul(c,q0)|0;var s0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(s0>>>26)|0,s0&=67108863,B=Math.imul(i,W0),y=Math.imul(i,H0),y=y+Math.imul($0,W0)|0,w=Math.imul($0,H0),B=B+Math.imul(a,T0)|0,y=y+Math.imul(a,D0)|0,y=y+Math.imul(r,T0)|0,w=w+Math.imul(r,D0)|0,B=B+Math.imul(s,L0)|0,y=y+Math.imul(s,R0)|0,y=y+Math.imul(t,L0)|0,w=w+Math.imul(t,R0)|0,B=B+Math.imul(o,z0)|0,y=y+Math.imul(o,M0)|0,y=y+Math.imul(u,z0)|0,w=w+Math.imul(u,M0)|0,B=B+Math.imul(d,v0)|0,y=y+Math.imul(d,q0)|0,y=y+Math.imul(b,v0)|0,w=w+Math.imul(b,q0)|0,B=B+Math.imul(p,k0)|0,y=y+Math.imul(p,g0)|0,y=y+Math.imul(c,k0)|0,w=w+Math.imul(c,g0)|0;var t0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(t0>>>26)|0,t0&=67108863,B=Math.imul(Y0,W0),y=Math.imul(Y0,H0),y=y+Math.imul(Z0,W0)|0,w=Math.imul(Z0,H0),B=B+Math.imul(i,T0)|0,y=y+Math.imul(i,D0)|0,y=y+Math.imul($0,T0)|0,w=w+Math.imul($0,D0)|0,B=B+Math.imul(a,L0)|0,y=y+Math.imul(a,R0)|0,y=y+Math.imul(r,L0)|0,w=w+Math.imul(r,R0)|0,B=B+Math.imul(s,z0)|0,y=y+Math.imul(s,M0)|0,y=y+Math.imul(t,z0)|0,w=w+Math.imul(t,M0)|0,B=B+Math.imul(o,v0)|0,y=y+Math.imul(o,q0)|0,y=y+Math.imul(u,v0)|0,w=w+Math.imul(u,q0)|0,B=B+Math.imul(d,k0)|0,y=y+Math.imul(d,g0)|0,y=y+Math.imul(b,k0)|0,w=w+Math.imul(b,g0)|0,B=B+Math.imul(p,x0)|0,y=y+Math.imul(p,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,_0)|0;var m0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(m0>>>26)|0,m0&=67108863,B=Math.imul(V0,W0),y=Math.imul(V0,H0),y=y+Math.imul(U0,W0)|0,w=Math.imul(U0,H0),B=B+Math.imul(Y0,T0)|0,y=y+Math.imul(Y0,D0)|0,y=y+Math.imul(Z0,T0)|0,w=w+Math.imul(Z0,D0)|0,B=B+Math.imul(i,L0)|0,y=y+Math.imul(i,R0)|0,y=y+Math.imul($0,L0)|0,w=w+Math.imul($0,R0)|0,B=B+Math.imul(a,z0)|0,y=y+Math.imul(a,M0)|0,y=y+Math.imul(r,z0)|0,w=w+Math.imul(r,M0)|0,B=B+Math.imul(s,v0)|0,y=y+Math.imul(s,q0)|0,y=y+Math.imul(t,v0)|0,w=w+Math.imul(t,q0)|0,B=B+Math.imul(o,k0)|0,y=y+Math.imul(o,g0)|0,y=y+Math.imul(u,k0)|0,w=w+Math.imul(u,g0)|0,B=B+Math.imul(d,x0)|0,y=y+Math.imul(d,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,_0)|0,B=B+Math.imul(p,y0)|0,y=y+Math.imul(p,w0)|0,y=y+Math.imul(c,y0)|0,w=w+Math.imul(c,w0)|0;var a0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(a0>>>26)|0,a0&=67108863,B=Math.imul(K0,W0),y=Math.imul(K0,H0),y=y+Math.imul(I0,W0)|0,w=Math.imul(I0,H0),B=B+Math.imul(V0,T0)|0,y=y+Math.imul(V0,D0)|0,y=y+Math.imul(U0,T0)|0,w=w+Math.imul(U0,D0)|0,B=B+Math.imul(Y0,L0)|0,y=y+Math.imul(Y0,R0)|0,y=y+Math.imul(Z0,L0)|0,w=w+Math.imul(Z0,R0)|0,B=B+Math.imul(i,z0)|0,y=y+Math.imul(i,M0)|0,y=y+Math.imul($0,z0)|0,w=w+Math.imul($0,M0)|0,B=B+Math.imul(a,v0)|0,y=y+Math.imul(a,q0)|0,y=y+Math.imul(r,v0)|0,w=w+Math.imul(r,q0)|0,B=B+Math.imul(s,k0)|0,y=y+Math.imul(s,g0)|0,y=y+Math.imul(t,k0)|0,w=w+Math.imul(t,g0)|0,B=B+Math.imul(o,x0)|0,y=y+Math.imul(o,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,_0)|0,B=B+Math.imul(d,y0)|0,y=y+Math.imul(d,w0)|0,y=y+Math.imul(b,y0)|0,w=w+Math.imul(b,w0)|0,B=B+Math.imul(p,p0)|0,y=y+Math.imul(p,c0)|0,y=y+Math.imul(c,p0)|0,w=w+Math.imul(c,c0)|0;var r0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(r0>>>26)|0,r0&=67108863,B=Math.imul(O0,W0),y=Math.imul(O0,H0),y=y+Math.imul(F0,W0)|0,w=Math.imul(F0,H0),B=B+Math.imul(K0,T0)|0,y=y+Math.imul(K0,D0)|0,y=y+Math.imul(I0,T0)|0,w=w+Math.imul(I0,D0)|0,B=B+Math.imul(V0,L0)|0,y=y+Math.imul(V0,R0)|0,y=y+Math.imul(U0,L0)|0,w=w+Math.imul(U0,R0)|0,B=B+Math.imul(Y0,z0)|0,y=y+Math.imul(Y0,M0)|0,y=y+Math.imul(Z0,z0)|0,w=w+Math.imul(Z0,M0)|0,B=B+Math.imul(i,v0)|0,y=y+Math.imul(i,q0)|0,y=y+Math.imul($0,v0)|0,w=w+Math.imul($0,q0)|0,B=B+Math.imul(a,k0)|0,y=y+Math.imul(a,g0)|0,y=y+Math.imul(r,k0)|0,w=w+Math.imul(r,g0)|0,B=B+Math.imul(s,x0)|0,y=y+Math.imul(s,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,_0)|0,B=B+Math.imul(o,y0)|0,y=y+Math.imul(o,w0)|0,y=y+Math.imul(u,y0)|0,w=w+Math.imul(u,w0)|0,B=B+Math.imul(d,p0)|0,y=y+Math.imul(d,c0)|0,y=y+Math.imul(b,p0)|0,w=w+Math.imul(b,c0)|0,B=B+Math.imul(p,d0)|0,y=y+Math.imul(p,b0)|0,y=y+Math.imul(c,d0)|0,w=w+Math.imul(c,b0)|0;var e0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(e0>>>26)|0,e0&=67108863,B=Math.imul(O0,T0),y=Math.imul(O0,D0),y=y+Math.imul(F0,T0)|0,w=Math.imul(F0,D0),B=B+Math.imul(K0,L0)|0,y=y+Math.imul(K0,R0)|0,y=y+Math.imul(I0,L0)|0,w=w+Math.imul(I0,R0)|0,B=B+Math.imul(V0,z0)|0,y=y+Math.imul(V0,M0)|0,y=y+Math.imul(U0,z0)|0,w=w+Math.imul(U0,M0)|0,B=B+Math.imul(Y0,v0)|0,y=y+Math.imul(Y0,q0)|0,y=y+Math.imul(Z0,v0)|0,w=w+Math.imul(Z0,q0)|0,B=B+Math.imul(i,k0)|0,y=y+Math.imul(i,g0)|0,y=y+Math.imul($0,k0)|0,w=w+Math.imul($0,g0)|0,B=B+Math.imul(a,x0)|0,y=y+Math.imul(a,_0)|0,y=y+Math.imul(r,x0)|0,w=w+Math.imul(r,_0)|0,B=B+Math.imul(s,y0)|0,y=y+Math.imul(s,w0)|0,y=y+Math.imul(t,y0)|0,w=w+Math.imul(t,w0)|0,B=B+Math.imul(o,p0)|0,y=y+Math.imul(o,c0)|0,y=y+Math.imul(u,p0)|0,w=w+Math.imul(u,c0)|0,B=B+Math.imul(d,d0)|0,y=y+Math.imul(d,b0)|0,y=y+Math.imul(b,d0)|0,w=w+Math.imul(b,b0)|0;var i0=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(i0>>>26)|0,i0&=67108863,B=Math.imul(O0,L0),y=Math.imul(O0,R0),y=y+Math.imul(F0,L0)|0,w=Math.imul(F0,R0),B=B+Math.imul(K0,z0)|0,y=y+Math.imul(K0,M0)|0,y=y+Math.imul(I0,z0)|0,w=w+Math.imul(I0,M0)|0,B=B+Math.imul(V0,v0)|0,y=y+Math.imul(V0,q0)|0,y=y+Math.imul(U0,v0)|0,w=w+Math.imul(U0,q0)|0,B=B+Math.imul(Y0,k0)|0,y=y+Math.imul(Y0,g0)|0,y=y+Math.imul(Z0,k0)|0,w=w+Math.imul(Z0,g0)|0,B=B+Math.imul(i,x0)|0,y=y+Math.imul(i,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,_0)|0,B=B+Math.imul(a,y0)|0,y=y+Math.imul(a,w0)|0,y=y+Math.imul(r,y0)|0,w=w+Math.imul(r,w0)|0,B=B+Math.imul(s,p0)|0,y=y+Math.imul(s,c0)|0,y=y+Math.imul(t,p0)|0,w=w+Math.imul(t,c0)|0,B=B+Math.imul(o,d0)|0,y=y+Math.imul(o,b0)|0,y=y+Math.imul(u,d0)|0,w=w+Math.imul(u,b0)|0;var $$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+($$>>>26)|0,$$&=67108863,B=Math.imul(O0,z0),y=Math.imul(O0,M0),y=y+Math.imul(F0,z0)|0,w=Math.imul(F0,M0),B=B+Math.imul(K0,v0)|0,y=y+Math.imul(K0,q0)|0,y=y+Math.imul(I0,v0)|0,w=w+Math.imul(I0,q0)|0,B=B+Math.imul(V0,k0)|0,y=y+Math.imul(V0,g0)|0,y=y+Math.imul(U0,k0)|0,w=w+Math.imul(U0,g0)|0,B=B+Math.imul(Y0,x0)|0,y=y+Math.imul(Y0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,_0)|0,B=B+Math.imul(i,y0)|0,y=y+Math.imul(i,w0)|0,y=y+Math.imul($0,y0)|0,w=w+Math.imul($0,w0)|0,B=B+Math.imul(a,p0)|0,y=y+Math.imul(a,c0)|0,y=y+Math.imul(r,p0)|0,w=w+Math.imul(r,c0)|0,B=B+Math.imul(s,d0)|0,y=y+Math.imul(s,b0)|0,y=y+Math.imul(t,d0)|0,w=w+Math.imul(t,b0)|0;var Q$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,B=Math.imul(O0,v0),y=Math.imul(O0,q0),y=y+Math.imul(F0,v0)|0,w=Math.imul(F0,q0),B=B+Math.imul(K0,k0)|0,y=y+Math.imul(K0,g0)|0,y=y+Math.imul(I0,k0)|0,w=w+Math.imul(I0,g0)|0,B=B+Math.imul(V0,x0)|0,y=y+Math.imul(V0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,_0)|0,B=B+Math.imul(Y0,y0)|0,y=y+Math.imul(Y0,w0)|0,y=y+Math.imul(Z0,y0)|0,w=w+Math.imul(Z0,w0)|0,B=B+Math.imul(i,p0)|0,y=y+Math.imul(i,c0)|0,y=y+Math.imul($0,p0)|0,w=w+Math.imul($0,c0)|0,B=B+Math.imul(a,d0)|0,y=y+Math.imul(a,b0)|0,y=y+Math.imul(r,d0)|0,w=w+Math.imul(r,b0)|0;var Y$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,B=Math.imul(O0,k0),y=Math.imul(O0,g0),y=y+Math.imul(F0,k0)|0,w=Math.imul(F0,g0),B=B+Math.imul(K0,x0)|0,y=y+Math.imul(K0,_0)|0,y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,_0)|0,B=B+Math.imul(V0,y0)|0,y=y+Math.imul(V0,w0)|0,y=y+Math.imul(U0,y0)|0,w=w+Math.imul(U0,w0)|0,B=B+Math.imul(Y0,p0)|0,y=y+Math.imul(Y0,c0)|0,y=y+Math.imul(Z0,p0)|0,w=w+Math.imul(Z0,c0)|0,B=B+Math.imul(i,d0)|0,y=y+Math.imul(i,b0)|0,y=y+Math.imul($0,d0)|0,w=w+Math.imul($0,b0)|0;var Z$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,B=Math.imul(O0,x0),y=Math.imul(O0,_0),y=y+Math.imul(F0,x0)|0,w=Math.imul(F0,_0),B=B+Math.imul(K0,y0)|0,y=y+Math.imul(K0,w0)|0,y=y+Math.imul(I0,y0)|0,w=w+Math.imul(I0,w0)|0,B=B+Math.imul(V0,p0)|0,y=y+Math.imul(V0,c0)|0,y=y+Math.imul(U0,p0)|0,w=w+Math.imul(U0,c0)|0,B=B+Math.imul(Y0,d0)|0,y=y+Math.imul(Y0,b0)|0,y=y+Math.imul(Z0,d0)|0,w=w+Math.imul(Z0,b0)|0;var G$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(G$>>>26)|0,G$&=67108863,B=Math.imul(O0,y0),y=Math.imul(O0,w0),y=y+Math.imul(F0,y0)|0,w=Math.imul(F0,w0),B=B+Math.imul(K0,p0)|0,y=y+Math.imul(K0,c0)|0,y=y+Math.imul(I0,p0)|0,w=w+Math.imul(I0,c0)|0,B=B+Math.imul(V0,d0)|0,y=y+Math.imul(V0,b0)|0,y=y+Math.imul(U0,d0)|0,w=w+Math.imul(U0,b0)|0;var V$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(V$>>>26)|0,V$&=67108863,B=Math.imul(O0,p0),y=Math.imul(O0,c0),y=y+Math.imul(F0,p0)|0,w=Math.imul(F0,c0),B=B+Math.imul(K0,d0)|0,y=y+Math.imul(K0,b0)|0,y=y+Math.imul(I0,d0)|0,w=w+Math.imul(I0,b0)|0;var U$=(_+B|0)+((y&8191)<<13)|0;_=(w+(y>>>13)|0)+(U$>>>26)|0,U$&=67108863,B=Math.imul(O0,d0),y=Math.imul(O0,b0),y=y+Math.imul(F0,d0)|0,w=Math.imul(F0,b0);var X$=(_+B|0)+((y&8191)<<13)|0;return _=(w+(y>>>13)|0)+(X$>>>26)|0,X$&=67108863,x[0]=l0,x[1]=o0,x[2]=u0,x[3]=n0,x[4]=s0,x[5]=t0,x[6]=m0,x[7]=a0,x[8]=r0,x[9]=e0,x[10]=i0,x[11]=$$,x[12]=Q$,x[13]=Y$,x[14]=Z$,x[15]=G$,x[16]=V$,x[17]=U$,x[18]=X$,_!==0&&(x[19]=_,k.length++),k};Math.imul||(H=W);function E(q,j,k){k.negative=j.negative^q.negative,k.length=q.length+j.length;for(var g=0,N=0,x=0;x>>26)|0,N+=_>>>26,_&=67108863}k.words[x]=B,g=_,_=N}return g!==0?k.words[x]=g:k.length--,k.strip()}function T(q,j,k){var g=new D;return g.mulp(q,j,k)}V.prototype.mulTo=function(q,j){var k,g=this.length+q.length;return this.length===10&&q.length===10?k=H(this,q,j):g<63?k=W(this,q,j):g<1024?k=E(this,q,j):k=T(this,q,j),k};function D(q,j){this.x=q,this.y=j}D.prototype.makeRBT=function(q){for(var j=new Array(q),k=V.prototype._countBits(q)-1,g=0;g>=1;return g},D.prototype.permute=function(q,j,k,g,N,x){for(var _=0;_>>1)N++;return 1<>>13,k[2*x+1]=N&8191,N=N>>>13;for(x=2*j;x>=26,j+=g/67108864|0,j+=N>>>26,this.words[k]=N&67108863}return j!==0&&(this.words[k]=j,this.length++),this},V.prototype.muln=function(q){return this.clone().imuln(q)},V.prototype.sqr=function(){return this.mul(this)},V.prototype.isqr=function(){return this.imul(this.clone())},V.prototype.pow=function(q){var j=A(q);if(j.length===0)return new V(1);for(var k=this,g=0;g=0);var j=q%26,k=(q-j)/26,g=67108863>>>26-j<<26-j,N;if(j!==0){var x=0;for(N=0;N>>26-j}x&&(this.words[N]=x,this.length++)}if(k!==0){for(N=this.length-1;N>=0;N--)this.words[N+k]=this.words[N];for(N=0;N=0);var g;j?g=(j-j%26)/26:g=0;var N=q%26,x=Math.min((q-N)/26,this.length),_=67108863^67108863>>>N<x)for(this.length-=x,y=0;y=0&&(w!==0||y>=g);y--){var f=this.words[y]|0;this.words[y]=w<<26-N|f>>>N,w=f&_}return B&&w!==0&&(B.words[B.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},V.prototype.ishrn=function(q,j,k){return Z(this.negative===0),this.iushrn(q,j,k)},V.prototype.shln=function(q){return this.clone().ishln(q)},V.prototype.ushln=function(q){return this.clone().iushln(q)},V.prototype.shrn=function(q){return this.clone().ishrn(q)},V.prototype.ushrn=function(q){return this.clone().iushrn(q)},V.prototype.testn=function(q){Z(typeof q=="number"&&q>=0);var j=q%26,k=(q-j)/26,g=1<=0);var j=q%26,k=(q-j)/26;if(Z(this.negative===0,"imaskn works only with positive numbers"),this.length<=k)return this;if(j!==0&&k++,this.length=Math.min(k,this.length),j!==0){var g=67108863^67108863>>>j<=67108864;j++)this.words[j]-=67108864,j===this.length-1?this.words[j+1]=1:this.words[j+1]++;return this.length=Math.max(this.length,j+1),this},V.prototype.isubn=function(q){if(Z(typeof q=="number"),Z(q<67108864),q<0)return this.iaddn(-q);if(this.negative!==0)return this.negative=0,this.iaddn(q),this.negative=1,this;if(this.words[0]-=q,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var j=0;j>26)-(B/67108864|0),this.words[N+k]=x&67108863}for(;N>26,this.words[N+k]=x&67108863;if(_===0)return this.strip();for(Z(_===-1),_=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},V.prototype._wordDiv=function(q,j){var k=this.length-q.length,g=this.clone(),N=q,x=N.words[N.length-1]|0,_=this._countBits(x);k=26-_,k!==0&&(N=N.ushln(k),g.iushln(k),x=N.words[N.length-1]|0);var B=g.length-N.length,y;if(j!=="mod"){y=new V(null),y.length=B+1,y.words=new Array(y.length);for(var w=0;w=0;p--){var c=(g.words[N.length+p]|0)*67108864+(g.words[N.length+p-1]|0);for(c=Math.min(c/x|0,67108863),g._ishlnsubmul(N,c,p);g.negative!==0;)c--,g.negative=0,g._ishlnsubmul(N,1,p),g.isZero()||(g.negative^=1);y&&(y.words[p]=c)}return y&&y.strip(),g.strip(),j!=="div"&&k!==0&&g.iushrn(k),{div:y||null,mod:g}},V.prototype.divmod=function(q,j,k){if(Z(!q.isZero()),this.isZero())return{div:new V(0),mod:new V(0)};var g,N,x;return this.negative!==0&&q.negative===0?(x=this.neg().divmod(q,j),j!=="mod"&&(g=x.div.neg()),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.iadd(q)),{div:g,mod:N}):this.negative===0&&q.negative!==0?(x=this.divmod(q.neg(),j),j!=="mod"&&(g=x.div.neg()),{div:g,mod:x.mod}):(this.negative&q.negative)!==0?(x=this.neg().divmod(q.neg(),j),j!=="div"&&(N=x.mod.neg(),k&&N.negative!==0&&N.isub(q)),{div:x.div,mod:N}):q.length>this.length||this.cmp(q)<0?{div:new V(0),mod:this}:q.length===1?j==="div"?{div:this.divn(q.words[0]),mod:null}:j==="mod"?{div:null,mod:new V(this.modn(q.words[0]))}:{div:this.divn(q.words[0]),mod:new V(this.modn(q.words[0]))}:this._wordDiv(q,j)},V.prototype.div=function(q){return this.divmod(q,"div",!1).div},V.prototype.mod=function(q){return this.divmod(q,"mod",!1).mod},V.prototype.umod=function(q){return this.divmod(q,"mod",!0).mod},V.prototype.divRound=function(q){var j=this.divmod(q);if(j.mod.isZero())return j.div;var k=j.div.negative!==0?j.mod.isub(q):j.mod,g=q.ushrn(1),N=q.andln(1),x=k.cmp(g);return x<0||N===1&&x===0?j.div:j.div.negative!==0?j.div.isubn(1):j.div.iaddn(1)},V.prototype.modn=function(q){Z(q<=67108863);for(var j=(1<<26)%q,k=0,g=this.length-1;g>=0;g--)k=(j*k+(this.words[g]|0))%q;return k},V.prototype.idivn=function(q){Z(q<=67108863);for(var j=0,k=this.length-1;k>=0;k--){var g=(this.words[k]|0)+j*67108864;this.words[k]=g/q|0,j=g%q}return this.strip()},V.prototype.divn=function(q){return this.clone().idivn(q)},V.prototype.egcd=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=new V(0),_=new V(1),B=0;j.isEven()&&k.isEven();)j.iushrn(1),k.iushrn(1),++B;for(var y=k.clone(),w=j.clone();!j.isZero();){for(var f=0,p=1;(j.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(j.iushrn(f);f-- >0;)(g.isOdd()||N.isOdd())&&(g.iadd(y),N.isub(w)),g.iushrn(1),N.iushrn(1);for(var c=0,h=1;(k.words[0]&h)===0&&c<26;++c,h<<=1);if(c>0)for(k.iushrn(c);c-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(y),_.isub(w)),x.iushrn(1),_.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(x),N.isub(_)):(k.isub(j),x.isub(g),_.isub(N))}return{a:x,b:_,gcd:k.iushln(B)}},V.prototype._invmp=function(q){Z(q.negative===0),Z(!q.isZero());var j=this,k=q.clone();j.negative!==0?j=j.umod(q):j=j.clone();for(var g=new V(1),N=new V(0),x=k.clone();j.cmpn(1)>0&&k.cmpn(1)>0;){for(var _=0,B=1;(j.words[0]&B)===0&&_<26;++_,B<<=1);if(_>0)for(j.iushrn(_);_-- >0;)g.isOdd()&&g.iadd(x),g.iushrn(1);for(var y=0,w=1;(k.words[0]&w)===0&&y<26;++y,w<<=1);if(y>0)for(k.iushrn(y);y-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);j.cmp(k)>=0?(j.isub(k),g.isub(N)):(k.isub(j),N.isub(g))}var f;return j.cmpn(1)===0?f=g:f=N,f.cmpn(0)<0&&f.iadd(q),f},V.prototype.gcd=function(q){if(this.isZero())return q.abs();if(q.isZero())return this.abs();var j=this.clone(),k=q.clone();j.negative=0,k.negative=0;for(var g=0;j.isEven()&&k.isEven();g++)j.iushrn(1),k.iushrn(1);do{for(;j.isEven();)j.iushrn(1);for(;k.isEven();)k.iushrn(1);var N=j.cmp(k);if(N<0){var x=j;j=k,k=x}else if(N===0||k.cmpn(1)===0)break;j.isub(k)}while(!0);return k.iushln(g)},V.prototype.invm=function(q){return this.egcd(q).a.umod(q)},V.prototype.isEven=function(){return(this.words[0]&1)===0},V.prototype.isOdd=function(){return(this.words[0]&1)===1},V.prototype.andln=function(q){return this.words[0]&q},V.prototype.bincn=function(q){Z(typeof q=="number");var j=q%26,k=(q-j)/26,g=1<>>26,_&=67108863,this.words[x]=_}return N!==0&&(this.words[x]=N,this.length++),this},V.prototype.isZero=function(){return this.length===1&&this.words[0]===0},V.prototype.cmpn=function(q){var j=q<0;if(this.negative!==0&&!j)return-1;if(this.negative===0&&j)return 1;this.strip();var k;if(this.length>1)k=1;else{j&&(q=-q),Z(q<=67108863,"Number is too big");var g=this.words[0]|0;k=g===q?0:gq.length)return 1;if(this.length=0;k--){var g=this.words[k]|0,N=q.words[k]|0;if(g!==N){gN&&(j=1);break}}return j},V.prototype.gtn=function(q){return this.cmpn(q)===1},V.prototype.gt=function(q){return this.cmp(q)===1},V.prototype.gten=function(q){return this.cmpn(q)>=0},V.prototype.gte=function(q){return this.cmp(q)>=0},V.prototype.ltn=function(q){return this.cmpn(q)===-1},V.prototype.lt=function(q){return this.cmp(q)===-1},V.prototype.lten=function(q){return this.cmpn(q)<=0},V.prototype.lte=function(q){return this.cmp(q)<=0},V.prototype.eqn=function(q){return this.cmpn(q)===0},V.prototype.eq=function(q){return this.cmp(q)===0},V.red=function(q){return new S(q)},V.prototype.toRed=function(q){return Z(!this.red,"Already a number in reduction context"),Z(this.negative===0,"red works only with positives"),q.convertTo(this)._forceRed(q)},V.prototype.fromRed=function(){return Z(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},V.prototype._forceRed=function(q){return this.red=q,this},V.prototype.forceRed=function(q){return Z(!this.red,"Already a number in reduction context"),this._forceRed(q)},V.prototype.redAdd=function(q){return Z(this.red,"redAdd works only with red numbers"),this.red.add(this,q)},V.prototype.redIAdd=function(q){return Z(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,q)},V.prototype.redSub=function(q){return Z(this.red,"redSub works only with red numbers"),this.red.sub(this,q)},V.prototype.redISub=function(q){return Z(this.red,"redISub works only with red numbers"),this.red.isub(this,q)},V.prototype.redShl=function(q){return Z(this.red,"redShl works only with red numbers"),this.red.shl(this,q)},V.prototype.redMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.mul(this,q)},V.prototype.redIMul=function(q){return Z(this.red,"redMul works only with red numbers"),this.red._verify2(this,q),this.red.imul(this,q)},V.prototype.redSqr=function(){return Z(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},V.prototype.redISqr=function(){return Z(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},V.prototype.redSqrt=function(){return Z(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},V.prototype.redInvm=function(){return Z(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},V.prototype.redNeg=function(){return Z(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},V.prototype.redPow=function(q){return Z(this.red&&!q.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,q)};var C={k256:null,p224:null,p192:null,p25519:null};function L(q,j){this.name=q,this.p=new V(j,16),this.n=this.p.bitLength(),this.k=new V(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}L.prototype._tmp=function(){var q=new V(null);return q.words=new Array(Math.ceil(this.n/13)),q},L.prototype.ireduce=function(q){var j=q,k;do this.split(j,this.tmp),j=this.imulK(j),j=j.iadd(this.tmp),k=j.bitLength();while(k>this.n);var g=k0?j.isub(this.p):j.strip!==void 0?j.strip():j._strip(),j},L.prototype.split=function(q,j){q.iushrn(this.n,0,j)},L.prototype.imulK=function(q){return q.imul(this.k)};function R(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}G(R,L),R.prototype.split=function(q,j){for(var k=4194303,g=Math.min(q.length,9),N=0;N>>22,x=_}x>>>=22,q.words[N-10]=x,x===0&&q.length>10?q.length-=10:q.length-=9},R.prototype.imulK=function(q){q.words[q.length]=0,q.words[q.length+1]=0,q.length+=2;for(var j=0,k=0;k>>=26,q.words[k]=N,j=g}return j!==0&&(q.words[q.length++]=j),q},V._prime=function(q){if(C[q])return C[q];var j;if(q==="k256")j=new R;else if(q==="p224")j=new P;else if(q==="p192")j=new z;else if(q==="p25519")j=new M;else throw new Error("Unknown prime "+q);return C[q]=j,j};function S(q){if(typeof q=="string"){var j=V._prime(q);this.m=j.p,this.prime=j}else Z(q.gtn(1),"modulus must be greater than 1"),this.m=q,this.prime=null}S.prototype._verify1=function(q){Z(q.negative===0,"red works only with positives"),Z(q.red,"red works only with red numbers")},S.prototype._verify2=function(q,j){Z((q.negative|j.negative)===0,"red works only with positives"),Z(q.red&&q.red===j.red,"red works only with red numbers")},S.prototype.imod=function(q){return this.prime?this.prime.ireduce(q)._forceRed(this):q.umod(this.m)._forceRed(this)},S.prototype.neg=function(q){return q.isZero()?q.clone():this.m.sub(q)._forceRed(this)},S.prototype.add=function(q,j){this._verify2(q,j);var k=q.add(j);return k.cmp(this.m)>=0&&k.isub(this.m),k._forceRed(this)},S.prototype.iadd=function(q,j){this._verify2(q,j);var k=q.iadd(j);return k.cmp(this.m)>=0&&k.isub(this.m),k},S.prototype.sub=function(q,j){this._verify2(q,j);var k=q.sub(j);return k.cmpn(0)<0&&k.iadd(this.m),k._forceRed(this)},S.prototype.isub=function(q,j){this._verify2(q,j);var k=q.isub(j);return k.cmpn(0)<0&&k.iadd(this.m),k},S.prototype.shl=function(q,j){return this._verify1(q),this.imod(q.ushln(j))},S.prototype.imul=function(q,j){return this._verify2(q,j),this.imod(q.imul(j))},S.prototype.mul=function(q,j){return this._verify2(q,j),this.imod(q.mul(j))},S.prototype.isqr=function(q){return this.imul(q,q.clone())},S.prototype.sqr=function(q){return this.mul(q,q)},S.prototype.sqrt=function(q){if(q.isZero())return q.clone();var j=this.m.andln(3);if(Z(j%2===1),j===3){var k=this.m.add(new V(1)).iushrn(2);return this.pow(q,k)}for(var g=this.m.subn(1),N=0;!g.isZero()&&g.andln(1)===0;)N++,g.iushrn(1);Z(!g.isZero());var x=new V(1).toRed(this),_=x.redNeg(),B=this.m.subn(1).iushrn(1),y=this.m.bitLength();for(y=new V(2*y*y).toRed(this);this.pow(y,B).cmp(_)!==0;)y.redIAdd(_);for(var w=this.pow(y,g),f=this.pow(q,g.addn(1).iushrn(1)),p=this.pow(q,g),c=N;p.cmp(x)!==0;){for(var h=p,d=0;h.cmp(x)!==0;d++)h=h.redSqr();Z(d=0;N--){for(var w=j.words[N],f=y-1;f>=0;f--){var p=w>>f&1;if(x!==g[0]&&(x=this.sqr(x)),p===0&&_===0){B=0;continue}_<<=1,_|=p,B++,!(B!==k&&(N!==0||f!==0))&&(x=this.mul(x,g[_]),B=0,_=0)}y=26}return x},S.prototype.convertTo=function(q){var j=q.umod(this.m);return j===q?j.clone():j},S.prototype.convertFrom=function(q){var j=q.clone();return j.red=null,j},V.mont=function(q){return new v(q)};function v(q){S.call(this,q),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new V(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}G(v,S),v.prototype.convertTo=function(q){return this.imod(q.ushln(this.shift))},v.prototype.convertFrom=function(q){var j=this.imod(q.mul(this.rinv));return j.red=null,j},v.prototype.imul=function(q,j){if(q.isZero()||j.isZero())return q.words[0]=0,q.length=1,q;var k=q.imul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.mul=function(q,j){if(q.isZero()||j.isZero())return new V(0)._forceRed(this);var k=q.mul(j),g=k.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=k.isub(g).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},v.prototype.invm=function(q){var j=this.imod(q._invmp(this.m).mul(this.r2));return j._forceRed(this)}})(typeof $>"u"||$,bZ)}}),{CryptoHasher:lY}=globalThis.Bun,oY=P$({"node_modules/public-encrypt/withPublic.js"(bZ,$){var Q=bY(),Y=M$().Buffer;function Z(G,V){return Y.from(G.toRed(Q.mont(V.modulus)).redPow(new Q(V.publicExponent)).fromRed().toArray())}$.exports=Z}}),uY=P$({"node_modules/public-encrypt/publicEncrypt.js"(bZ,$){var Q=_Y(),Y=S$(),Z=h$(),G=hY(),V=dY(),U=bY(),X=oY(),K=wQ(),I=M$().Buffer;$.exports=function(A,W,H){var E;A.padding?E=A.padding:H?E=1:E=4;var T=Q(A),D;if(E===4)D=J(T,W);else if(E===1)D=O(T,W,H);else if(E===3){if(D=new U(W),D.cmp(T.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return H?K(D,T):X(D,T)};function J(A,W){var H=A.modulus.byteLength(),E=W.length,T=Z("sha1").update(I.alloc(0)).digest(),D=T.length,C=2*D;if(E>H-C-2)throw new Error("message too long");var L=I.alloc(H-E-C-2),R=H-D-1,P=Y(D),z=V(I.concat([T,L,I.alloc(1,1),W],R),G(P,R)),M=V(P,G(z,D));return new U(I.concat([I.alloc(1),M,z],H))}function O(A,W,H){var E=W.length,T=A.modulus.byteLength();if(E>T-11)throw new Error("message too long");var D;return H?D=I.alloc(T-E-3,255):D=F(T-E-3),new U(I.concat([I.from([0,H?1:2]),D,I.alloc(1),W],T))}function F(A){for(var W=I.allocUnsafe(A),H=0,E=Y(A*2),T=0,D;HT||new G(A).cmp(E.modulus)>=0)throw new Error("decryption error");var D;W?D=X(new G(A),E):D=V(A,E);var C=K.alloc(T-D.length);if(D=K.concat([C,D],T),H===4)return I(E,D);if(H===1)return J(E,D,W);if(H===3)return D;throw new Error("unknown padding")};function I(F,A){var W=F.modulus.byteLength(),H=U("sha1").update(K.alloc(0)).digest(),E=H.length;if(A[0]!==0)throw new Error("decryption error");var T=A.slice(1,E+1),D=A.slice(E+1),C=Z(T,Y(D,E)),L=Z(D,Y(C,W-E-1));if(O(H,L.slice(0,E)))throw new Error("decryption error");for(var R=E;L[R]===0;)R++;if(L[R++]!==1)throw new Error("decryption error");return L.slice(R)}function J(F,A,W){for(var H=A.slice(0,2),E=2,T=0;A[E++]!==0;)if(E>=A.length){T++;break}var D=A.slice(2,E-1);if((H.toString("hex")!=="0002"&&!W||H.toString("hex")!=="0001"&&W)&&T++,D.length<8&&T++,T)throw new Error("decryption error");return A.slice(E)}function O(F,A){F=K.from(F),A=K.from(A);var W=0,H=F.length;F.length!==A.length&&(W++,H=Math.min(F.length,A.length));for(var E=-1;++EG||J<0)throw new TypeError("offset must be a uint32");if(J>Z||J>O)throw new RangeError("offset out of range")}function U(J,O,F){if(typeof J!="number"||J!==J)throw new TypeError("size must be a number");if(J>G||J<0)throw new TypeError("size must be a uint32");if(J+O>F||J>Z)throw new RangeError("buffer too small")}bZ.randomFill=X,bZ.randomFillSync=I;function X(J,O,F,A){if(!Y.isBuffer(J)&&!(J instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof O=="function")A=O,O=0,F=J.length;else if(typeof F=="function")A=F,F=J.length-O;else if(typeof A!="function")throw new TypeError('"cb" argument must be a function');return V(O,J.length),U(F,O,J.length),K(J,O,F,A)}function K(J,O,F,A){if(A){Q(F,function(H,E){if(H)return A(H);E.copy(J,O),A(null,J)});return}var W=Q(F);return W.copy(J,O),J}function I(J,O,F){if(typeof O>"u"&&(O=0),!Y.isBuffer(J)&&!(J instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return V(O,J.length),F===void 0&&(F=J.length-O),U(F,O,J.length),K(J,O,F)}}}),mY=P$({"node_modules/crypto-browserify/index.js"(bZ){bZ.randomBytes=bZ.rng=bZ.pseudoRandomBytes=bZ.prng=S$(),bZ.createHash=h$(),bZ.Hash=bZ.createHash.Hash,bZ.createHmac=bZ.Hmac=l$();var $=u$(),Q=Object.keys($),Y=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Q);bZ.getHashes=function(){return Y};var Z=r$();bZ.pbkdf2=Z.pbkdf2,bZ.pbkdf2Sync=Z.pbkdf2Sync;var G=SQ();bZ.Cipher=G.Cipher,bZ.createCipher=G.createCipher,bZ.Cipheriv=G.Cipheriv,bZ.createCipheriv=G.createCipheriv,bZ.Decipher=G.Decipher,bZ.createDecipher=G.createDecipher,bZ.Decipheriv=G.Decipheriv,bZ.createDecipheriv=G.createDecipheriv,bZ.getCiphers=G.getCiphers,bZ.listCiphers=G.listCiphers;var V=BQ();bZ.DiffieHellmanGroup=V.DiffieHellmanGroup,bZ.createDiffieHellmanGroup=V.createDiffieHellmanGroup,bZ.getDiffieHellman=V.getDiffieHellman,bZ.createDiffieHellman=V.createDiffieHellman,bZ.DiffieHellman=V.DiffieHellman;var U=fY();bZ.createSign=U.createSign,bZ.Sign=U.Sign,bZ.createVerify=U.createVerify,bZ.Verify=U.Verify,bZ.createECDH=cY();var X=sY();bZ.publicEncrypt=X.publicEncrypt,bZ.privateEncrypt=X.privateEncrypt,bZ.publicDecrypt=X.publicDecrypt,bZ.privateDecrypt=X.privateDecrypt,bZ.getRandomValues=(I)=>O$.getRandomValues(I);var K=tY();bZ.randomFill=K.randomFill,bZ.randomFillSync=K.randomFillSync,bZ.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(` -`))},bZ.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}}}),aY={...mY(),[Symbol.for("CommonJS")]:0},W$="buffer",rY=(bZ)=>O$.getRandomValues(bZ),eY=()=>O$.randomUUID(),H$="timingSafeEqual"in O$?(bZ,$)=>{let{byteLength:Q}=bZ,{byteLength:Y}=$;if(typeof Q!="number"||typeof Y!="number")throw new TypeError("Input must be an array buffer view");if(Q!==Y)throw new RangeError("Input buffers must have the same length");return O$.timingSafeEqual(bZ,$)}:void 0,iY="scryptSync"in O$?(bZ,$,Q,Y)=>{let Z=O$.scryptSync(bZ,$,Q,Y);return W$!=="buffer"?new Buffer(Z).toString(W$):new Buffer(Z)}:void 0,$Z="scryptSync"in O$?function(bZ,$,Q,Y,Z){if(typeof Y=="function"&&(Z=Y,Y=void 0),typeof Z!="function"){var G=new TypeError("callback must be a function");throw G.code="ERR_INVALID_CALLBACK",G}try{let V=O$.scryptSync(bZ,$,Q,Y);process.nextTick(Z,null,W$!=="buffer"?new Buffer(V).toString(W$):new Buffer(V))}catch(V){throw V}}:void 0;H$&&(Object.defineProperty(H$,"name",{value:"::bunternal::"}),Object.defineProperty($Z,"name",{value:"::bunternal::"}),Object.defineProperty(iY,"name",{value:"::bunternal::"}));var E$=O$;z$(aY,{DEFAULT_ENCODING:()=>W$,getRandomValues:()=>rY,randomUUID:()=>eY,scrypt:()=>$Z,scryptSync:()=>iY,timingSafeEqual:()=>H$,webcrypto:()=>E$,subtle:()=>E$.subtle});var{randomBytes:QZ,rng:YZ,pseudoRandomBytes:ZZ,prng:GZ,Hash:VZ,createHash:UZ,createHmac:XZ,Hmac:KZ,getHashes:IZ,pbkdf2:JZ,pbkdf2Sync:OZ,Cipher:FZ,createCipher:AZ,Cipheriv:WZ,createCipheriv:HZ,Decipher:EZ,createDecipher:TZ,Decipheriv:DZ,createDecipheriv:CZ,getCiphers:LZ,listCiphers:RZ,DiffieHellmanGroup:PZ,createDiffieHellmanGroup:zZ,getDiffieHellman:MZ,createDiffieHellman:SZ,DiffieHellman:vZ,createSign:qZ,Sign:jZ,createVerify:kZ,Verify:gZ,createECDH:NZ,publicEncrypt:xZ,privateEncrypt:_Z,publicDecrypt:BZ,privateDecrypt:yZ,randomFill:wZ,randomFillSync:fZ,createCredentials:pZ,constants:cZ}=aY;var dZ=aY;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{E$ as webcrypto,H$ as timingSafeEqual,iY as scryptSync,$Z as scrypt,YZ as rng,eY as randomUUID,fZ as randomFillSync,wZ as randomFill,QZ as randomBytes,xZ as publicEncrypt,BZ as publicDecrypt,ZZ as pseudoRandomBytes,GZ as prng,_Z as privateEncrypt,yZ as privateDecrypt,OZ as pbkdf2Sync,JZ as pbkdf2,RZ as listCiphers,rY as getRandomValues,IZ as getHashes,MZ as getDiffieHellman,LZ as getCiphers,dZ as default,kZ as createVerify,qZ as createSign,XZ as createHmac,UZ as createHash,NZ as createECDH,zZ as createDiffieHellmanGroup,SZ as createDiffieHellman,CZ as createDecipheriv,TZ as createDecipher,pZ as createCredentials,HZ as createCipheriv,AZ as createCipher,cZ as constants,gZ as Verify,jZ as Sign,KZ as Hmac,VZ as Hash,PZ as DiffieHellmanGroup,vZ as DiffieHellman,DZ as Decipheriv,EZ as Decipher,W$ as DEFAULT_ENCODING,WZ as Cipheriv,FZ as Cipher}; +import{StringDecoder as z$} from"node:string_decoder";import*as M$ from"node:buffer";import*as A$ from"node:stream";var L$=Object.defineProperty;var R$=Object.getOwnPropertyNames;var S$=536870888,F$=globalThis.Buffer,H$=globalThis.crypto,v$=H$;var q$=($,Q)=>function(){return Q||(0,$[R$($)[0]])((Q={exports:{}}).exports,Q),Q.exports},j$=($,Q)=>{for(var Y in Q)L$($,Y,{get:Q[Y],enumerable:!0})};var k$=q$({"node_modules/safe-buffer/index.js"($,Q){var Y=M$,Z=Y.Buffer;function G(U,X){for(var K in U)X[K]=U[K]}Z.from&&Z.alloc&&Z.allocUnsafe&&Z.allocUnsafeSlow?Q.exports=Y:(G(Y,$),$.Buffer=V);function V(U,X,K){return Z(U,X,K)}V.prototype=Object.create(Z.prototype),G(Z,V),V.from=function(U,X,K){if(typeof U=="number")throw new TypeError("Argument must not be a number");return Z(U,X,K)},V.alloc=function(U,X,K){if(typeof U!="number")throw new TypeError("Argument must be a number");var I=Z(U);return X!==void 0?typeof K=="string"?I.fill(X,K):I.fill(X):I.fill(0),I},V.allocUnsafe=function(U){if(typeof U!="number")throw new TypeError("Argument must be a number");return Z(U)},V.allocUnsafeSlow=function(U){if(typeof U!="number")throw new TypeError("Argument must be a number");return Y.SlowBuffer(U)}}}),g$=q$({"node_modules/randombytes/browser.js"($,Q){var Y=65536,Z=4294967295;function G(){throw new Error(`Secure random number generation is not supported by this browser. +Use Chrome, Firefox or Internet Explorer 11`)}var V=k$().Buffer,U=v$;U&&U.getRandomValues?Q.exports=X:Q.exports=G;function X(K,I){if(K>Z)throw new RangeError("requested too many random bytes");var O=V.allocUnsafe(K);if(K>0)if(K>Y)for(var J=0;J=this._blockSize;){for(var O=this._blockOffset;O0;++J)this._length[J]+=F,F=this._length[J]/4294967296|0,F>0&&(this._length[J]-=4294967296*F);return this},V.prototype._update=function(){throw new Error("_update is not implemented")},V.prototype.digest=function(U){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var X=this._digest();U!==void 0&&(X=X.toString(U)),this._block.fill(0),this._blockOffset=0;for(var K=0;K<4;++K)this._length[K]=0;return X},V.prototype._digest=function(){throw new Error("_digest is not implemented")},Q.exports=V}}),x$=q$({"node_modules/md5.js/index.js"($,Q){var Y=_$(),Z=N$(),G=k$().Buffer,V=new Array(16);function U(){Z.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}Y(U,Z),U.prototype._update=function(){for(var F=V,A=0;A<16;++A)F[A]=this._block.readInt32LE(A*4);var H=this._a,W=this._b,E=this._c,T=this._d;H=K(H,W,E,T,F[0],3614090360,7),T=K(T,H,W,E,F[1],3905402710,12),E=K(E,T,H,W,F[2],606105819,17),W=K(W,E,T,H,F[3],3250441966,22),H=K(H,W,E,T,F[4],4118548399,7),T=K(T,H,W,E,F[5],1200080426,12),E=K(E,T,H,W,F[6],2821735955,17),W=K(W,E,T,H,F[7],4249261313,22),H=K(H,W,E,T,F[8],1770035416,7),T=K(T,H,W,E,F[9],2336552879,12),E=K(E,T,H,W,F[10],4294925233,17),W=K(W,E,T,H,F[11],2304563134,22),H=K(H,W,E,T,F[12],1804603682,7),T=K(T,H,W,E,F[13],4254626195,12),E=K(E,T,H,W,F[14],2792965006,17),W=K(W,E,T,H,F[15],1236535329,22),H=I(H,W,E,T,F[1],4129170786,5),T=I(T,H,W,E,F[6],3225465664,9),E=I(E,T,H,W,F[11],643717713,14),W=I(W,E,T,H,F[0],3921069994,20),H=I(H,W,E,T,F[5],3593408605,5),T=I(T,H,W,E,F[10],38016083,9),E=I(E,T,H,W,F[15],3634488961,14),W=I(W,E,T,H,F[4],3889429448,20),H=I(H,W,E,T,F[9],568446438,5),T=I(T,H,W,E,F[14],3275163606,9),E=I(E,T,H,W,F[3],4107603335,14),W=I(W,E,T,H,F[8],1163531501,20),H=I(H,W,E,T,F[13],2850285829,5),T=I(T,H,W,E,F[2],4243563512,9),E=I(E,T,H,W,F[7],1735328473,14),W=I(W,E,T,H,F[12],2368359562,20),H=O(H,W,E,T,F[5],4294588738,4),T=O(T,H,W,E,F[8],2272392833,11),E=O(E,T,H,W,F[11],1839030562,16),W=O(W,E,T,H,F[14],4259657740,23),H=O(H,W,E,T,F[1],2763975236,4),T=O(T,H,W,E,F[4],1272893353,11),E=O(E,T,H,W,F[7],4139469664,16),W=O(W,E,T,H,F[10],3200236656,23),H=O(H,W,E,T,F[13],681279174,4),T=O(T,H,W,E,F[0],3936430074,11),E=O(E,T,H,W,F[3],3572445317,16),W=O(W,E,T,H,F[6],76029189,23),H=O(H,W,E,T,F[9],3654602809,4),T=O(T,H,W,E,F[12],3873151461,11),E=O(E,T,H,W,F[15],530742520,16),W=O(W,E,T,H,F[2],3299628645,23),H=J(H,W,E,T,F[0],4096336452,6),T=J(T,H,W,E,F[7],1126891415,10),E=J(E,T,H,W,F[14],2878612391,15),W=J(W,E,T,H,F[5],4237533241,21),H=J(H,W,E,T,F[12],1700485571,6),T=J(T,H,W,E,F[3],2399980690,10),E=J(E,T,H,W,F[10],4293915773,15),W=J(W,E,T,H,F[1],2240044497,21),H=J(H,W,E,T,F[8],1873313359,6),T=J(T,H,W,E,F[15],4264355552,10),E=J(E,T,H,W,F[6],2734768916,15),W=J(W,E,T,H,F[13],1309151649,21),H=J(H,W,E,T,F[4],4149444226,6),T=J(T,H,W,E,F[11],3174756917,10),E=J(E,T,H,W,F[2],718787259,15),W=J(W,E,T,H,F[9],3951481745,21),this._a=this._a+H|0,this._b=this._b+W|0,this._c=this._c+E|0,this._d=this._d+T|0},U.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var F=G.allocUnsafe(16);return F.writeInt32LE(this._a,0),F.writeInt32LE(this._b,4),F.writeInt32LE(this._c,8),F.writeInt32LE(this._d,12),F};function X(F,A){return F<>>32-A}function K(F,A,H,W,E,T,D){return X(F+(A&H|~A&W)+E+T|0,D)+A|0}function I(F,A,H,W,E,T,D){return X(F+(A&W|H&~W)+E+T|0,D)+A|0}function O(F,A,H,W,E,T,D){return X(F+(A^H^W)+E+T|0,D)+A|0}function J(F,A,H,W,E,T,D){return X(F+(H^(A|~W))+E+T|0,D)+A|0}Q.exports=U}}),B$=q$({"node_modules/ripemd160/index.js"($,Q){var Y=F$,Z=_$(),G=N$(),V=new Array(16),U=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],X=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],K=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],I=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],O=[0,1518500249,1859775393,2400959708,2840853838],J=[1352829926,1548603684,1836072691,2053994217,0];function F(){G.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}Z(F,G),F.prototype._update=function(){for(var C=V,L=0;L<16;++L)C[L]=this._block.readInt32LE(L*4);for(var R=this._a|0,P=this._b|0,z=this._c|0,M=this._d|0,S=this._e|0,v=this._a|0,q=this._b|0,j=this._c|0,k=this._d|0,g=this._e|0,_=0;_<80;_+=1){var N,x;_<16?(N=H(R,P,z,M,S,C[U[_]],O[0],K[_]),x=D(v,q,j,k,g,C[X[_]],J[0],I[_])):_<32?(N=W(R,P,z,M,S,C[U[_]],O[1],K[_]),x=T(v,q,j,k,g,C[X[_]],J[1],I[_])):_<48?(N=E(R,P,z,M,S,C[U[_]],O[2],K[_]),x=E(v,q,j,k,g,C[X[_]],J[2],I[_])):_<64?(N=T(R,P,z,M,S,C[U[_]],O[3],K[_]),x=W(v,q,j,k,g,C[X[_]],J[3],I[_])):(N=D(R,P,z,M,S,C[U[_]],O[4],K[_]),x=H(v,q,j,k,g,C[X[_]],J[4],I[_])),R=S,S=M,M=A(z,10),z=P,P=N,v=g,g=k,k=A(j,10),j=q,q=x}var B=this._b+z+k|0;this._b=this._c+M+g|0,this._c=this._d+S+v|0,this._d=this._e+R+q|0,this._e=this._a+P+j|0,this._a=B},F.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var C=Y.alloc?Y.alloc(20):new Y(20);return C.writeInt32LE(this._a,0),C.writeInt32LE(this._b,4),C.writeInt32LE(this._c,8),C.writeInt32LE(this._d,12),C.writeInt32LE(this._e,16),C};function A(C,L){return C<>>32-L}function H(C,L,R,P,z,M,S,v){return A(C+(L^R^P)+M+S|0,v)+z|0}function W(C,L,R,P,z,M,S,v){return A(C+(L&R|~L&P)+M+S|0,v)+z|0}function E(C,L,R,P,z,M,S,v){return A(C+((L|~R)^P)+M+S|0,v)+z|0}function T(C,L,R,P,z,M,S,v){return A(C+(L&P|R&~P)+M+S|0,v)+z|0}function D(C,L,R,P,z,M,S,v){return A(C+(L^(R|~P))+M+S|0,v)+z|0}Q.exports=F}}),y$=q$({"node_modules/sha.js/hash.js"($,Q){var Y=k$().Buffer;function Z(G,V){this._block=Y.alloc(G),this._finalSize=V,this._blockSize=G,this._len=0}Z.prototype.update=function(G,V){typeof G=="string"&&(V=V||"utf8",G=Y.from(G,V));for(var U=this._block,X=this._blockSize,K=G.length,I=this._len,O=0;O=this._finalSize&&(this._update(this._block),this._block.fill(0));var U=this._len*8;if(U<=4294967295)this._block.writeUInt32BE(U,this._blockSize-4);else{var X=(U&4294967295)>>>0,K=(U-X)/4294967296;this._block.writeUInt32BE(K,this._blockSize-8),this._block.writeUInt32BE(X,this._blockSize-4)}this._update(this._block);var I=this._hash();return G?I.toString(G):I},Z.prototype._update=function(){throw new Error("_update must be implemented by subclass")},Q.exports=Z}}),w$=q$({"node_modules/sha.js/sha.js"($,Q){var Y=_$(),Z=y$(),G=k$().Buffer,V=[1518500249,1859775393,-1894007588,-899497514],U=new Array(80);function X(){this.init(),this._w=U,Z.call(this,64,56)}Y(X,Z),X.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function K(J){return J<<5|J>>>27}function I(J){return J<<30|J>>>2}function O(J,F,A,H){return J===0?F&A|~F&H:J===2?F&A|F&H|A&H:F^A^H}X.prototype._update=function(J){for(var F=this._w,A=this._a|0,H=this._b|0,W=this._c|0,E=this._d|0,T=this._e|0,D=0;D<16;++D)F[D]=J.readInt32BE(D*4);for(;D<80;++D)F[D]=F[D-3]^F[D-8]^F[D-14]^F[D-16];for(var C=0;C<80;++C){var L=~~(C/20),R=K(A)+O(L,H,W,E)+T+F[C]+V[L]|0;T=E,E=W,W=I(H),H=A,A=R}this._a=A+this._a|0,this._b=H+this._b|0,this._c=W+this._c|0,this._d=E+this._d|0,this._e=T+this._e|0},X.prototype._hash=function(){var J=G.allocUnsafe(20);return J.writeInt32BE(this._a|0,0),J.writeInt32BE(this._b|0,4),J.writeInt32BE(this._c|0,8),J.writeInt32BE(this._d|0,12),J.writeInt32BE(this._e|0,16),J},Q.exports=X}}),p$=q$({"node_modules/sha.js/sha1.js"($,Q){var Y=_$(),Z=y$(),G=k$().Buffer,V=[1518500249,1859775393,-1894007588,-899497514],U=new Array(80);function X(){this.init(),this._w=U,Z.call(this,64,56)}Y(X,Z),X.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function K(F){return F<<1|F>>>31}function I(F){return F<<5|F>>>27}function O(F){return F<<30|F>>>2}function J(F,A,H,W){return F===0?A&H|~A&W:F===2?A&H|A&W|H&W:A^H^W}X.prototype._update=function(F){for(var A=this._w,H=this._a|0,W=this._b|0,E=this._c|0,T=this._d|0,D=this._e|0,C=0;C<16;++C)A[C]=F.readInt32BE(C*4);for(;C<80;++C)A[C]=K(A[C-3]^A[C-8]^A[C-14]^A[C-16]);for(var L=0;L<80;++L){var R=~~(L/20),P=I(H)+J(R,W,E,T)+D+A[L]+V[R]|0;D=T,T=E,E=O(W),W=H,H=P}this._a=H+this._a|0,this._b=W+this._b|0,this._c=E+this._c|0,this._d=T+this._d|0,this._e=D+this._e|0},X.prototype._hash=function(){var F=G.allocUnsafe(20);return F.writeInt32BE(this._a|0,0),F.writeInt32BE(this._b|0,4),F.writeInt32BE(this._c|0,8),F.writeInt32BE(this._d|0,12),F.writeInt32BE(this._e|0,16),F},Q.exports=X}}),f$=q$({"node_modules/sha.js/sha256.js"($,Q){var Y=_$(),Z=y$(),G=k$().Buffer,V=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],U=new Array(64);function X(){this.init(),this._w=U,Z.call(this,64,56)}Y(X,Z),X.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function K(H,W,E){return E^H&(W^E)}function I(H,W,E){return H&W|E&(H|W)}function O(H){return(H>>>2|H<<30)^(H>>>13|H<<19)^(H>>>22|H<<10)}function J(H){return(H>>>6|H<<26)^(H>>>11|H<<21)^(H>>>25|H<<7)}function F(H){return(H>>>7|H<<25)^(H>>>18|H<<14)^H>>>3}function A(H){return(H>>>17|H<<15)^(H>>>19|H<<13)^H>>>10}X.prototype._update=function(H){for(var W=this._w,E=this._a|0,T=this._b|0,D=this._c|0,C=this._d|0,L=this._e|0,R=this._f|0,P=this._g|0,z=this._h|0,M=0;M<16;++M)W[M]=H.readInt32BE(M*4);for(;M<64;++M)W[M]=A(W[M-2])+W[M-7]+F(W[M-15])+W[M-16]|0;for(var S=0;S<64;++S){var v=z+J(L)+K(L,R,P)+V[S]+W[S]|0,q=O(E)+I(E,T,D)|0;z=P,P=R,R=L,L=C+v|0,C=D,D=T,T=E,E=v+q|0}this._a=E+this._a|0,this._b=T+this._b|0,this._c=D+this._c|0,this._d=C+this._d|0,this._e=L+this._e|0,this._f=R+this._f|0,this._g=P+this._g|0,this._h=z+this._h|0},X.prototype._hash=function(){var H=G.allocUnsafe(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},Q.exports=X}}),c$=q$({"node_modules/sha.js/sha224.js"($,Q){var Y=_$(),Z=f$(),G=y$(),V=k$().Buffer,U=new Array(64);function X(){this.init(),this._w=U,G.call(this,64,56)}Y(X,Z),X.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},X.prototype._hash=function(){var K=V.allocUnsafe(28);return K.writeInt32BE(this._a,0),K.writeInt32BE(this._b,4),K.writeInt32BE(this._c,8),K.writeInt32BE(this._d,12),K.writeInt32BE(this._e,16),K.writeInt32BE(this._f,20),K.writeInt32BE(this._g,24),K},Q.exports=X}}),h$=q$({"node_modules/sha.js/sha512.js"($,Q){var Y=_$(),Z=y$(),G=k$().Buffer,V=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],U=new Array(160);function X(){this.init(),this._w=U,Z.call(this,128,112)}Y(X,Z),X.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function K(T,D,C){return C^T&(D^C)}function I(T,D,C){return T&D|C&(T|D)}function O(T,D){return(T>>>28|D<<4)^(D>>>2|T<<30)^(D>>>7|T<<25)}function J(T,D){return(T>>>14|D<<18)^(T>>>18|D<<14)^(D>>>9|T<<23)}function F(T,D){return(T>>>1|D<<31)^(T>>>8|D<<24)^T>>>7}function A(T,D){return(T>>>1|D<<31)^(T>>>8|D<<24)^(T>>>7|D<<25)}function H(T,D){return(T>>>19|D<<13)^(D>>>29|T<<3)^T>>>6}function W(T,D){return(T>>>19|D<<13)^(D>>>29|T<<3)^(T>>>6|D<<26)}function E(T,D){return T>>>0>>0?1:0}X.prototype._update=function(T){for(var D=this._w,C=this._ah|0,L=this._bh|0,R=this._ch|0,P=this._dh|0,z=this._eh|0,M=this._fh|0,S=this._gh|0,v=this._hh|0,q=this._al|0,j=this._bl|0,k=this._cl|0,g=this._dl|0,_=this._el|0,N=this._fl|0,x=this._gl|0,B=this._hl|0,y=0;y<32;y+=2)D[y]=T.readInt32BE(y*4),D[y+1]=T.readInt32BE(y*4+4);for(;y<160;y+=2){var w=D[y-30],p=D[y-30+1],f=F(w,p),c=A(p,w);w=D[y-4],p=D[y-4+1];var h=H(w,p),d=W(p,w),b=D[y-14],l=D[y-14+1],o=D[y-32],u=D[y-32+1],n=c+l|0,s=f+b+E(n,c)|0;n=n+d|0,s=s+h+E(n,d)|0,n=n+u|0,s=s+o+E(n,u)|0,D[y]=s,D[y+1]=n}for(var t=0;t<160;t+=2){s=D[t],n=D[t+1];var m=I(C,L,R),a=I(q,j,k),e=O(C,q),r=O(q,C),i=J(z,_),$0=J(_,z),Q0=V[t],Y0=V[t+1],Z0=K(z,M,S),G0=K(_,N,x),V0=B+$0|0,U0=v+i+E(V0,B)|0;V0=V0+G0|0,U0=U0+Z0+E(V0,G0)|0,V0=V0+Y0|0,U0=U0+Q0+E(V0,Y0)|0,V0=V0+n|0,U0=U0+s+E(V0,n)|0;var X0=r+a|0,K0=e+m+E(X0,r)|0;v=S,B=x,S=M,x=N,M=z,N=_,_=g+V0|0,z=P+U0+E(_,g)|0,P=R,g=k,R=L,k=j,L=C,j=q,q=V0+X0|0,C=U0+K0+E(q,V0)|0}this._al=this._al+q|0,this._bl=this._bl+j|0,this._cl=this._cl+k|0,this._dl=this._dl+g|0,this._el=this._el+_|0,this._fl=this._fl+N|0,this._gl=this._gl+x|0,this._hl=this._hl+B|0,this._ah=this._ah+C+E(this._al,q)|0,this._bh=this._bh+L+E(this._bl,j)|0,this._ch=this._ch+R+E(this._cl,k)|0,this._dh=this._dh+P+E(this._dl,g)|0,this._eh=this._eh+z+E(this._el,_)|0,this._fh=this._fh+M+E(this._fl,N)|0,this._gh=this._gh+S+E(this._gl,x)|0,this._hh=this._hh+v+E(this._hl,B)|0},X.prototype._hash=function(){var T=G.allocUnsafe(64);function D(C,L,R){T.writeInt32BE(C,R),T.writeInt32BE(L,R+4)}return D(this._ah,this._al,0),D(this._bh,this._bl,8),D(this._ch,this._cl,16),D(this._dh,this._dl,24),D(this._eh,this._el,32),D(this._fh,this._fl,40),D(this._gh,this._gl,48),D(this._hh,this._hl,56),T},Q.exports=X}}),d$=q$({"node_modules/sha.js/sha384.js"($,Q){var Y=_$(),Z=h$(),G=y$(),V=k$().Buffer,U=new Array(160);function X(){this.init(),this._w=U,G.call(this,128,112)}Y(X,Z),X.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},X.prototype._hash=function(){var K=V.allocUnsafe(48);function I(O,J,F){K.writeInt32BE(O,F),K.writeInt32BE(J,F+4)}return I(this._ah,this._al,0),I(this._bh,this._bl,8),I(this._ch,this._cl,16),I(this._dh,this._dl,24),I(this._eh,this._el,32),I(this._fh,this._fl,40),K},Q.exports=X}}),b$=q$({"node_modules/sha.js/index.js"(Y,Q){var Y=Q.exports=function(Z){Z=Z.toLowerCase();var G=Y[Z];if(!G)throw new Error(Z+" is not supported (we accept pull requests)");return new G};Y.sha=w$(),Y.sha1=p$(),Y.sha224=c$(),Y.sha256=f$(),Y.sha384=d$(),Y.sha512=h$()}}),l$=q$({"node_modules/cipher-base/index.js"($,Q){var Y=k$().Buffer,Z=_$();function G(V){A$.Transform.call(this),this.hashMode=typeof V=="string",this.hashMode?this[V]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}Z(G,A$.Transform),G.prototype.update=function(V,U,X){typeof V=="string"&&(V=Y.from(V,U));var K=this._update(V);return this.hashMode?this:(X&&(K=this._toString(K,X)),K)},G.prototype.setAutoPadding=function(){},G.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},G.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},G.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},G.prototype._transform=function(V,U,X){var K;try{this.hashMode?this._update(V):this.push(this._update(V))}catch(I){K=I}finally{X(K)}},G.prototype._flush=function(V){var U;try{this.push(this.__final())}catch(X){U=X}V(U)},G.prototype._finalOrDigest=function(V){var U=this.__final()||Y.alloc(0);return V&&(U=this._toString(U,V,!0)),U},G.prototype._toString=function(V,U,X){if(this._decoder||(this._decoder=new z$(U),this._encoding=U),this._encoding!==U)throw new Error("can't switch encodings");var K=this._decoder.write(V);return X&&(K+=this._decoder.end()),K},Q.exports=G}}),o$=q$({"node_modules/create-hash/browser.js"($,Q){const Y=function V(U,X){this._options=X,this._hasher=new sY(U,X),this._finalized=!1};Y.prototype=Object.create(A$.Transform.prototype),Y.prototype.update=function V(U,X){return this._checkFinalized(),this._hasher.update(U,X),this},Y.prototype.digest=function V(U,X){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(U,X)},Y.prototype._checkFinalized=function V(){if(this._finalized){var U=new Error("Digest already called");throw U.code="ERR_CRYPTO_HASH_FINALIZED",U}},Y.prototype.copy=function V(){const U=Object.create(Y.prototype);return U._options=this._options,U._hasher=this._hasher.copy(),U._finalized=this._finalized,U};const Z={__proto__:A$.Transform.prototype,...Y.prototype,_transform(V,U,X){this.update(V,U),X&&X()},_flush(V){this.push(this.digest()),V()}},G=["_events","_eventsCount","_final","_maxListeners","_maxListeners","_read","_undestroy","_writableState","_write","_writev","addListener","asIndexedPairs","closed","compose","constructor","cork","destroy","destroyed","drop","emit","end","errored","eventNames","every","filter","find","flatMap","forEach","getMaxListeners","hasOwnProperty","isPaused","isPrototypeOf","iterator","listenerCount","listeners","map","off","on","once","pause","pipe","prependListener","prependOnceListener","propertyIsEnumerable","push","rawListeners","read","readable","readableAborted","readableBuffer","readableDidRead","readableEncoding","readableEnded","readableFlowing","readableHighWaterMark","readableLength","readableObjectMode","reduce","removeAllListeners","removeListener","resume","setDefaultEncoding","setEncoding","setMaxListeners","some","take","toArray","toLocaleString","toString","uncork","unpipe","unshift","valueOf","wrap","writable","writableBuffer","writableCorked","writableEnded","writableFinished","writableHighWaterMark","writableLength","writableNeedDrain","writableObjectMode","write"];for(let V of G)Object.defineProperty(Y.prototype,V,{get(){return Object.setPrototypeOf(this,Z),A$.Transform.call(this,this._options),this[V]},enumerable:!1,configurable:!0});Q.exports=function V(U){return new Y(U)},Q.exports.createHash=Q.exports,Q.exports.Hash=Y}}),u$=q$({"node_modules/create-hmac/legacy.js"($,Q){var Y=_$(),Z=k$().Buffer,G=l$(),V=Z.alloc(128),U=64;function X(K,I){G.call(this,"digest"),typeof I=="string"&&(I=Z.from(I)),this._alg=K,this._key=I,I.length>U?I=K(I):I.lengthA){var H=J==="rmd160"?new X:K(J);F=H.update(F).digest()}else F.lengthY||G!==G)throw new TypeError("Bad key length")}}}),e$=q$({"node_modules/pbkdf2/lib/default-encoding.js"($,Q){var Y;global.process&&global.process.browser?Y="utf-8":global.process&&global.process.version?(Z=parseInt(process.version.split(".")[0].slice(1),10),Y=Z>=6?"utf-8":"binary"):Y="utf-8";var Z;Q.exports=Y}}),r$=q$({"node_modules/pbkdf2/lib/to-buffer.js"($,Q){var Y=k$().Buffer;Q.exports=function(Z,G,V){if(Y.isBuffer(Z))return Z;if(typeof Z=="string")return Y.from(Z,G);if(ArrayBuffer.isView(Z))return Y.from(Z.buffer);throw new TypeError(V+" must be a string, a Buffer, a typed array or a DataView")}}}),i$=q$({"node_modules/pbkdf2/lib/sync-browser.js"($,Q){var Y=n$(),Z=B$(),G=b$(),V=k$().Buffer,U=a$(),X=e$(),K=r$(),I=V.alloc(128),O={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function J(H,W,E){var T=F(H),D=H==="sha512"||H==="sha384"?128:64;W.length>D?W=T(W):W.length>>0},$.writeUInt32BE=function(G,V,U){G[0+U]=V>>>24,G[1+U]=V>>>16&255,G[2+U]=V>>>8&255,G[3+U]=V&255},$.ip=function(G,V,U,X){for(var K=0,I=0,O=6;O>=0;O-=2){for(var J=0;J<=24;J+=8)K<<=1,K|=V>>>J+O&1;for(var J=0;J<=24;J+=8)K<<=1,K|=G>>>J+O&1}for(var O=6;O>=0;O-=2){for(var J=1;J<=25;J+=8)I<<=1,I|=V>>>J+O&1;for(var J=1;J<=25;J+=8)I<<=1,I|=G>>>J+O&1}U[X+0]=K>>>0,U[X+1]=I>>>0},$.rip=function(G,V,U,X){for(var K=0,I=0,O=0;O<4;O++)for(var J=24;J>=0;J-=8)K<<=1,K|=V>>>J+O&1,K<<=1,K|=G>>>J+O&1;for(var O=4;O<8;O++)for(var J=24;J>=0;J-=8)I<<=1,I|=V>>>J+O&1,I<<=1,I|=G>>>J+O&1;U[X+0]=K>>>0,U[X+1]=I>>>0},$.pc1=function(G,V,U,X){for(var K=0,I=0,O=7;O>=5;O--){for(var J=0;J<=24;J+=8)K<<=1,K|=V>>J+O&1;for(var J=0;J<=24;J+=8)K<<=1,K|=G>>J+O&1}for(var J=0;J<=24;J+=8)K<<=1,K|=V>>J+O&1;for(var O=1;O<=3;O++){for(var J=0;J<=24;J+=8)I<<=1,I|=V>>J+O&1;for(var J=0;J<=24;J+=8)I<<=1,I|=G>>J+O&1}for(var J=0;J<=24;J+=8)I<<=1,I|=G>>J+O&1;U[X+0]=K>>>0,U[X+1]=I>>>0},$.r28shl=function(G,V){return G<>>28-V};var Q=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];$.pc2=function(G,V,U,X){for(var K=0,I=0,O=Q.length>>>1,J=0;J>>Q[J]&1;for(var J=O;J>>Q[J]&1;U[X+0]=K>>>0,U[X+1]=I>>>0},$.expand=function(G,V,U){var X=0,K=0;X=(G&1)<<5|G>>>27;for(var I=23;I>=15;I-=4)X<<=6,X|=G>>>I&63;for(var I=11;I>=3;I-=4)K|=G>>>I&63,K<<=6;K|=(G&31)<<1|G>>>31,V[U+0]=X>>>0,V[U+1]=K>>>0};var Y=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];$.substitute=function(G,V){for(var U=0,X=0;X<4;X++){var K=G>>>18-X*6&63,I=Y[X*64+K];U<<=4,U|=I}for(var X=0;X<4;X++){var K=V>>>18-X*6&63,I=Y[256+X*64+K];U<<=4,U|=I}return U>>>0};var Z=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];$.permute=function(G){for(var V=0,U=0;U>>Z[U]&1;return V>>>0},$.padSplit=function(G,V,U){for(var X=G.toString(2);X.length0;X--)V+=this._buffer(G,V),U+=this._flushBuffer(K,U);return V+=this._buffer(G,V),K},Z.prototype.final=function(G){var V;G&&(V=this.update(G));var U;return this.type==="encrypt"?U=this._finalEncrypt():U=this._finalDecrypt(),V?V.concat(U):U},Z.prototype._pad=function(G,V){if(V===0)return!1;for(;V>>1];J=G.r28shl(J,H),F=G.r28shl(F,H),G.pc2(J,F,I.keys,A)}},X.prototype._update=function(I,O,J,F){var A=this._desState,H=G.readUInt32BE(I,O),W=G.readUInt32BE(I,O+4);G.ip(H,W,A.tmp,0),H=A.tmp[0],W=A.tmp[1],this.type==="encrypt"?this._encrypt(A,H,W,A.tmp,0):this._decrypt(A,H,W,A.tmp,0),H=A.tmp[0],W=A.tmp[1],G.writeUInt32BE(J,H,F),G.writeUInt32BE(J,W,F+4)},X.prototype._pad=function(I,O){for(var J=I.length-O,F=O;F>>0,H=R}G.rip(W,H,F,A)},X.prototype._decrypt=function(I,O,J,F,A){for(var H=J,W=O,E=I.keys.length-2;E>=0;E-=2){var T=I.keys[E],D=I.keys[E+1];G.expand(H,I.tmp,0),T^=I.tmp[0],D^=I.tmp[1];var C=G.substitute(T,D),L=G.permute(C),R=H;H=(W^L)>>>0,W=R}G.rip(H,W,F,A)}}}),UQ=q$({"node_modules/des.js/lib/des/cbc.js"($){var Q=ZQ(),Y=_$(),Z={};function G(U){Q.equal(U.length,8,"Invalid IV length"),this.iv=new Array(8);for(var X=0;X>K%8,G._prev=Z(G._prev,U?J:F);return O}function Z(G,V){var U=G.length,X=-1,K=Q.allocUnsafe(G.length);for(G=Q.concat([G,Q.from([V])]);++X>7;return K}$.encrypt=function(G,V,U){for(var X=V.length,K=Q.allocUnsafe(X),I=-1;++I>>24]^W[C>>>16&255]^E[L>>>8&255]^T[R&255]^O[v++],z=H[C>>>24]^W[L>>>16&255]^E[R>>>8&255]^T[D&255]^O[v++],M=H[L>>>24]^W[R>>>16&255]^E[D>>>8&255]^T[C&255]^O[v++],S=H[R>>>24]^W[D>>>16&255]^E[C>>>8&255]^T[L&255]^O[v++],D=P,C=z,L=M,R=S;return P=(F[D>>>24]<<24|F[C>>>16&255]<<16|F[L>>>8&255]<<8|F[R&255])^O[v++],z=(F[C>>>24]<<24|F[L>>>16&255]<<16|F[R>>>8&255]<<8|F[D&255])^O[v++],M=(F[L>>>24]<<24|F[R>>>16&255]<<16|F[D>>>8&255]<<8|F[C&255])^O[v++],S=(F[R>>>24]<<24|F[D>>>16&255]<<16|F[C>>>8&255]<<8|F[L&255])^O[v++],P=P>>>0,z=z>>>0,M=M>>>0,S=S>>>0,[P,z,M,S]}var U=[0,1,2,4,8,16,32,64,128,27,54],X=function(){for(var I=new Array(256),O=0;O<256;O++)O<128?I[O]=O<<1:I[O]=O<<1^283;for(var J=[],F=[],A=[[],[],[],[]],H=[[],[],[],[]],W=0,E=0,T=0;T<256;++T){var D=E^E<<1^E<<2^E<<3^E<<4;D=D>>>8^D&255^99,J[W]=D,F[D]=W;var C=I[W],L=I[C],R=I[L],P=I[D]*257^D*16843008;A[0][W]=P<<24|P>>>8,A[1][W]=P<<16|P>>>16,A[2][W]=P<<8|P>>>24,A[3][W]=P,P=R*16843009^L*65537^C*257^W*16843008,H[0][D]=P<<24|P>>>8,H[1][D]=P<<16|P>>>16,H[2][D]=P<<8|P>>>24,H[3][D]=P,W===0?W=E=1:(W=C^I[I[I[R^C]]],E^=I[I[E]])}return{SBOX:J,INV_SBOX:F,SUB_MIX:A,INV_SUB_MIX:H}}();function K(I){this._key=Z(I),this._reset()}K.blockSize=16,K.keySize=32,K.prototype.blockSize=K.blockSize,K.prototype.keySize=K.keySize,K.prototype._reset=function(){for(var I=this._key,O=I.length,J=O+6,F=(J+1)*4,A=[],H=0;H>>24,W=X.SBOX[W>>>24]<<24|X.SBOX[W>>>16&255]<<16|X.SBOX[W>>>8&255]<<8|X.SBOX[W&255],W^=U[H/O|0]<<24):O>6&&H%O===4&&(W=X.SBOX[W>>>24]<<24|X.SBOX[W>>>16&255]<<16|X.SBOX[W>>>8&255]<<8|X.SBOX[W&255]),A[H]=A[H-O]^W}for(var E=[],T=0;T>>24]]^X.INV_SUB_MIX[1][X.SBOX[C>>>16&255]]^X.INV_SUB_MIX[2][X.SBOX[C>>>8&255]]^X.INV_SUB_MIX[3][X.SBOX[C&255]]}this._nRounds=J,this._keySchedule=A,this._invKeySchedule=E},K.prototype.encryptBlockRaw=function(I){return I=Z(I),V(I,this._keySchedule,X.SUB_MIX,X.SBOX,this._nRounds)},K.prototype.encryptBlock=function(I){var O=this.encryptBlockRaw(I),J=Y.allocUnsafe(16);return J.writeUInt32BE(O[0],0),J.writeUInt32BE(O[1],4),J.writeUInt32BE(O[2],8),J.writeUInt32BE(O[3],12),J},K.prototype.decryptBlock=function(I){I=Z(I);var O=I[1];I[1]=I[3],I[3]=O;var J=V(I,this._invKeySchedule,X.INV_SUB_MIX,X.INV_SBOX,this._nRounds),F=Y.allocUnsafe(16);return F.writeUInt32BE(J[0],0),F.writeUInt32BE(J[3],4),F.writeUInt32BE(J[2],8),F.writeUInt32BE(J[1],12),F},K.prototype.scrub=function(){G(this._keySchedule),G(this._invKeySchedule),G(this._key)},Q.exports.AES=K}}),RQ=q$({"node_modules/browserify-aes/ghash.js"($,Q){var Y=k$().Buffer,Z=Y.alloc(16,0);function G(X){return[X.readUInt32BE(0),X.readUInt32BE(4),X.readUInt32BE(8),X.readUInt32BE(12)]}function V(X){var K=Y.allocUnsafe(16);return K.writeUInt32BE(X[0]>>>0,0),K.writeUInt32BE(X[1]>>>0,4),K.writeUInt32BE(X[2]>>>0,8),K.writeUInt32BE(X[3]>>>0,12),K}function U(X){this.h=X,this.state=Y.alloc(16,0),this.cache=Y.allocUnsafe(0)}U.prototype.ghash=function(X){for(var K=-1;++K0;I--)X[I]=X[I]>>>1|(X[I-1]&1)<<31;X[0]=X[0]>>>1,J&&(X[0]=X[0]^225<<24)}this.state=V(K)},U.prototype.update=function(X){this.cache=Y.concat([this.cache,X]);for(var K;this.cache.length>=16;)K=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(K)},U.prototype.final=function(X,K){return this.cache.length&&this.ghash(Y.concat([this.cache,Z],16)),this.ghash(V([0,X,0,K])),this.state},Q.exports=U}}),PQ=q$({"node_modules/browserify-aes/authCipher.js"($,Q){var Y=LQ(),Z=k$().Buffer,G=l$(),V=_$(),U=RQ(),X=JQ(),K=TQ();function I(F,A){var H=0;F.length!==A.length&&H++;for(var W=Math.min(F.length,A.length),E=0;E0||K>0;){var A=new Z;A.update(F),A.update(V),U&&A.update(U),F=A.digest();var H=0;if(I>0){var W=O.length-I;H=Math.min(I,F.length),F.copy(O,W,0,H),I-=H}if(H0){var E=J.length-K,T=Math.min(K,F.length-H);F.copy(J,E,H,H+T),K-=T}}return F.fill(0),{key:O,iv:J}}Q.exports=G}}),SQ=q$({"node_modules/browserify-aes/encrypter.js"($){var Q=CQ(),Y=PQ(),Z=k$().Buffer,G=zQ(),V=l$(),U=LQ(),X=MQ(),K=_$();function I(H,W,E){V.call(this),this._cache=new J,this._cipher=new U.AES(W),this._prev=Z.from(E),this._mode=H,this._autopadding=!0}K(I,V),I.prototype._update=function(H){this._cache.add(H);for(var W,E,T=[];W=this._cache.get();)E=this._mode.encrypt(this,W),T.push(E);return Z.concat(T)};var O=Z.alloc(16,16);I.prototype._final=function(){var H=this._cache.flush();if(this._autopadding)return H=this._mode.encrypt(this,H),this._cipher.scrub(),H;if(!H.equals(O))throw this._cipher.scrub(),new Error("data not multiple of block length")},I.prototype.setAutoPadding=function(H){return this._autopadding=!!H,this};function J(){this.cache=Z.allocUnsafe(0)}J.prototype.add=function(H){this.cache=Z.concat([this.cache,H])},J.prototype.get=function(){if(this.cache.length>15){var H=this.cache.slice(0,16);return this.cache=this.cache.slice(16),H}return null},J.prototype.flush=function(){for(var H=16-this.cache.length,W=Z.allocUnsafe(H),E=-1;++E16)return W=this.cache.slice(0,16),this.cache=this.cache.slice(16),W}else if(this.cache.length>=16)return W=this.cache.slice(0,16),this.cache=this.cache.slice(16),W;return null},O.prototype.flush=function(){if(this.cache.length)return this.cache};function J(H){var W=H[15];if(W<1||W>16)throw new Error("unable to decrypt data");for(var E=-1;++E0?j:k},U.min=function(j,k){return j.cmp(k)<0?j:k},U.prototype._init=function(j,k,g){if(typeof j=="number")return this._initNumber(j,k,g);if(typeof j=="object")return this._initArray(j,k,g);k==="hex"&&(k=16),G(k===(k|0)&&k>=2&&k<=36),j=j.toString().replace(/\s+/g,"");var _=0;j[0]==="-"&&(_++,this.negative=1),_=0;_-=3)x=j[_]|j[_-1]<<8|j[_-2]<<16,this.words[N]|=x<>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);else if(g==="le")for(_=0,N=0;_>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);return this.strip()};function K(j,k){var g=j.charCodeAt(k);return g>=65&&g<=70?g-55:g>=97&&g<=102?g-87:g-48&15}function I(j,k,g){var _=K(j,g);return g-1>=k&&(_|=K(j,g-1)<<4),_}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var _=0;_=k;_-=2)B=I(j,k,_)<=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8;else{var y=j.length-k;for(_=y%2===0?k+1:k;_=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8}this.strip()};function O(j,k,g,_){for(var N=0,x=Math.min(j.length,g),B=k;B=49?N+=y-49+10:y>=17?N+=y-17+10:N+=y}return N}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var _=0,N=1;N<=67108863;N*=k)_++;_--,N=N/k|0;for(var x=j.length-g,B=x%_,y=Math.min(x,x-B)+g,w=0,p=g;p1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},U.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},U.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],F=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],A=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];U.prototype.toString=function(j,k){j=j||10,k=k|0||1;var g;if(j===16||j==="hex"){g="";for(var _=0,N=0,x=0;x>>24-_&16777215,N!==0||x!==this.length-1?g=J[6-y.length]+y+g:g=y+g,_+=2,_>=26&&(_-=26,x--)}for(N!==0&&(g=N.toString(16)+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}if(j===(j|0)&&j>=2&&j<=36){var w=F[j],p=A[j];g="";var f=this.clone();for(f.negative=0;!f.isZero();){var c=f.modn(p).toString(j);f=f.idivn(p),f.isZero()?g=c+g:g=J[w-c.length]+c+g}for(this.isZero()&&(g="0"+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}G(!1,"Base should be between 2 and 36")},U.prototype.toNumber=function(){var j=this.words[0];return this.length===2?j+=this.words[1]*67108864:this.length===3&&this.words[2]===1?j+=4503599627370496+this.words[1]*67108864:this.length>2&&G(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-j:j},U.prototype.toJSON=function(){return this.toString(16)},U.prototype.toBuffer=function(j,k){return G(typeof X<"u"),this.toArrayLike(X,j,k)},U.prototype.toArray=function(j,k){return this.toArrayLike(Array,j,k)},U.prototype.toArrayLike=function(j,k,g){var _=this.byteLength(),N=g||Math.max(1,_);G(_<=N,"byte array longer than desired length"),G(N>0,"Requested array length <= 0"),this.strip();var x=k==="le",B=new j(N),y,w,p=this.clone();if(x){for(w=0;!p.isZero();w++)y=p.andln(255),p.iushrn(8),B[w]=y;for(;w=4096&&(g+=13,k>>>=13),k>=64&&(g+=7,k>>>=7),k>=8&&(g+=4,k>>>=4),k>=2&&(g+=2,k>>>=2),g+k},U.prototype._zeroBits=function(j){if(j===0)return 26;var k=j,g=0;return(k&8191)===0&&(g+=13,k>>>=13),(k&127)===0&&(g+=7,k>>>=7),(k&15)===0&&(g+=4,k>>>=4),(k&3)===0&&(g+=2,k>>>=2),(k&1)===0&&g++,g},U.prototype.bitLength=function(){var j=this.words[this.length-1],k=this._countBits(j);return(this.length-1)*26+k};function H(j){for(var k=new Array(j.bitLength()),g=0;g>>N}return k}U.prototype.zeroBits=function(){if(this.isZero())return 0;for(var j=0,k=0;kj.length?this.clone().ior(j):j.clone().ior(this)},U.prototype.uor=function(j){return this.length>j.length?this.clone().iuor(j):j.clone().iuor(this)},U.prototype.iuand=function(j){var k;this.length>j.length?k=j:k=this;for(var g=0;gj.length?this.clone().iand(j):j.clone().iand(this)},U.prototype.uand=function(j){return this.length>j.length?this.clone().iuand(j):j.clone().iuand(this)},U.prototype.iuxor=function(j){var k,g;this.length>j.length?(k=this,g=j):(k=j,g=this);for(var _=0;_j.length?this.clone().ixor(j):j.clone().ixor(this)},U.prototype.uxor=function(j){return this.length>j.length?this.clone().iuxor(j):j.clone().iuxor(this)},U.prototype.inotn=function(j){G(typeof j=="number"&&j>=0);var k=Math.ceil(j/26)|0,g=j%26;this._expand(k),g>0&&k--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-g),this.strip()},U.prototype.notn=function(j){return this.clone().inotn(j)},U.prototype.setn=function(j,k){G(typeof j=="number"&&j>=0);var g=j/26|0,_=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<<_:this.words[g]=this.words[g]&~(1<<_),this.strip()},U.prototype.iadd=function(j){var k;if(this.negative!==0&&j.negative===0)return this.negative=0,k=this.isub(j),this.negative^=1,this._normSign();if(this.negative===0&&j.negative!==0)return j.negative=0,k=this.isub(j),j.negative=1,k._normSign();var g,_;this.length>j.length?(g=this,_=j):(g=j,_=this);for(var N=0,x=0;x<_.length;x++)k=(g.words[x]|0)+(_.words[x]|0)+N,this.words[x]=k&67108863,N=k>>>26;for(;N!==0&&x>>26;if(this.length=g.length,N!==0)this.words[this.length]=N,this.length++;else if(g!==this)for(;xj.length?this.clone().iadd(j):j.clone().iadd(this)},U.prototype.isub=function(j){if(j.negative!==0){j.negative=0;var k=this.iadd(j);return j.negative=1,k._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(j),this.negative=1,this._normSign();var g=this.cmp(j);if(g===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,N;g>0?(_=this,N=j):(_=j,N=this);for(var x=0,B=0;B>26,this.words[B]=k&67108863;for(;x!==0&&B<_.length;B++)k=(_.words[B]|0)+x,x=k>>26,this.words[B]=k&67108863;if(x===0&&B<_.length&&_!==this)for(;B<_.length;B++)this.words[B]=_.words[B];return this.length=Math.max(this.length,B),_!==this&&(this.negative=1),this.strip()},U.prototype.sub=function(j){return this.clone().isub(j)};function W(j,k,g){g.negative=k.negative^j.negative;var _=j.length+k.length|0;g.length=_,_=_-1|0;var N=j.words[0]|0,x=k.words[0]|0,B=N*x,y=B&67108863,w=B/67108864|0;g.words[0]=y;for(var p=1;p<_;p++){for(var f=w>>>26,c=w&67108863,h=Math.min(p,k.length-1),d=Math.max(0,p-j.length+1);d<=h;d++){var b=p-d|0;N=j.words[b]|0,x=k.words[d]|0,B=N*x+c,f+=B/67108864|0,c=B&67108863}g.words[p]=c|0,w=f|0}return w!==0?g.words[p]=w|0:g.length--,g.strip()}var E=function(j,k,g){var _=j.words,N=k.words,x=g.words,B=0,y,w,p,f=_[0]|0,c=f&8191,h=f>>>13,d=_[1]|0,b=d&8191,l=d>>>13,o=_[2]|0,u=o&8191,n=o>>>13,s=_[3]|0,t=s&8191,m=s>>>13,a=_[4]|0,e=a&8191,r=a>>>13,i=_[5]|0,$0=i&8191,Q0=i>>>13,Y0=_[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=_[7]|0,U0=V0&8191,X0=V0>>>13,K0=_[8]|0,I0=K0&8191,O0=K0>>>13,J0=_[9]|0,F0=J0&8191,A0=J0>>>13,H0=N[0]|0,W0=H0&8191,E0=H0>>>13,T0=N[1]|0,D0=T0&8191,C0=T0>>>13,L0=N[2]|0,R0=L0&8191,P0=L0>>>13,z0=N[3]|0,M0=z0&8191,S0=z0>>>13,v0=N[4]|0,q0=v0&8191,j0=v0>>>13,k0=N[5]|0,g0=k0&8191,_0=k0>>>13,N0=N[6]|0,x0=N0&8191,B0=N0>>>13,y0=N[7]|0,w0=y0&8191,p0=y0>>>13,f0=N[8]|0,c0=f0&8191,h0=f0>>>13,d0=N[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,W0),w=Math.imul(c,E0),w=w+Math.imul(h,W0)|0,p=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,W0),w=Math.imul(b,E0),w=w+Math.imul(l,W0)|0,p=Math.imul(l,E0),y=y+Math.imul(c,D0)|0,w=w+Math.imul(c,C0)|0,w=w+Math.imul(h,D0)|0,p=p+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,W0),w=Math.imul(u,E0),w=w+Math.imul(n,W0)|0,p=Math.imul(n,E0),y=y+Math.imul(b,D0)|0,w=w+Math.imul(b,C0)|0,w=w+Math.imul(l,D0)|0,p=p+Math.imul(l,C0)|0,y=y+Math.imul(c,R0)|0,w=w+Math.imul(c,P0)|0,w=w+Math.imul(h,R0)|0,p=p+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,W0),w=Math.imul(t,E0),w=w+Math.imul(m,W0)|0,p=Math.imul(m,E0),y=y+Math.imul(u,D0)|0,w=w+Math.imul(u,C0)|0,w=w+Math.imul(n,D0)|0,p=p+Math.imul(n,C0)|0,y=y+Math.imul(b,R0)|0,w=w+Math.imul(b,P0)|0,w=w+Math.imul(l,R0)|0,p=p+Math.imul(l,P0)|0,y=y+Math.imul(c,M0)|0,w=w+Math.imul(c,S0)|0,w=w+Math.imul(h,M0)|0,p=p+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(e,W0),w=Math.imul(e,E0),w=w+Math.imul(r,W0)|0,p=Math.imul(r,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,p=p+Math.imul(m,C0)|0,y=y+Math.imul(u,R0)|0,w=w+Math.imul(u,P0)|0,w=w+Math.imul(n,R0)|0,p=p+Math.imul(n,P0)|0,y=y+Math.imul(b,M0)|0,w=w+Math.imul(b,S0)|0,w=w+Math.imul(l,M0)|0,p=p+Math.imul(l,S0)|0,y=y+Math.imul(c,q0)|0,w=w+Math.imul(c,j0)|0,w=w+Math.imul(h,q0)|0,p=p+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,W0),w=Math.imul($0,E0),w=w+Math.imul(Q0,W0)|0,p=Math.imul(Q0,E0),y=y+Math.imul(e,D0)|0,w=w+Math.imul(e,C0)|0,w=w+Math.imul(r,D0)|0,p=p+Math.imul(r,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,p=p+Math.imul(m,P0)|0,y=y+Math.imul(u,M0)|0,w=w+Math.imul(u,S0)|0,w=w+Math.imul(n,M0)|0,p=p+Math.imul(n,S0)|0,y=y+Math.imul(b,q0)|0,w=w+Math.imul(b,j0)|0,w=w+Math.imul(l,q0)|0,p=p+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,_0)|0,w=w+Math.imul(h,g0)|0,p=p+Math.imul(h,_0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,W0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,W0)|0,p=Math.imul(G0,E0),y=y+Math.imul($0,D0)|0,w=w+Math.imul($0,C0)|0,w=w+Math.imul(Q0,D0)|0,p=p+Math.imul(Q0,C0)|0,y=y+Math.imul(e,R0)|0,w=w+Math.imul(e,P0)|0,w=w+Math.imul(r,R0)|0,p=p+Math.imul(r,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,p=p+Math.imul(m,S0)|0,y=y+Math.imul(u,q0)|0,w=w+Math.imul(u,j0)|0,w=w+Math.imul(n,q0)|0,p=p+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,_0)|0,w=w+Math.imul(l,g0)|0,p=p+Math.imul(l,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,x0)|0,p=p+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,W0),w=Math.imul(U0,E0),w=w+Math.imul(X0,W0)|0,p=Math.imul(X0,E0),y=y+Math.imul(Z0,D0)|0,w=w+Math.imul(Z0,C0)|0,w=w+Math.imul(G0,D0)|0,p=p+Math.imul(G0,C0)|0,y=y+Math.imul($0,R0)|0,w=w+Math.imul($0,P0)|0,w=w+Math.imul(Q0,R0)|0,p=p+Math.imul(Q0,P0)|0,y=y+Math.imul(e,M0)|0,w=w+Math.imul(e,S0)|0,w=w+Math.imul(r,M0)|0,p=p+Math.imul(r,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,p=p+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,_0)|0,w=w+Math.imul(n,g0)|0,p=p+Math.imul(n,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,x0)|0,p=p+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,p0)|0,w=w+Math.imul(h,w0)|0,p=p+Math.imul(h,p0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(I0,W0),w=Math.imul(I0,E0),w=w+Math.imul(O0,W0)|0,p=Math.imul(O0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,p=p+Math.imul(X0,C0)|0,y=y+Math.imul(Z0,R0)|0,w=w+Math.imul(Z0,P0)|0,w=w+Math.imul(G0,R0)|0,p=p+Math.imul(G0,P0)|0,y=y+Math.imul($0,M0)|0,w=w+Math.imul($0,S0)|0,w=w+Math.imul(Q0,M0)|0,p=p+Math.imul(Q0,S0)|0,y=y+Math.imul(e,q0)|0,w=w+Math.imul(e,j0)|0,w=w+Math.imul(r,q0)|0,p=p+Math.imul(r,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,_0)|0,w=w+Math.imul(m,g0)|0,p=p+Math.imul(m,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,x0)|0,p=p+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,p0)|0,w=w+Math.imul(l,w0)|0,p=p+Math.imul(l,p0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,p=p+Math.imul(h,h0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(F0,W0),w=Math.imul(F0,E0),w=w+Math.imul(A0,W0)|0,p=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(O0,D0)|0,p=p+Math.imul(O0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,p=p+Math.imul(X0,P0)|0,y=y+Math.imul(Z0,M0)|0,w=w+Math.imul(Z0,S0)|0,w=w+Math.imul(G0,M0)|0,p=p+Math.imul(G0,S0)|0,y=y+Math.imul($0,q0)|0,w=w+Math.imul($0,j0)|0,w=w+Math.imul(Q0,q0)|0,p=p+Math.imul(Q0,j0)|0,y=y+Math.imul(e,g0)|0,w=w+Math.imul(e,_0)|0,w=w+Math.imul(r,g0)|0,p=p+Math.imul(r,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,x0)|0,p=p+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,p0)|0,w=w+Math.imul(n,w0)|0,p=p+Math.imul(n,p0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,p=p+Math.imul(l,h0)|0,y=y+Math.imul(c,b0)|0,w=w+Math.imul(c,l0)|0,w=w+Math.imul(h,b0)|0,p=p+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(i0>>>26)|0,i0&=67108863,y=Math.imul(F0,D0),w=Math.imul(F0,C0),w=w+Math.imul(A0,D0)|0,p=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(O0,R0)|0,p=p+Math.imul(O0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,p=p+Math.imul(X0,S0)|0,y=y+Math.imul(Z0,q0)|0,w=w+Math.imul(Z0,j0)|0,w=w+Math.imul(G0,q0)|0,p=p+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,_0)|0,w=w+Math.imul(Q0,g0)|0,p=p+Math.imul(Q0,_0)|0,y=y+Math.imul(e,x0)|0,w=w+Math.imul(e,B0)|0,w=w+Math.imul(r,x0)|0,p=p+Math.imul(r,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,p0)|0,w=w+Math.imul(m,w0)|0,p=p+Math.imul(m,p0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,p=p+Math.imul(n,h0)|0,y=y+Math.imul(b,b0)|0,w=w+Math.imul(b,l0)|0,w=w+Math.imul(l,b0)|0,p=p+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,p=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(O0,M0)|0,p=p+Math.imul(O0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,p=p+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,_0)|0,w=w+Math.imul(G0,g0)|0,p=p+Math.imul(G0,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,x0)|0,p=p+Math.imul(Q0,B0)|0,y=y+Math.imul(e,w0)|0,w=w+Math.imul(e,p0)|0,w=w+Math.imul(r,w0)|0,p=p+Math.imul(r,p0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,p=p+Math.imul(m,h0)|0,y=y+Math.imul(u,b0)|0,w=w+Math.imul(u,l0)|0,w=w+Math.imul(n,b0)|0,p=p+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,y=Math.imul(F0,M0),w=Math.imul(F0,S0),w=w+Math.imul(A0,M0)|0,p=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(O0,q0)|0,p=p+Math.imul(O0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,_0)|0,w=w+Math.imul(X0,g0)|0,p=p+Math.imul(X0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,x0)|0,p=p+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,p0)|0,w=w+Math.imul(Q0,w0)|0,p=p+Math.imul(Q0,p0)|0,y=y+Math.imul(e,c0)|0,w=w+Math.imul(e,h0)|0,w=w+Math.imul(r,c0)|0,p=p+Math.imul(r,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,p=p+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,y=Math.imul(F0,q0),w=Math.imul(F0,j0),w=w+Math.imul(A0,q0)|0,p=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,_0)|0,w=w+Math.imul(O0,g0)|0,p=p+Math.imul(O0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,x0)|0,p=p+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,p0)|0,w=w+Math.imul(G0,w0)|0,p=p+Math.imul(G0,p0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,p=p+Math.imul(Q0,h0)|0,y=y+Math.imul(e,b0)|0,w=w+Math.imul(e,l0)|0,w=w+Math.imul(r,b0)|0,p=p+Math.imul(r,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,_0),w=w+Math.imul(A0,g0)|0,p=Math.imul(A0,_0),y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(O0,x0)|0,p=p+Math.imul(O0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,p0)|0,w=w+Math.imul(X0,w0)|0,p=p+Math.imul(X0,p0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,p=p+Math.imul(G0,h0)|0,y=y+Math.imul($0,b0)|0,w=w+Math.imul($0,l0)|0,w=w+Math.imul(Q0,b0)|0,p=p+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,x0),w=Math.imul(F0,B0),w=w+Math.imul(A0,x0)|0,p=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,p0)|0,w=w+Math.imul(O0,w0)|0,p=p+Math.imul(O0,p0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,p=p+Math.imul(X0,h0)|0,y=y+Math.imul(Z0,b0)|0,w=w+Math.imul(Z0,l0)|0,w=w+Math.imul(G0,b0)|0,p=p+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,p0),w=w+Math.imul(A0,w0)|0,p=Math.imul(A0,p0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(O0,c0)|0,p=p+Math.imul(O0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,p=p+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(U$>>>26)|0,U$&=67108863,y=Math.imul(F0,c0),w=Math.imul(F0,h0),w=w+Math.imul(A0,c0)|0,p=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(O0,b0)|0,p=p+Math.imul(O0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(X$>>>26)|0,X$&=67108863,y=Math.imul(F0,b0),w=Math.imul(F0,l0),w=w+Math.imul(A0,b0)|0,p=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(p+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,x[0]=o0,x[1]=u0,x[2]=n0,x[3]=s0,x[4]=t0,x[5]=m0,x[6]=a0,x[7]=e0,x[8]=r0,x[9]=i0,x[10]=$$,x[11]=Q$,x[12]=Y$,x[13]=Z$,x[14]=G$,x[15]=V$,x[16]=U$,x[17]=X$,x[18]=K$,B!==0&&(x[19]=B,g.length++),g};Math.imul||(E=W);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var _=0,N=0,x=0;x>>26)|0,N+=B>>>26,B&=67108863}g.words[x]=y,_=B,B=N}return _!==0?g.words[x]=_:g.length--,g.strip()}function D(j,k,g){var _=new C;return _.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,_=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):_<63?g=W(this,j,k):_<1024?g=T(this,j,k):g=D(this,j,k),g};function C(j,k){this.x=j,this.y=k}C.prototype.makeRBT=function(j){for(var k=new Array(j),g=U.prototype._countBits(j)-1,_=0;_>=1;return _},C.prototype.permute=function(j,k,g,_,N,x){for(var B=0;B>>1)N++;return 1<>>13,g[2*x+1]=N&8191,N=N>>>13;for(x=2*k;x<_;++x)g[x]=0;G(N===0),G((N&-8192)===0)},C.prototype.stub=function(j){for(var k=new Array(j),g=0;g>=26,k+=_/67108864|0,k+=N>>>26,this.words[g]=N&67108863}return k!==0&&(this.words[g]=k,this.length++),this},U.prototype.muln=function(j){return this.clone().imuln(j)},U.prototype.sqr=function(){return this.mul(this)},U.prototype.isqr=function(){return this.imul(this.clone())},U.prototype.pow=function(j){var k=H(j);if(k.length===0)return new U(1);for(var g=this,_=0;_=0);var k=j%26,g=(j-k)/26,_=67108863>>>26-k<<26-k,N;if(k!==0){var x=0;for(N=0;N>>26-k}x&&(this.words[N]=x,this.length++)}if(g!==0){for(N=this.length-1;N>=0;N--)this.words[N+g]=this.words[N];for(N=0;N=0);var _;k?_=(k-k%26)/26:_=0;var N=j%26,x=Math.min((j-N)/26,this.length),B=67108863^67108863>>>N<x)for(this.length-=x,w=0;w=0&&(p!==0||w>=_);w--){var f=this.words[w]|0;this.words[w]=p<<26-N|f>>>N,p=f&B}return y&&p!==0&&(y.words[y.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},U.prototype.ishrn=function(j,k,g){return G(this.negative===0),this.iushrn(j,k,g)},U.prototype.shln=function(j){return this.clone().ishln(j)},U.prototype.ushln=function(j){return this.clone().iushln(j)},U.prototype.shrn=function(j){return this.clone().ishrn(j)},U.prototype.ushrn=function(j){return this.clone().iushrn(j)},U.prototype.testn=function(j){G(typeof j=="number"&&j>=0);var k=j%26,g=(j-k)/26,_=1<=0);var k=j%26,g=(j-k)/26;if(G(this.negative===0,"imaskn works only with positive numbers"),this.length<=g)return this;if(k!==0&&g++,this.length=Math.min(g,this.length),k!==0){var _=67108863^67108863>>>k<=67108864;k++)this.words[k]-=67108864,k===this.length-1?this.words[k+1]=1:this.words[k+1]++;return this.length=Math.max(this.length,k+1),this},U.prototype.isubn=function(j){if(G(typeof j=="number"),G(j<67108864),j<0)return this.iaddn(-j);if(this.negative!==0)return this.negative=0,this.iaddn(j),this.negative=1,this;if(this.words[0]-=j,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var k=0;k>26)-(y/67108864|0),this.words[N+g]=x&67108863}for(;N>26,this.words[N+g]=x&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,_=this.clone(),N=j,x=N.words[N.length-1]|0,B=this._countBits(x);g=26-B,g!==0&&(N=N.ushln(g),_.iushln(g),x=N.words[N.length-1]|0);var y=_.length-N.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var p=0;p=0;c--){var h=(_.words[N.length+c]|0)*67108864+(_.words[N.length+c-1]|0);for(h=Math.min(h/x|0,67108863),_._ishlnsubmul(N,h,c);_.negative!==0;)h--,_.negative=0,_._ishlnsubmul(N,1,c),_.isZero()||(_.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),_.strip(),k!=="div"&&g!==0&&_.iushrn(g),{div:w||null,mod:_}},U.prototype.divmod=function(j,k,g){if(G(!j.isZero()),this.isZero())return{div:new U(0),mod:new U(0)};var _,N,x;return this.negative!==0&&j.negative===0?(x=this.neg().divmod(j,k),k!=="mod"&&(_=x.div.neg()),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.iadd(j)),{div:_,mod:N}):this.negative===0&&j.negative!==0?(x=this.divmod(j.neg(),k),k!=="mod"&&(_=x.div.neg()),{div:_,mod:x.mod}):(this.negative&j.negative)!==0?(x=this.neg().divmod(j.neg(),k),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.isub(j)),{div:x.div,mod:N}):j.length>this.length||this.cmp(j)<0?{div:new U(0),mod:this}:j.length===1?k==="div"?{div:this.divn(j.words[0]),mod:null}:k==="mod"?{div:null,mod:new U(this.modn(j.words[0]))}:{div:this.divn(j.words[0]),mod:new U(this.modn(j.words[0]))}:this._wordDiv(j,k)},U.prototype.div=function(j){return this.divmod(j,"div",!1).div},U.prototype.mod=function(j){return this.divmod(j,"mod",!1).mod},U.prototype.umod=function(j){return this.divmod(j,"mod",!0).mod},U.prototype.divRound=function(j){var k=this.divmod(j);if(k.mod.isZero())return k.div;var g=k.div.negative!==0?k.mod.isub(j):k.mod,_=j.ushrn(1),N=j.andln(1),x=g.cmp(_);return x<0||N===1&&x===0?k.div:k.div.negative!==0?k.div.isubn(1):k.div.iaddn(1)},U.prototype.modn=function(j){G(j<=67108863);for(var k=(1<<26)%j,g=0,_=this.length-1;_>=0;_--)g=(k*g+(this.words[_]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var _=(this.words[g]|0)+k*67108864;this.words[g]=_/j|0,k=_%j}return this.strip()},U.prototype.divn=function(j){return this.clone().idivn(j)},U.prototype.egcd=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=new U(0),B=new U(1),y=0;k.isEven()&&g.isEven();)k.iushrn(1),g.iushrn(1),++y;for(var w=g.clone(),p=k.clone();!k.isZero();){for(var f=0,c=1;(k.words[0]&c)===0&&f<26;++f,c<<=1);if(f>0)for(k.iushrn(f);f-- >0;)(_.isOdd()||N.isOdd())&&(_.iadd(w),N.isub(p)),_.iushrn(1),N.iushrn(1);for(var h=0,d=1;(g.words[0]&d)===0&&h<26;++h,d<<=1);if(h>0)for(g.iushrn(h);h-- >0;)(x.isOdd()||B.isOdd())&&(x.iadd(w),B.isub(p)),x.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(x),N.isub(B)):(g.isub(k),x.isub(_),B.isub(N))}return{a:x,b:B,gcd:g.iushln(y)}},U.prototype._invmp=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=g.clone();k.cmpn(1)>0&&g.cmpn(1)>0;){for(var B=0,y=1;(k.words[0]&y)===0&&B<26;++B,y<<=1);if(B>0)for(k.iushrn(B);B-- >0;)_.isOdd()&&_.iadd(x),_.iushrn(1);for(var w=0,p=1;(g.words[0]&p)===0&&w<26;++w,p<<=1);if(w>0)for(g.iushrn(w);w-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(N)):(g.isub(k),N.isub(_))}var f;return k.cmpn(1)===0?f=_:f=N,f.cmpn(0)<0&&f.iadd(j),f},U.prototype.gcd=function(j){if(this.isZero())return j.abs();if(j.isZero())return this.abs();var k=this.clone(),g=j.clone();k.negative=0,g.negative=0;for(var _=0;k.isEven()&&g.isEven();_++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var N=k.cmp(g);if(N<0){var x=k;k=g,g=x}else if(N===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(_)},U.prototype.invm=function(j){return this.egcd(j).a.umod(j)},U.prototype.isEven=function(){return(this.words[0]&1)===0},U.prototype.isOdd=function(){return(this.words[0]&1)===1},U.prototype.andln=function(j){return this.words[0]&j},U.prototype.bincn=function(j){G(typeof j=="number");var k=j%26,g=(j-k)/26,_=1<>>26,B&=67108863,this.words[x]=B}return N!==0&&(this.words[x]=N,this.length++),this},U.prototype.isZero=function(){return this.length===1&&this.words[0]===0},U.prototype.cmpn=function(j){var k=j<0;if(this.negative!==0&&!k)return-1;if(this.negative===0&&k)return 1;this.strip();var g;if(this.length>1)g=1;else{k&&(j=-j),G(j<=67108863,"Number is too big");var _=this.words[0]|0;g=_===j?0:_j.length)return 1;if(this.length=0;g--){var _=this.words[g]|0,N=j.words[g]|0;if(_!==N){_N&&(k=1);break}}return k},U.prototype.gtn=function(j){return this.cmpn(j)===1},U.prototype.gt=function(j){return this.cmp(j)===1},U.prototype.gten=function(j){return this.cmpn(j)>=0},U.prototype.gte=function(j){return this.cmp(j)>=0},U.prototype.ltn=function(j){return this.cmpn(j)===-1},U.prototype.lt=function(j){return this.cmp(j)===-1},U.prototype.lten=function(j){return this.cmpn(j)<=0},U.prototype.lte=function(j){return this.cmp(j)<=0},U.prototype.eqn=function(j){return this.cmpn(j)===0},U.prototype.eq=function(j){return this.cmp(j)===0},U.red=function(j){return new v(j)},U.prototype.toRed=function(j){return G(!this.red,"Already a number in reduction context"),G(this.negative===0,"red works only with positives"),j.convertTo(this)._forceRed(j)},U.prototype.fromRed=function(){return G(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},U.prototype._forceRed=function(j){return this.red=j,this},U.prototype.forceRed=function(j){return G(!this.red,"Already a number in reduction context"),this._forceRed(j)},U.prototype.redAdd=function(j){return G(this.red,"redAdd works only with red numbers"),this.red.add(this,j)},U.prototype.redIAdd=function(j){return G(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,j)},U.prototype.redSub=function(j){return G(this.red,"redSub works only with red numbers"),this.red.sub(this,j)},U.prototype.redISub=function(j){return G(this.red,"redISub works only with red numbers"),this.red.isub(this,j)},U.prototype.redShl=function(j){return G(this.red,"redShl works only with red numbers"),this.red.shl(this,j)},U.prototype.redMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.mul(this,j)},U.prototype.redIMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.imul(this,j)},U.prototype.redSqr=function(){return G(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},U.prototype.redISqr=function(){return G(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},U.prototype.redSqrt=function(){return G(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},U.prototype.redInvm=function(){return G(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},U.prototype.redNeg=function(){return G(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},U.prototype.redPow=function(j){return G(this.red&&!j.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,j)};var L={k256:null,p224:null,p192:null,p25519:null};function R(j,k){this.name=j,this.p=new U(k,16),this.n=this.p.bitLength(),this.k=new U(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}R.prototype._tmp=function(){var j=new U(null);return j.words=new Array(Math.ceil(this.n/13)),j},R.prototype.ireduce=function(j){var k=j,g;do this.split(k,this.tmp),k=this.imulK(k),k=k.iadd(this.tmp),g=k.bitLength();while(g>this.n);var _=g0?k.isub(this.p):k.strip!==void 0?k.strip():k._strip(),k},R.prototype.split=function(j,k){j.iushrn(this.n,0,k)},R.prototype.imulK=function(j){return j.imul(this.k)};function P(){R.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}V(P,R),P.prototype.split=function(j,k){for(var g=4194303,_=Math.min(j.length,9),N=0;N<_;N++)k.words[N]=j.words[N];if(k.length=_,j.length<=9){j.words[0]=0,j.length=1;return}var x=j.words[9];for(k.words[k.length++]=x&g,N=10;N>>22,x=B}x>>>=22,j.words[N-10]=x,x===0&&j.length>10?j.length-=10:j.length-=9},P.prototype.imulK=function(j){j.words[j.length]=0,j.words[j.length+1]=0,j.length+=2;for(var k=0,g=0;g>>=26,j.words[g]=N,k=_}return k!==0&&(j.words[j.length++]=k),j},U._prime=function(j){if(L[j])return L[j];var k;if(j==="k256")k=new P;else if(j==="p224")k=new z;else if(j==="p192")k=new M;else if(j==="p25519")k=new S;else throw new Error("Unknown prime "+j);return L[j]=k,k};function v(j){if(typeof j=="string"){var k=U._prime(j);this.m=k.p,this.prime=k}else G(j.gtn(1),"modulus must be greater than 1"),this.m=j,this.prime=null}v.prototype._verify1=function(j){G(j.negative===0,"red works only with positives"),G(j.red,"red works only with red numbers")},v.prototype._verify2=function(j,k){G((j.negative|k.negative)===0,"red works only with positives"),G(j.red&&j.red===k.red,"red works only with red numbers")},v.prototype.imod=function(j){return this.prime?this.prime.ireduce(j)._forceRed(this):j.umod(this.m)._forceRed(this)},v.prototype.neg=function(j){return j.isZero()?j.clone():this.m.sub(j)._forceRed(this)},v.prototype.add=function(j,k){this._verify2(j,k);var g=j.add(k);return g.cmp(this.m)>=0&&g.isub(this.m),g._forceRed(this)},v.prototype.iadd=function(j,k){this._verify2(j,k);var g=j.iadd(k);return g.cmp(this.m)>=0&&g.isub(this.m),g},v.prototype.sub=function(j,k){this._verify2(j,k);var g=j.sub(k);return g.cmpn(0)<0&&g.iadd(this.m),g._forceRed(this)},v.prototype.isub=function(j,k){this._verify2(j,k);var g=j.isub(k);return g.cmpn(0)<0&&g.iadd(this.m),g},v.prototype.shl=function(j,k){return this._verify1(j),this.imod(j.ushln(k))},v.prototype.imul=function(j,k){return this._verify2(j,k),this.imod(j.imul(k))},v.prototype.mul=function(j,k){return this._verify2(j,k),this.imod(j.mul(k))},v.prototype.isqr=function(j){return this.imul(j,j.clone())},v.prototype.sqr=function(j){return this.mul(j,j)},v.prototype.sqrt=function(j){if(j.isZero())return j.clone();var k=this.m.andln(3);if(G(k%2===1),k===3){var g=this.m.add(new U(1)).iushrn(2);return this.pow(j,g)}for(var _=this.m.subn(1),N=0;!_.isZero()&&_.andln(1)===0;)N++,_.iushrn(1);G(!_.isZero());var x=new U(1).toRed(this),B=x.redNeg(),y=this.m.subn(1).iushrn(1),w=this.m.bitLength();for(w=new U(2*w*w).toRed(this);this.pow(w,y).cmp(B)!==0;)w.redIAdd(B);for(var p=this.pow(w,_),f=this.pow(j,_.addn(1).iushrn(1)),c=this.pow(j,_),h=N;c.cmp(x)!==0;){for(var d=c,b=0;d.cmp(x)!==0;b++)d=d.redSqr();G(b=0;N--){for(var p=k.words[N],f=w-1;f>=0;f--){var c=p>>f&1;if(x!==_[0]&&(x=this.sqr(x)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(N!==0||f!==0))&&(x=this.mul(x,_[B]),y=0,B=0)}w=26}return x},v.prototype.convertTo=function(j){var k=j.umod(this.m);return k===j?k.clone():k},v.prototype.convertFrom=function(j){var k=j.clone();return k.red=null,k},U.mont=function(j){return new q(j)};function q(j){v.call(this,j),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new U(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}V(q,v),q.prototype.convertTo=function(j){return this.imod(j.ushln(this.shift))},q.prototype.convertFrom=function(j){var k=this.imod(j.mul(this.rinv));return k.red=null,k},q.prototype.imul=function(j,k){if(j.isZero()||k.isZero())return j.words[0]=0,j.length=1,j;var g=j.imul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.invm=function(j){var k=this.imod(j._invmp(this.m).mul(this.r2));return k._forceRed(this)}})(typeof Q>"u"||Q,$)}}),_Q=q$({"node_modules/miller-rabin/node_modules/bn.js/lib/bn.js"($,Q){(function(Y,Z){function G(j,k){if(!j)throw new Error(k||"Assertion failed")}function V(j,k){j.super_=k;var g=function(){};g.prototype=k.prototype,j.prototype=new g,j.prototype.constructor=j}function U(j,k,g){if(U.isBN(j))return j;this.negative=0,this.words=null,this.length=0,this.red=null,j!==null&&((k==="le"||k==="be")&&(g=k,k=10),this._init(j||0,k||10,g||"be"))}typeof Y=="object"?Y.exports=U:Z.BN=U,U.BN=U,U.wordSize=26;var X=F$;U.isBN=function(j){return j instanceof U?!0:j!==null&&typeof j=="object"&&j.constructor.wordSize===U.wordSize&&Array.isArray(j.words)},U.max=function(j,k){return j.cmp(k)>0?j:k},U.min=function(j,k){return j.cmp(k)<0?j:k},U.prototype._init=function(j,k,g){if(typeof j=="number")return this._initNumber(j,k,g);if(typeof j=="object")return this._initArray(j,k,g);k==="hex"&&(k=16),G(k===(k|0)&&k>=2&&k<=36),j=j.toString().replace(/\s+/g,"");var _=0;j[0]==="-"&&(_++,this.negative=1),_=0;_-=3)x=j[_]|j[_-1]<<8|j[_-2]<<16,this.words[N]|=x<>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);else if(g==="le")for(_=0,N=0;_>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);return this.strip()};function K(j,k){var g=j.charCodeAt(k);return g>=65&&g<=70?g-55:g>=97&&g<=102?g-87:g-48&15}function I(j,k,g){var _=K(j,g);return g-1>=k&&(_|=K(j,g-1)<<4),_}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var _=0;_=k;_-=2)B=I(j,k,_)<=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8;else{var y=j.length-k;for(_=y%2===0?k+1:k;_=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8}this.strip()};function O(j,k,g,_){for(var N=0,x=Math.min(j.length,g),B=k;B=49?N+=y-49+10:y>=17?N+=y-17+10:N+=y}return N}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var _=0,N=1;N<=67108863;N*=k)_++;_--,N=N/k|0;for(var x=j.length-g,B=x%_,y=Math.min(x,x-B)+g,w=0,p=g;p1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},U.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},U.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],F=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],A=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];U.prototype.toString=function(j,k){j=j||10,k=k|0||1;var g;if(j===16||j==="hex"){g="";for(var _=0,N=0,x=0;x>>24-_&16777215,N!==0||x!==this.length-1?g=J[6-y.length]+y+g:g=y+g,_+=2,_>=26&&(_-=26,x--)}for(N!==0&&(g=N.toString(16)+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}if(j===(j|0)&&j>=2&&j<=36){var w=F[j],p=A[j];g="";var f=this.clone();for(f.negative=0;!f.isZero();){var c=f.modn(p).toString(j);f=f.idivn(p),f.isZero()?g=c+g:g=J[w-c.length]+c+g}for(this.isZero()&&(g="0"+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}G(!1,"Base should be between 2 and 36")},U.prototype.toNumber=function(){var j=this.words[0];return this.length===2?j+=this.words[1]*67108864:this.length===3&&this.words[2]===1?j+=4503599627370496+this.words[1]*67108864:this.length>2&&G(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-j:j},U.prototype.toJSON=function(){return this.toString(16)},U.prototype.toBuffer=function(j,k){return G(typeof X<"u"),this.toArrayLike(X,j,k)},U.prototype.toArray=function(j,k){return this.toArrayLike(Array,j,k)},U.prototype.toArrayLike=function(j,k,g){var _=this.byteLength(),N=g||Math.max(1,_);G(_<=N,"byte array longer than desired length"),G(N>0,"Requested array length <= 0"),this.strip();var x=k==="le",B=new j(N),y,w,p=this.clone();if(x){for(w=0;!p.isZero();w++)y=p.andln(255),p.iushrn(8),B[w]=y;for(;w=4096&&(g+=13,k>>>=13),k>=64&&(g+=7,k>>>=7),k>=8&&(g+=4,k>>>=4),k>=2&&(g+=2,k>>>=2),g+k},U.prototype._zeroBits=function(j){if(j===0)return 26;var k=j,g=0;return(k&8191)===0&&(g+=13,k>>>=13),(k&127)===0&&(g+=7,k>>>=7),(k&15)===0&&(g+=4,k>>>=4),(k&3)===0&&(g+=2,k>>>=2),(k&1)===0&&g++,g},U.prototype.bitLength=function(){var j=this.words[this.length-1],k=this._countBits(j);return(this.length-1)*26+k};function H(j){for(var k=new Array(j.bitLength()),g=0;g>>N}return k}U.prototype.zeroBits=function(){if(this.isZero())return 0;for(var j=0,k=0;kj.length?this.clone().ior(j):j.clone().ior(this)},U.prototype.uor=function(j){return this.length>j.length?this.clone().iuor(j):j.clone().iuor(this)},U.prototype.iuand=function(j){var k;this.length>j.length?k=j:k=this;for(var g=0;gj.length?this.clone().iand(j):j.clone().iand(this)},U.prototype.uand=function(j){return this.length>j.length?this.clone().iuand(j):j.clone().iuand(this)},U.prototype.iuxor=function(j){var k,g;this.length>j.length?(k=this,g=j):(k=j,g=this);for(var _=0;_j.length?this.clone().ixor(j):j.clone().ixor(this)},U.prototype.uxor=function(j){return this.length>j.length?this.clone().iuxor(j):j.clone().iuxor(this)},U.prototype.inotn=function(j){G(typeof j=="number"&&j>=0);var k=Math.ceil(j/26)|0,g=j%26;this._expand(k),g>0&&k--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-g),this.strip()},U.prototype.notn=function(j){return this.clone().inotn(j)},U.prototype.setn=function(j,k){G(typeof j=="number"&&j>=0);var g=j/26|0,_=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<<_:this.words[g]=this.words[g]&~(1<<_),this.strip()},U.prototype.iadd=function(j){var k;if(this.negative!==0&&j.negative===0)return this.negative=0,k=this.isub(j),this.negative^=1,this._normSign();if(this.negative===0&&j.negative!==0)return j.negative=0,k=this.isub(j),j.negative=1,k._normSign();var g,_;this.length>j.length?(g=this,_=j):(g=j,_=this);for(var N=0,x=0;x<_.length;x++)k=(g.words[x]|0)+(_.words[x]|0)+N,this.words[x]=k&67108863,N=k>>>26;for(;N!==0&&x>>26;if(this.length=g.length,N!==0)this.words[this.length]=N,this.length++;else if(g!==this)for(;xj.length?this.clone().iadd(j):j.clone().iadd(this)},U.prototype.isub=function(j){if(j.negative!==0){j.negative=0;var k=this.iadd(j);return j.negative=1,k._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(j),this.negative=1,this._normSign();var g=this.cmp(j);if(g===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,N;g>0?(_=this,N=j):(_=j,N=this);for(var x=0,B=0;B>26,this.words[B]=k&67108863;for(;x!==0&&B<_.length;B++)k=(_.words[B]|0)+x,x=k>>26,this.words[B]=k&67108863;if(x===0&&B<_.length&&_!==this)for(;B<_.length;B++)this.words[B]=_.words[B];return this.length=Math.max(this.length,B),_!==this&&(this.negative=1),this.strip()},U.prototype.sub=function(j){return this.clone().isub(j)};function W(j,k,g){g.negative=k.negative^j.negative;var _=j.length+k.length|0;g.length=_,_=_-1|0;var N=j.words[0]|0,x=k.words[0]|0,B=N*x,y=B&67108863,w=B/67108864|0;g.words[0]=y;for(var p=1;p<_;p++){for(var f=w>>>26,c=w&67108863,h=Math.min(p,k.length-1),d=Math.max(0,p-j.length+1);d<=h;d++){var b=p-d|0;N=j.words[b]|0,x=k.words[d]|0,B=N*x+c,f+=B/67108864|0,c=B&67108863}g.words[p]=c|0,w=f|0}return w!==0?g.words[p]=w|0:g.length--,g.strip()}var E=function(j,k,g){var _=j.words,N=k.words,x=g.words,B=0,y,w,p,f=_[0]|0,c=f&8191,h=f>>>13,d=_[1]|0,b=d&8191,l=d>>>13,o=_[2]|0,u=o&8191,n=o>>>13,s=_[3]|0,t=s&8191,m=s>>>13,a=_[4]|0,e=a&8191,r=a>>>13,i=_[5]|0,$0=i&8191,Q0=i>>>13,Y0=_[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=_[7]|0,U0=V0&8191,X0=V0>>>13,K0=_[8]|0,I0=K0&8191,O0=K0>>>13,J0=_[9]|0,F0=J0&8191,A0=J0>>>13,H0=N[0]|0,W0=H0&8191,E0=H0>>>13,T0=N[1]|0,D0=T0&8191,C0=T0>>>13,L0=N[2]|0,R0=L0&8191,P0=L0>>>13,z0=N[3]|0,M0=z0&8191,S0=z0>>>13,v0=N[4]|0,q0=v0&8191,j0=v0>>>13,k0=N[5]|0,g0=k0&8191,_0=k0>>>13,N0=N[6]|0,x0=N0&8191,B0=N0>>>13,y0=N[7]|0,w0=y0&8191,p0=y0>>>13,f0=N[8]|0,c0=f0&8191,h0=f0>>>13,d0=N[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,W0),w=Math.imul(c,E0),w=w+Math.imul(h,W0)|0,p=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,W0),w=Math.imul(b,E0),w=w+Math.imul(l,W0)|0,p=Math.imul(l,E0),y=y+Math.imul(c,D0)|0,w=w+Math.imul(c,C0)|0,w=w+Math.imul(h,D0)|0,p=p+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,W0),w=Math.imul(u,E0),w=w+Math.imul(n,W0)|0,p=Math.imul(n,E0),y=y+Math.imul(b,D0)|0,w=w+Math.imul(b,C0)|0,w=w+Math.imul(l,D0)|0,p=p+Math.imul(l,C0)|0,y=y+Math.imul(c,R0)|0,w=w+Math.imul(c,P0)|0,w=w+Math.imul(h,R0)|0,p=p+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,W0),w=Math.imul(t,E0),w=w+Math.imul(m,W0)|0,p=Math.imul(m,E0),y=y+Math.imul(u,D0)|0,w=w+Math.imul(u,C0)|0,w=w+Math.imul(n,D0)|0,p=p+Math.imul(n,C0)|0,y=y+Math.imul(b,R0)|0,w=w+Math.imul(b,P0)|0,w=w+Math.imul(l,R0)|0,p=p+Math.imul(l,P0)|0,y=y+Math.imul(c,M0)|0,w=w+Math.imul(c,S0)|0,w=w+Math.imul(h,M0)|0,p=p+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(e,W0),w=Math.imul(e,E0),w=w+Math.imul(r,W0)|0,p=Math.imul(r,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,p=p+Math.imul(m,C0)|0,y=y+Math.imul(u,R0)|0,w=w+Math.imul(u,P0)|0,w=w+Math.imul(n,R0)|0,p=p+Math.imul(n,P0)|0,y=y+Math.imul(b,M0)|0,w=w+Math.imul(b,S0)|0,w=w+Math.imul(l,M0)|0,p=p+Math.imul(l,S0)|0,y=y+Math.imul(c,q0)|0,w=w+Math.imul(c,j0)|0,w=w+Math.imul(h,q0)|0,p=p+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,W0),w=Math.imul($0,E0),w=w+Math.imul(Q0,W0)|0,p=Math.imul(Q0,E0),y=y+Math.imul(e,D0)|0,w=w+Math.imul(e,C0)|0,w=w+Math.imul(r,D0)|0,p=p+Math.imul(r,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,p=p+Math.imul(m,P0)|0,y=y+Math.imul(u,M0)|0,w=w+Math.imul(u,S0)|0,w=w+Math.imul(n,M0)|0,p=p+Math.imul(n,S0)|0,y=y+Math.imul(b,q0)|0,w=w+Math.imul(b,j0)|0,w=w+Math.imul(l,q0)|0,p=p+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,_0)|0,w=w+Math.imul(h,g0)|0,p=p+Math.imul(h,_0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,W0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,W0)|0,p=Math.imul(G0,E0),y=y+Math.imul($0,D0)|0,w=w+Math.imul($0,C0)|0,w=w+Math.imul(Q0,D0)|0,p=p+Math.imul(Q0,C0)|0,y=y+Math.imul(e,R0)|0,w=w+Math.imul(e,P0)|0,w=w+Math.imul(r,R0)|0,p=p+Math.imul(r,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,p=p+Math.imul(m,S0)|0,y=y+Math.imul(u,q0)|0,w=w+Math.imul(u,j0)|0,w=w+Math.imul(n,q0)|0,p=p+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,_0)|0,w=w+Math.imul(l,g0)|0,p=p+Math.imul(l,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,x0)|0,p=p+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,W0),w=Math.imul(U0,E0),w=w+Math.imul(X0,W0)|0,p=Math.imul(X0,E0),y=y+Math.imul(Z0,D0)|0,w=w+Math.imul(Z0,C0)|0,w=w+Math.imul(G0,D0)|0,p=p+Math.imul(G0,C0)|0,y=y+Math.imul($0,R0)|0,w=w+Math.imul($0,P0)|0,w=w+Math.imul(Q0,R0)|0,p=p+Math.imul(Q0,P0)|0,y=y+Math.imul(e,M0)|0,w=w+Math.imul(e,S0)|0,w=w+Math.imul(r,M0)|0,p=p+Math.imul(r,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,p=p+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,_0)|0,w=w+Math.imul(n,g0)|0,p=p+Math.imul(n,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,x0)|0,p=p+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,p0)|0,w=w+Math.imul(h,w0)|0,p=p+Math.imul(h,p0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(I0,W0),w=Math.imul(I0,E0),w=w+Math.imul(O0,W0)|0,p=Math.imul(O0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,p=p+Math.imul(X0,C0)|0,y=y+Math.imul(Z0,R0)|0,w=w+Math.imul(Z0,P0)|0,w=w+Math.imul(G0,R0)|0,p=p+Math.imul(G0,P0)|0,y=y+Math.imul($0,M0)|0,w=w+Math.imul($0,S0)|0,w=w+Math.imul(Q0,M0)|0,p=p+Math.imul(Q0,S0)|0,y=y+Math.imul(e,q0)|0,w=w+Math.imul(e,j0)|0,w=w+Math.imul(r,q0)|0,p=p+Math.imul(r,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,_0)|0,w=w+Math.imul(m,g0)|0,p=p+Math.imul(m,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,x0)|0,p=p+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,p0)|0,w=w+Math.imul(l,w0)|0,p=p+Math.imul(l,p0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,p=p+Math.imul(h,h0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(F0,W0),w=Math.imul(F0,E0),w=w+Math.imul(A0,W0)|0,p=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(O0,D0)|0,p=p+Math.imul(O0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,p=p+Math.imul(X0,P0)|0,y=y+Math.imul(Z0,M0)|0,w=w+Math.imul(Z0,S0)|0,w=w+Math.imul(G0,M0)|0,p=p+Math.imul(G0,S0)|0,y=y+Math.imul($0,q0)|0,w=w+Math.imul($0,j0)|0,w=w+Math.imul(Q0,q0)|0,p=p+Math.imul(Q0,j0)|0,y=y+Math.imul(e,g0)|0,w=w+Math.imul(e,_0)|0,w=w+Math.imul(r,g0)|0,p=p+Math.imul(r,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,x0)|0,p=p+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,p0)|0,w=w+Math.imul(n,w0)|0,p=p+Math.imul(n,p0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,p=p+Math.imul(l,h0)|0,y=y+Math.imul(c,b0)|0,w=w+Math.imul(c,l0)|0,w=w+Math.imul(h,b0)|0,p=p+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(i0>>>26)|0,i0&=67108863,y=Math.imul(F0,D0),w=Math.imul(F0,C0),w=w+Math.imul(A0,D0)|0,p=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(O0,R0)|0,p=p+Math.imul(O0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,p=p+Math.imul(X0,S0)|0,y=y+Math.imul(Z0,q0)|0,w=w+Math.imul(Z0,j0)|0,w=w+Math.imul(G0,q0)|0,p=p+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,_0)|0,w=w+Math.imul(Q0,g0)|0,p=p+Math.imul(Q0,_0)|0,y=y+Math.imul(e,x0)|0,w=w+Math.imul(e,B0)|0,w=w+Math.imul(r,x0)|0,p=p+Math.imul(r,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,p0)|0,w=w+Math.imul(m,w0)|0,p=p+Math.imul(m,p0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,p=p+Math.imul(n,h0)|0,y=y+Math.imul(b,b0)|0,w=w+Math.imul(b,l0)|0,w=w+Math.imul(l,b0)|0,p=p+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,p=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(O0,M0)|0,p=p+Math.imul(O0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,p=p+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,_0)|0,w=w+Math.imul(G0,g0)|0,p=p+Math.imul(G0,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,x0)|0,p=p+Math.imul(Q0,B0)|0,y=y+Math.imul(e,w0)|0,w=w+Math.imul(e,p0)|0,w=w+Math.imul(r,w0)|0,p=p+Math.imul(r,p0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,p=p+Math.imul(m,h0)|0,y=y+Math.imul(u,b0)|0,w=w+Math.imul(u,l0)|0,w=w+Math.imul(n,b0)|0,p=p+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,y=Math.imul(F0,M0),w=Math.imul(F0,S0),w=w+Math.imul(A0,M0)|0,p=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(O0,q0)|0,p=p+Math.imul(O0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,_0)|0,w=w+Math.imul(X0,g0)|0,p=p+Math.imul(X0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,x0)|0,p=p+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,p0)|0,w=w+Math.imul(Q0,w0)|0,p=p+Math.imul(Q0,p0)|0,y=y+Math.imul(e,c0)|0,w=w+Math.imul(e,h0)|0,w=w+Math.imul(r,c0)|0,p=p+Math.imul(r,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,p=p+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,y=Math.imul(F0,q0),w=Math.imul(F0,j0),w=w+Math.imul(A0,q0)|0,p=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,_0)|0,w=w+Math.imul(O0,g0)|0,p=p+Math.imul(O0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,x0)|0,p=p+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,p0)|0,w=w+Math.imul(G0,w0)|0,p=p+Math.imul(G0,p0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,p=p+Math.imul(Q0,h0)|0,y=y+Math.imul(e,b0)|0,w=w+Math.imul(e,l0)|0,w=w+Math.imul(r,b0)|0,p=p+Math.imul(r,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,_0),w=w+Math.imul(A0,g0)|0,p=Math.imul(A0,_0),y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(O0,x0)|0,p=p+Math.imul(O0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,p0)|0,w=w+Math.imul(X0,w0)|0,p=p+Math.imul(X0,p0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,p=p+Math.imul(G0,h0)|0,y=y+Math.imul($0,b0)|0,w=w+Math.imul($0,l0)|0,w=w+Math.imul(Q0,b0)|0,p=p+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,x0),w=Math.imul(F0,B0),w=w+Math.imul(A0,x0)|0,p=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,p0)|0,w=w+Math.imul(O0,w0)|0,p=p+Math.imul(O0,p0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,p=p+Math.imul(X0,h0)|0,y=y+Math.imul(Z0,b0)|0,w=w+Math.imul(Z0,l0)|0,w=w+Math.imul(G0,b0)|0,p=p+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,p0),w=w+Math.imul(A0,w0)|0,p=Math.imul(A0,p0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(O0,c0)|0,p=p+Math.imul(O0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,p=p+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(U$>>>26)|0,U$&=67108863,y=Math.imul(F0,c0),w=Math.imul(F0,h0),w=w+Math.imul(A0,c0)|0,p=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(O0,b0)|0,p=p+Math.imul(O0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(X$>>>26)|0,X$&=67108863,y=Math.imul(F0,b0),w=Math.imul(F0,l0),w=w+Math.imul(A0,b0)|0,p=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(p+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,x[0]=o0,x[1]=u0,x[2]=n0,x[3]=s0,x[4]=t0,x[5]=m0,x[6]=a0,x[7]=e0,x[8]=r0,x[9]=i0,x[10]=$$,x[11]=Q$,x[12]=Y$,x[13]=Z$,x[14]=G$,x[15]=V$,x[16]=U$,x[17]=X$,x[18]=K$,B!==0&&(x[19]=B,g.length++),g};Math.imul||(E=W);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var _=0,N=0,x=0;x>>26)|0,N+=B>>>26,B&=67108863}g.words[x]=y,_=B,B=N}return _!==0?g.words[x]=_:g.length--,g.strip()}function D(j,k,g){var _=new C;return _.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,_=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):_<63?g=W(this,j,k):_<1024?g=T(this,j,k):g=D(this,j,k),g};function C(j,k){this.x=j,this.y=k}C.prototype.makeRBT=function(j){for(var k=new Array(j),g=U.prototype._countBits(j)-1,_=0;_>=1;return _},C.prototype.permute=function(j,k,g,_,N,x){for(var B=0;B>>1)N++;return 1<>>13,g[2*x+1]=N&8191,N=N>>>13;for(x=2*k;x<_;++x)g[x]=0;G(N===0),G((N&-8192)===0)},C.prototype.stub=function(j){for(var k=new Array(j),g=0;g>=26,k+=_/67108864|0,k+=N>>>26,this.words[g]=N&67108863}return k!==0&&(this.words[g]=k,this.length++),this},U.prototype.muln=function(j){return this.clone().imuln(j)},U.prototype.sqr=function(){return this.mul(this)},U.prototype.isqr=function(){return this.imul(this.clone())},U.prototype.pow=function(j){var k=H(j);if(k.length===0)return new U(1);for(var g=this,_=0;_=0);var k=j%26,g=(j-k)/26,_=67108863>>>26-k<<26-k,N;if(k!==0){var x=0;for(N=0;N>>26-k}x&&(this.words[N]=x,this.length++)}if(g!==0){for(N=this.length-1;N>=0;N--)this.words[N+g]=this.words[N];for(N=0;N=0);var _;k?_=(k-k%26)/26:_=0;var N=j%26,x=Math.min((j-N)/26,this.length),B=67108863^67108863>>>N<x)for(this.length-=x,w=0;w=0&&(p!==0||w>=_);w--){var f=this.words[w]|0;this.words[w]=p<<26-N|f>>>N,p=f&B}return y&&p!==0&&(y.words[y.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},U.prototype.ishrn=function(j,k,g){return G(this.negative===0),this.iushrn(j,k,g)},U.prototype.shln=function(j){return this.clone().ishln(j)},U.prototype.ushln=function(j){return this.clone().iushln(j)},U.prototype.shrn=function(j){return this.clone().ishrn(j)},U.prototype.ushrn=function(j){return this.clone().iushrn(j)},U.prototype.testn=function(j){G(typeof j=="number"&&j>=0);var k=j%26,g=(j-k)/26,_=1<=0);var k=j%26,g=(j-k)/26;if(G(this.negative===0,"imaskn works only with positive numbers"),this.length<=g)return this;if(k!==0&&g++,this.length=Math.min(g,this.length),k!==0){var _=67108863^67108863>>>k<=67108864;k++)this.words[k]-=67108864,k===this.length-1?this.words[k+1]=1:this.words[k+1]++;return this.length=Math.max(this.length,k+1),this},U.prototype.isubn=function(j){if(G(typeof j=="number"),G(j<67108864),j<0)return this.iaddn(-j);if(this.negative!==0)return this.negative=0,this.iaddn(j),this.negative=1,this;if(this.words[0]-=j,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var k=0;k>26)-(y/67108864|0),this.words[N+g]=x&67108863}for(;N>26,this.words[N+g]=x&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,_=this.clone(),N=j,x=N.words[N.length-1]|0,B=this._countBits(x);g=26-B,g!==0&&(N=N.ushln(g),_.iushln(g),x=N.words[N.length-1]|0);var y=_.length-N.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var p=0;p=0;c--){var h=(_.words[N.length+c]|0)*67108864+(_.words[N.length+c-1]|0);for(h=Math.min(h/x|0,67108863),_._ishlnsubmul(N,h,c);_.negative!==0;)h--,_.negative=0,_._ishlnsubmul(N,1,c),_.isZero()||(_.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),_.strip(),k!=="div"&&g!==0&&_.iushrn(g),{div:w||null,mod:_}},U.prototype.divmod=function(j,k,g){if(G(!j.isZero()),this.isZero())return{div:new U(0),mod:new U(0)};var _,N,x;return this.negative!==0&&j.negative===0?(x=this.neg().divmod(j,k),k!=="mod"&&(_=x.div.neg()),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.iadd(j)),{div:_,mod:N}):this.negative===0&&j.negative!==0?(x=this.divmod(j.neg(),k),k!=="mod"&&(_=x.div.neg()),{div:_,mod:x.mod}):(this.negative&j.negative)!==0?(x=this.neg().divmod(j.neg(),k),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.isub(j)),{div:x.div,mod:N}):j.length>this.length||this.cmp(j)<0?{div:new U(0),mod:this}:j.length===1?k==="div"?{div:this.divn(j.words[0]),mod:null}:k==="mod"?{div:null,mod:new U(this.modn(j.words[0]))}:{div:this.divn(j.words[0]),mod:new U(this.modn(j.words[0]))}:this._wordDiv(j,k)},U.prototype.div=function(j){return this.divmod(j,"div",!1).div},U.prototype.mod=function(j){return this.divmod(j,"mod",!1).mod},U.prototype.umod=function(j){return this.divmod(j,"mod",!0).mod},U.prototype.divRound=function(j){var k=this.divmod(j);if(k.mod.isZero())return k.div;var g=k.div.negative!==0?k.mod.isub(j):k.mod,_=j.ushrn(1),N=j.andln(1),x=g.cmp(_);return x<0||N===1&&x===0?k.div:k.div.negative!==0?k.div.isubn(1):k.div.iaddn(1)},U.prototype.modn=function(j){G(j<=67108863);for(var k=(1<<26)%j,g=0,_=this.length-1;_>=0;_--)g=(k*g+(this.words[_]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var _=(this.words[g]|0)+k*67108864;this.words[g]=_/j|0,k=_%j}return this.strip()},U.prototype.divn=function(j){return this.clone().idivn(j)},U.prototype.egcd=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=new U(0),B=new U(1),y=0;k.isEven()&&g.isEven();)k.iushrn(1),g.iushrn(1),++y;for(var w=g.clone(),p=k.clone();!k.isZero();){for(var f=0,c=1;(k.words[0]&c)===0&&f<26;++f,c<<=1);if(f>0)for(k.iushrn(f);f-- >0;)(_.isOdd()||N.isOdd())&&(_.iadd(w),N.isub(p)),_.iushrn(1),N.iushrn(1);for(var h=0,d=1;(g.words[0]&d)===0&&h<26;++h,d<<=1);if(h>0)for(g.iushrn(h);h-- >0;)(x.isOdd()||B.isOdd())&&(x.iadd(w),B.isub(p)),x.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(x),N.isub(B)):(g.isub(k),x.isub(_),B.isub(N))}return{a:x,b:B,gcd:g.iushln(y)}},U.prototype._invmp=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=g.clone();k.cmpn(1)>0&&g.cmpn(1)>0;){for(var B=0,y=1;(k.words[0]&y)===0&&B<26;++B,y<<=1);if(B>0)for(k.iushrn(B);B-- >0;)_.isOdd()&&_.iadd(x),_.iushrn(1);for(var w=0,p=1;(g.words[0]&p)===0&&w<26;++w,p<<=1);if(w>0)for(g.iushrn(w);w-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(N)):(g.isub(k),N.isub(_))}var f;return k.cmpn(1)===0?f=_:f=N,f.cmpn(0)<0&&f.iadd(j),f},U.prototype.gcd=function(j){if(this.isZero())return j.abs();if(j.isZero())return this.abs();var k=this.clone(),g=j.clone();k.negative=0,g.negative=0;for(var _=0;k.isEven()&&g.isEven();_++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var N=k.cmp(g);if(N<0){var x=k;k=g,g=x}else if(N===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(_)},U.prototype.invm=function(j){return this.egcd(j).a.umod(j)},U.prototype.isEven=function(){return(this.words[0]&1)===0},U.prototype.isOdd=function(){return(this.words[0]&1)===1},U.prototype.andln=function(j){return this.words[0]&j},U.prototype.bincn=function(j){G(typeof j=="number");var k=j%26,g=(j-k)/26,_=1<>>26,B&=67108863,this.words[x]=B}return N!==0&&(this.words[x]=N,this.length++),this},U.prototype.isZero=function(){return this.length===1&&this.words[0]===0},U.prototype.cmpn=function(j){var k=j<0;if(this.negative!==0&&!k)return-1;if(this.negative===0&&k)return 1;this.strip();var g;if(this.length>1)g=1;else{k&&(j=-j),G(j<=67108863,"Number is too big");var _=this.words[0]|0;g=_===j?0:_j.length)return 1;if(this.length=0;g--){var _=this.words[g]|0,N=j.words[g]|0;if(_!==N){_N&&(k=1);break}}return k},U.prototype.gtn=function(j){return this.cmpn(j)===1},U.prototype.gt=function(j){return this.cmp(j)===1},U.prototype.gten=function(j){return this.cmpn(j)>=0},U.prototype.gte=function(j){return this.cmp(j)>=0},U.prototype.ltn=function(j){return this.cmpn(j)===-1},U.prototype.lt=function(j){return this.cmp(j)===-1},U.prototype.lten=function(j){return this.cmpn(j)<=0},U.prototype.lte=function(j){return this.cmp(j)<=0},U.prototype.eqn=function(j){return this.cmpn(j)===0},U.prototype.eq=function(j){return this.cmp(j)===0},U.red=function(j){return new v(j)},U.prototype.toRed=function(j){return G(!this.red,"Already a number in reduction context"),G(this.negative===0,"red works only with positives"),j.convertTo(this)._forceRed(j)},U.prototype.fromRed=function(){return G(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},U.prototype._forceRed=function(j){return this.red=j,this},U.prototype.forceRed=function(j){return G(!this.red,"Already a number in reduction context"),this._forceRed(j)},U.prototype.redAdd=function(j){return G(this.red,"redAdd works only with red numbers"),this.red.add(this,j)},U.prototype.redIAdd=function(j){return G(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,j)},U.prototype.redSub=function(j){return G(this.red,"redSub works only with red numbers"),this.red.sub(this,j)},U.prototype.redISub=function(j){return G(this.red,"redISub works only with red numbers"),this.red.isub(this,j)},U.prototype.redShl=function(j){return G(this.red,"redShl works only with red numbers"),this.red.shl(this,j)},U.prototype.redMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.mul(this,j)},U.prototype.redIMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.imul(this,j)},U.prototype.redSqr=function(){return G(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},U.prototype.redISqr=function(){return G(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},U.prototype.redSqrt=function(){return G(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},U.prototype.redInvm=function(){return G(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},U.prototype.redNeg=function(){return G(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},U.prototype.redPow=function(j){return G(this.red&&!j.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,j)};var L={k256:null,p224:null,p192:null,p25519:null};function R(j,k){this.name=j,this.p=new U(k,16),this.n=this.p.bitLength(),this.k=new U(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}R.prototype._tmp=function(){var j=new U(null);return j.words=new Array(Math.ceil(this.n/13)),j},R.prototype.ireduce=function(j){var k=j,g;do this.split(k,this.tmp),k=this.imulK(k),k=k.iadd(this.tmp),g=k.bitLength();while(g>this.n);var _=g0?k.isub(this.p):k.strip!==void 0?k.strip():k._strip(),k},R.prototype.split=function(j,k){j.iushrn(this.n,0,k)},R.prototype.imulK=function(j){return j.imul(this.k)};function P(){R.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}V(P,R),P.prototype.split=function(j,k){for(var g=4194303,_=Math.min(j.length,9),N=0;N<_;N++)k.words[N]=j.words[N];if(k.length=_,j.length<=9){j.words[0]=0,j.length=1;return}var x=j.words[9];for(k.words[k.length++]=x&g,N=10;N>>22,x=B}x>>>=22,j.words[N-10]=x,x===0&&j.length>10?j.length-=10:j.length-=9},P.prototype.imulK=function(j){j.words[j.length]=0,j.words[j.length+1]=0,j.length+=2;for(var k=0,g=0;g>>=26,j.words[g]=N,k=_}return k!==0&&(j.words[j.length++]=k),j},U._prime=function(j){if(L[j])return L[j];var k;if(j==="k256")k=new P;else if(j==="p224")k=new z;else if(j==="p192")k=new M;else if(j==="p25519")k=new S;else throw new Error("Unknown prime "+j);return L[j]=k,k};function v(j){if(typeof j=="string"){var k=U._prime(j);this.m=k.p,this.prime=k}else G(j.gtn(1),"modulus must be greater than 1"),this.m=j,this.prime=null}v.prototype._verify1=function(j){G(j.negative===0,"red works only with positives"),G(j.red,"red works only with red numbers")},v.prototype._verify2=function(j,k){G((j.negative|k.negative)===0,"red works only with positives"),G(j.red&&j.red===k.red,"red works only with red numbers")},v.prototype.imod=function(j){return this.prime?this.prime.ireduce(j)._forceRed(this):j.umod(this.m)._forceRed(this)},v.prototype.neg=function(j){return j.isZero()?j.clone():this.m.sub(j)._forceRed(this)},v.prototype.add=function(j,k){this._verify2(j,k);var g=j.add(k);return g.cmp(this.m)>=0&&g.isub(this.m),g._forceRed(this)},v.prototype.iadd=function(j,k){this._verify2(j,k);var g=j.iadd(k);return g.cmp(this.m)>=0&&g.isub(this.m),g},v.prototype.sub=function(j,k){this._verify2(j,k);var g=j.sub(k);return g.cmpn(0)<0&&g.iadd(this.m),g._forceRed(this)},v.prototype.isub=function(j,k){this._verify2(j,k);var g=j.isub(k);return g.cmpn(0)<0&&g.iadd(this.m),g},v.prototype.shl=function(j,k){return this._verify1(j),this.imod(j.ushln(k))},v.prototype.imul=function(j,k){return this._verify2(j,k),this.imod(j.imul(k))},v.prototype.mul=function(j,k){return this._verify2(j,k),this.imod(j.mul(k))},v.prototype.isqr=function(j){return this.imul(j,j.clone())},v.prototype.sqr=function(j){return this.mul(j,j)},v.prototype.sqrt=function(j){if(j.isZero())return j.clone();var k=this.m.andln(3);if(G(k%2===1),k===3){var g=this.m.add(new U(1)).iushrn(2);return this.pow(j,g)}for(var _=this.m.subn(1),N=0;!_.isZero()&&_.andln(1)===0;)N++,_.iushrn(1);G(!_.isZero());var x=new U(1).toRed(this),B=x.redNeg(),y=this.m.subn(1).iushrn(1),w=this.m.bitLength();for(w=new U(2*w*w).toRed(this);this.pow(w,y).cmp(B)!==0;)w.redIAdd(B);for(var p=this.pow(w,_),f=this.pow(j,_.addn(1).iushrn(1)),c=this.pow(j,_),h=N;c.cmp(x)!==0;){for(var d=c,b=0;d.cmp(x)!==0;b++)d=d.redSqr();G(b=0;N--){for(var p=k.words[N],f=w-1;f>=0;f--){var c=p>>f&1;if(x!==_[0]&&(x=this.sqr(x)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(N!==0||f!==0))&&(x=this.mul(x,_[B]),y=0,B=0)}w=26}return x},v.prototype.convertTo=function(j){var k=j.umod(this.m);return k===j?k.clone():k},v.prototype.convertFrom=function(j){var k=j.clone();return k.red=null,k},U.mont=function(j){return new q(j)};function q(j){v.call(this,j),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new U(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}V(q,v),q.prototype.convertTo=function(j){return this.imod(j.ushln(this.shift))},q.prototype.convertFrom=function(j){var k=this.imod(j.mul(this.rinv));return k.red=null,k},q.prototype.imul=function(j,k){if(j.isZero()||k.isZero())return j.words[0]=0,j.length=1,j;var g=j.imul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.invm=function(j){var k=this.imod(j._invmp(this.m).mul(this.r2));return k._forceRed(this)}})(typeof Q>"u"||Q,$)}}),NQ=q$({"(disabled):node_modules/crypto-browserify/index.js"(){}}),xQ=q$({"node_modules/brorand/index.js"($,Q){var Y;Q.exports=function(G){return Y||(Y=new Z(null)),Y.generate(G)};function Z(G){this.rand=G}Q.exports.Rand=Z,Z.prototype.generate=function(G){return this._rand(G)},Z.prototype._rand=function(G){var V=new F$(G);return H$.getRandomValues(V),V}}}),BQ=q$({"node_modules/miller-rabin/lib/mr.js"($,Q){var Y=_Q(),Z=xQ();function G(V){this.rand=V||new Z.Rand}Q.exports=G,G.create=function(V){return new G(V)},G.prototype._randbelow=function(V){var U=V.bitLength(),X=Math.ceil(U/8);do var K=new Y(this.rand.generate(X));while(K.cmp(V)>=0);return K},G.prototype._randrange=function(V,U){var X=U.sub(V);return V.add(this._randbelow(X))},G.prototype.test=function(V,U,X){var K=V.bitLength(),I=Y.mont(V),O=new Y(1).toRed(I);U||(U=Math.max(1,K/48|0));for(var J=V.subn(1),F=0;!J.testn(F);F++);for(var A=V.shrn(F),H=J.toRed(I),W=!0;U>0;U--){var E=this._randrange(new Y(2),J);X&&X(E);var T=E.toRed(I).redPow(A);if(!(T.cmp(O)===0||T.cmp(H)===0)){for(var D=1;D0;U--){var H=this._randrange(new Y(2),O),W=V.gcd(H);if(W.cmpn(1)!==0)return W;var E=H.toRed(K).redPow(F);if(!(E.cmp(I)===0||E.cmp(A)===0)){for(var T=1;Tz;)S.ishrn(1);if(S.isEven()&&S.iadd(X),S.testn(1)||S.iadd(K),M.cmp(K)){if(!M.cmp(I))for(;S.mod(F).cmp(A);)S.iadd(E)}else for(;S.mod(G).cmp(W);)S.iadd(E);if(v=S.shrn(1),L(v)&&L(S)&&R(v)&&R(S)&&U.test(v)&&U.test(S))return S}}}}),wQ=q$({"node_modules/diffie-hellman/lib/primes.json"($,Q){Q.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}}}),pQ=q$({"node_modules/diffie-hellman/lib/dh.js"($,Q){var Y=gQ(),Z=BQ(),G=new Z,V=new Y(24),U=new Y(11),X=new Y(10),K=new Y(3),I=new Y(7),O=yQ(),J=g$();Q.exports=E;function F(D,C){return C=C||"utf8",F$.isBuffer(D)||(D=new F$(D,C)),this._pub=new Y(D),this}function A(D,C){return C=C||"utf8",F$.isBuffer(D)||(D=new F$(D,C)),this._priv=new Y(D),this}var H={};function W(D,C){var L=C.toString("hex"),R=[L,D.toString(16)].join("_");if(R in H)return H[R];var P=0;if(D.isEven()||!O.simpleSieve||!O.fermatTest(D)||!G.test(D))return P+=1,L==="02"||L==="05"?P+=8:P+=4,H[R]=P,P;G.test(D.shrn(1))||(P+=2);var z;switch(L){case"02":D.mod(V).cmp(U)&&(P+=8);break;case"05":z=D.mod(X),z.cmp(K)&&z.cmp(I)&&(P+=8);break;default:P+=4}return H[R]=P,P}function E(D,C,L){this.setGenerator(C),this.__prime=new Y(D),this._prime=Y.mont(this.__prime),this._primeLen=D.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,L?(this.setPublicKey=F,this.setPrivateKey=A):this._primeCode=8}Object.defineProperty(E.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=W(this.__prime,this.__gen)),this._primeCode}}),E.prototype.generateKeys=function(){return this._priv||(this._priv=new Y(J(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},E.prototype.computeSecret=function(D){D=new Y(D),D=D.toRed(this._prime);var C=D.redPow(this._priv).fromRed(),L=new F$(C.toArray()),R=this.getPrime();if(L.length0?_:N},U.min=function(_,N){return _.cmp(N)<0?_:N},U.prototype._init=function(_,N,x){if(typeof _=="number")return this._initNumber(_,N,x);if(typeof _=="object")return this._initArray(_,N,x);N==="hex"&&(N=16),G(N===(N|0)&&N>=2&&N<=36),_=_.toString().replace(/\s+/g,"");var B=0;_[0]==="-"&&(B++,this.negative=1),B<_.length&&(N===16?this._parseHex(_,B,x):(this._parseBase(_,N,B),x==="le"&&this._initArray(this.toArray(),N,x)))},U.prototype._initNumber=function(_,N,x){_<0&&(this.negative=1,_=-_),_<67108864?(this.words=[_&67108863],this.length=1):_<4503599627370496?(this.words=[_&67108863,_/67108864&67108863],this.length=2):(G(_<9007199254740992),this.words=[_&67108863,_/67108864&67108863,1],this.length=3),x==="le"&&this._initArray(this.toArray(),N,x)},U.prototype._initArray=function(_,N,x){if(G(typeof _.length=="number"),_.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(_.length/3),this.words=new Array(this.length);for(var B=0;B=0;B-=3)w=_[B]|_[B-1]<<8|_[B-2]<<16,this.words[y]|=w<>>26-p&67108863,p+=24,p>=26&&(p-=26,y++);else if(x==="le")for(B=0,y=0;B<_.length;B+=3)w=_[B]|_[B+1]<<8|_[B+2]<<16,this.words[y]|=w<>>26-p&67108863,p+=24,p>=26&&(p-=26,y++);return this._strip()};function K(_,N){var x=_.charCodeAt(N);if(x>=48&&x<=57)return x-48;if(x>=65&&x<=70)return x-55;if(x>=97&&x<=102)return x-87;G(!1,"Invalid character in "+_)}function I(_,N,x){var B=K(_,x);return x-1>=N&&(B|=K(_,x-1)<<4),B}U.prototype._parseHex=function(_,N,x){this.length=Math.ceil((_.length-N)/6),this.words=new Array(this.length);for(var B=0;B=N;B-=2)p=I(_,N,B)<=18?(y-=18,w+=1,this.words[w]|=p>>>26):y+=8;else{var f=_.length-N;for(B=f%2===0?N+1:N;B<_.length;B+=2)p=I(_,N,B)<=18?(y-=18,w+=1,this.words[w]|=p>>>26):y+=8}this._strip()};function O(_,N,x,B){for(var y=0,w=0,p=Math.min(_.length,x),f=N;f=49?w=c-49+10:c>=17?w=c-17+10:w=c,G(c>=0&&w1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},U.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{U.prototype[Symbol.for("nodejs.util.inspect.custom")]=F}catch{U.prototype.inspect=F}else U.prototype.inspect=F;function F(){return(this.red?""}var A=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],H=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],W=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];U.prototype.toString=function(_,N){_=_||10,N=N|0||1;var x;if(_===16||_==="hex"){x="";for(var B=0,y=0,w=0;w>>24-B&16777215,B+=2,B>=26&&(B-=26,w--),y!==0||w!==this.length-1?x=A[6-f.length]+f+x:x=f+x}for(y!==0&&(x=y.toString(16)+x);x.length%N!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}if(_===(_|0)&&_>=2&&_<=36){var c=H[_],h=W[_];x="";var d=this.clone();for(d.negative=0;!d.isZero();){var b=d.modrn(h).toString(_);d=d.idivn(h),d.isZero()?x=b+x:x=A[c-b.length]+b+x}for(this.isZero()&&(x="0"+x);x.length%N!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}G(!1,"Base should be between 2 and 36")},U.prototype.toNumber=function(){var _=this.words[0];return this.length===2?_+=this.words[1]*67108864:this.length===3&&this.words[2]===1?_+=4503599627370496+this.words[1]*67108864:this.length>2&&G(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-_:_},U.prototype.toJSON=function(){return this.toString(16,2)},X&&(U.prototype.toBuffer=function(_,N){return this.toArrayLike(X,_,N)}),U.prototype.toArray=function(_,N){return this.toArrayLike(Array,_,N)};var E=function(_,N){return _.allocUnsafe?_.allocUnsafe(N):new _(N)};U.prototype.toArrayLike=function(_,N,x){this._strip();var B=this.byteLength(),y=x||Math.max(1,B);G(B<=y,"byte array longer than desired length"),G(y>0,"Requested array length <= 0");var w=E(_,y),p=N==="le"?"LE":"BE";return this["_toArrayLike"+p](w,B),w},U.prototype._toArrayLikeLE=function(_,N){for(var x=0,B=0,y=0,w=0;y>8&255),x<_.length&&(_[x++]=p>>16&255),w===6?(x<_.length&&(_[x++]=p>>24&255),B=0,w=0):(B=p>>>24,w+=2)}if(x<_.length)for(_[x++]=B;x<_.length;)_[x++]=0},U.prototype._toArrayLikeBE=function(_,N){for(var x=_.length-1,B=0,y=0,w=0;y=0&&(_[x--]=p>>8&255),x>=0&&(_[x--]=p>>16&255),w===6?(x>=0&&(_[x--]=p>>24&255),B=0,w=0):(B=p>>>24,w+=2)}if(x>=0)for(_[x--]=B;x>=0;)_[x--]=0},Math.clz32?U.prototype._countBits=function(_){return 32-Math.clz32(_)}:U.prototype._countBits=function(_){var N=_,x=0;return N>=4096&&(x+=13,N>>>=13),N>=64&&(x+=7,N>>>=7),N>=8&&(x+=4,N>>>=4),N>=2&&(x+=2,N>>>=2),x+N},U.prototype._zeroBits=function(_){if(_===0)return 26;var N=_,x=0;return(N&8191)===0&&(x+=13,N>>>=13),(N&127)===0&&(x+=7,N>>>=7),(N&15)===0&&(x+=4,N>>>=4),(N&3)===0&&(x+=2,N>>>=2),(N&1)===0&&x++,x},U.prototype.bitLength=function(){var _=this.words[this.length-1],N=this._countBits(_);return(this.length-1)*26+N};function T(_){for(var N=new Array(_.bitLength()),x=0;x>>y&1}return N}U.prototype.zeroBits=function(){if(this.isZero())return 0;for(var _=0,N=0;N_.length?this.clone().ior(_):_.clone().ior(this)},U.prototype.uor=function(_){return this.length>_.length?this.clone().iuor(_):_.clone().iuor(this)},U.prototype.iuand=function(_){var N;this.length>_.length?N=_:N=this;for(var x=0;x_.length?this.clone().iand(_):_.clone().iand(this)},U.prototype.uand=function(_){return this.length>_.length?this.clone().iuand(_):_.clone().iuand(this)},U.prototype.iuxor=function(_){var N,x;this.length>_.length?(N=this,x=_):(N=_,x=this);for(var B=0;B_.length?this.clone().ixor(_):_.clone().ixor(this)},U.prototype.uxor=function(_){return this.length>_.length?this.clone().iuxor(_):_.clone().iuxor(this)},U.prototype.inotn=function(_){G(typeof _=="number"&&_>=0);var N=Math.ceil(_/26)|0,x=_%26;this._expand(N),x>0&&N--;for(var B=0;B0&&(this.words[B]=~this.words[B]&67108863>>26-x),this._strip()},U.prototype.notn=function(_){return this.clone().inotn(_)},U.prototype.setn=function(_,N){G(typeof _=="number"&&_>=0);var x=_/26|0,B=_%26;return this._expand(x+1),N?this.words[x]=this.words[x]|1<_.length?(x=this,B=_):(x=_,B=this);for(var y=0,w=0;w>>26;for(;y!==0&&w>>26;if(this.length=x.length,y!==0)this.words[this.length]=y,this.length++;else if(x!==this)for(;w_.length?this.clone().iadd(_):_.clone().iadd(this)},U.prototype.isub=function(_){if(_.negative!==0){_.negative=0;var N=this.iadd(_);return _.negative=1,N._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(_),this.negative=1,this._normSign();var x=this.cmp(_);if(x===0)return this.negative=0,this.length=1,this.words[0]=0,this;var B,y;x>0?(B=this,y=_):(B=_,y=this);for(var w=0,p=0;p>26,this.words[p]=N&67108863;for(;w!==0&&p>26,this.words[p]=N&67108863;if(w===0&&p>>26,b=c&67108863,l=Math.min(h,N.length-1),o=Math.max(0,h-_.length+1);o<=l;o++){var u=h-o|0;y=_.words[u]|0,w=N.words[o]|0,p=y*w+b,d+=p/67108864|0,b=p&67108863}x.words[h]=b|0,c=d|0}return c!==0?x.words[h]=c|0:x.length--,x._strip()}var C=function(_,N,x){var B=_.words,y=N.words,w=x.words,p=0,f,c,h,d=B[0]|0,b=d&8191,l=d>>>13,o=B[1]|0,u=o&8191,n=o>>>13,s=B[2]|0,t=s&8191,m=s>>>13,a=B[3]|0,e=a&8191,r=a>>>13,i=B[4]|0,$0=i&8191,Q0=i>>>13,Y0=B[5]|0,Z0=Y0&8191,G0=Y0>>>13,V0=B[6]|0,U0=V0&8191,X0=V0>>>13,K0=B[7]|0,I0=K0&8191,O0=K0>>>13,J0=B[8]|0,F0=J0&8191,A0=J0>>>13,H0=B[9]|0,W0=H0&8191,E0=H0>>>13,T0=y[0]|0,D0=T0&8191,C0=T0>>>13,L0=y[1]|0,R0=L0&8191,P0=L0>>>13,z0=y[2]|0,M0=z0&8191,S0=z0>>>13,v0=y[3]|0,q0=v0&8191,j0=v0>>>13,k0=y[4]|0,g0=k0&8191,_0=k0>>>13,N0=y[5]|0,x0=N0&8191,B0=N0>>>13,y0=y[6]|0,w0=y0&8191,p0=y0>>>13,f0=y[7]|0,c0=f0&8191,h0=f0>>>13,d0=y[8]|0,b0=d0&8191,l0=d0>>>13,o0=y[9]|0,u0=o0&8191,n0=o0>>>13;x.negative=_.negative^N.negative,x.length=19,f=Math.imul(b,D0),c=Math.imul(b,C0),c=c+Math.imul(l,D0)|0,h=Math.imul(l,C0);var s0=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(s0>>>26)|0,s0&=67108863,f=Math.imul(u,D0),c=Math.imul(u,C0),c=c+Math.imul(n,D0)|0,h=Math.imul(n,C0),f=f+Math.imul(b,R0)|0,c=c+Math.imul(b,P0)|0,c=c+Math.imul(l,R0)|0,h=h+Math.imul(l,P0)|0;var t0=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(t0>>>26)|0,t0&=67108863,f=Math.imul(t,D0),c=Math.imul(t,C0),c=c+Math.imul(m,D0)|0,h=Math.imul(m,C0),f=f+Math.imul(u,R0)|0,c=c+Math.imul(u,P0)|0,c=c+Math.imul(n,R0)|0,h=h+Math.imul(n,P0)|0,f=f+Math.imul(b,M0)|0,c=c+Math.imul(b,S0)|0,c=c+Math.imul(l,M0)|0,h=h+Math.imul(l,S0)|0;var m0=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(m0>>>26)|0,m0&=67108863,f=Math.imul(e,D0),c=Math.imul(e,C0),c=c+Math.imul(r,D0)|0,h=Math.imul(r,C0),f=f+Math.imul(t,R0)|0,c=c+Math.imul(t,P0)|0,c=c+Math.imul(m,R0)|0,h=h+Math.imul(m,P0)|0,f=f+Math.imul(u,M0)|0,c=c+Math.imul(u,S0)|0,c=c+Math.imul(n,M0)|0,h=h+Math.imul(n,S0)|0,f=f+Math.imul(b,q0)|0,c=c+Math.imul(b,j0)|0,c=c+Math.imul(l,q0)|0,h=h+Math.imul(l,j0)|0;var a0=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(a0>>>26)|0,a0&=67108863,f=Math.imul($0,D0),c=Math.imul($0,C0),c=c+Math.imul(Q0,D0)|0,h=Math.imul(Q0,C0),f=f+Math.imul(e,R0)|0,c=c+Math.imul(e,P0)|0,c=c+Math.imul(r,R0)|0,h=h+Math.imul(r,P0)|0,f=f+Math.imul(t,M0)|0,c=c+Math.imul(t,S0)|0,c=c+Math.imul(m,M0)|0,h=h+Math.imul(m,S0)|0,f=f+Math.imul(u,q0)|0,c=c+Math.imul(u,j0)|0,c=c+Math.imul(n,q0)|0,h=h+Math.imul(n,j0)|0,f=f+Math.imul(b,g0)|0,c=c+Math.imul(b,_0)|0,c=c+Math.imul(l,g0)|0,h=h+Math.imul(l,_0)|0;var e0=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(e0>>>26)|0,e0&=67108863,f=Math.imul(Z0,D0),c=Math.imul(Z0,C0),c=c+Math.imul(G0,D0)|0,h=Math.imul(G0,C0),f=f+Math.imul($0,R0)|0,c=c+Math.imul($0,P0)|0,c=c+Math.imul(Q0,R0)|0,h=h+Math.imul(Q0,P0)|0,f=f+Math.imul(e,M0)|0,c=c+Math.imul(e,S0)|0,c=c+Math.imul(r,M0)|0,h=h+Math.imul(r,S0)|0,f=f+Math.imul(t,q0)|0,c=c+Math.imul(t,j0)|0,c=c+Math.imul(m,q0)|0,h=h+Math.imul(m,j0)|0,f=f+Math.imul(u,g0)|0,c=c+Math.imul(u,_0)|0,c=c+Math.imul(n,g0)|0,h=h+Math.imul(n,_0)|0,f=f+Math.imul(b,x0)|0,c=c+Math.imul(b,B0)|0,c=c+Math.imul(l,x0)|0,h=h+Math.imul(l,B0)|0;var r0=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(r0>>>26)|0,r0&=67108863,f=Math.imul(U0,D0),c=Math.imul(U0,C0),c=c+Math.imul(X0,D0)|0,h=Math.imul(X0,C0),f=f+Math.imul(Z0,R0)|0,c=c+Math.imul(Z0,P0)|0,c=c+Math.imul(G0,R0)|0,h=h+Math.imul(G0,P0)|0,f=f+Math.imul($0,M0)|0,c=c+Math.imul($0,S0)|0,c=c+Math.imul(Q0,M0)|0,h=h+Math.imul(Q0,S0)|0,f=f+Math.imul(e,q0)|0,c=c+Math.imul(e,j0)|0,c=c+Math.imul(r,q0)|0,h=h+Math.imul(r,j0)|0,f=f+Math.imul(t,g0)|0,c=c+Math.imul(t,_0)|0,c=c+Math.imul(m,g0)|0,h=h+Math.imul(m,_0)|0,f=f+Math.imul(u,x0)|0,c=c+Math.imul(u,B0)|0,c=c+Math.imul(n,x0)|0,h=h+Math.imul(n,B0)|0,f=f+Math.imul(b,w0)|0,c=c+Math.imul(b,p0)|0,c=c+Math.imul(l,w0)|0,h=h+Math.imul(l,p0)|0;var i0=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(i0>>>26)|0,i0&=67108863,f=Math.imul(I0,D0),c=Math.imul(I0,C0),c=c+Math.imul(O0,D0)|0,h=Math.imul(O0,C0),f=f+Math.imul(U0,R0)|0,c=c+Math.imul(U0,P0)|0,c=c+Math.imul(X0,R0)|0,h=h+Math.imul(X0,P0)|0,f=f+Math.imul(Z0,M0)|0,c=c+Math.imul(Z0,S0)|0,c=c+Math.imul(G0,M0)|0,h=h+Math.imul(G0,S0)|0,f=f+Math.imul($0,q0)|0,c=c+Math.imul($0,j0)|0,c=c+Math.imul(Q0,q0)|0,h=h+Math.imul(Q0,j0)|0,f=f+Math.imul(e,g0)|0,c=c+Math.imul(e,_0)|0,c=c+Math.imul(r,g0)|0,h=h+Math.imul(r,_0)|0,f=f+Math.imul(t,x0)|0,c=c+Math.imul(t,B0)|0,c=c+Math.imul(m,x0)|0,h=h+Math.imul(m,B0)|0,f=f+Math.imul(u,w0)|0,c=c+Math.imul(u,p0)|0,c=c+Math.imul(n,w0)|0,h=h+Math.imul(n,p0)|0,f=f+Math.imul(b,c0)|0,c=c+Math.imul(b,h0)|0,c=c+Math.imul(l,c0)|0,h=h+Math.imul(l,h0)|0;var $$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+($$>>>26)|0,$$&=67108863,f=Math.imul(F0,D0),c=Math.imul(F0,C0),c=c+Math.imul(A0,D0)|0,h=Math.imul(A0,C0),f=f+Math.imul(I0,R0)|0,c=c+Math.imul(I0,P0)|0,c=c+Math.imul(O0,R0)|0,h=h+Math.imul(O0,P0)|0,f=f+Math.imul(U0,M0)|0,c=c+Math.imul(U0,S0)|0,c=c+Math.imul(X0,M0)|0,h=h+Math.imul(X0,S0)|0,f=f+Math.imul(Z0,q0)|0,c=c+Math.imul(Z0,j0)|0,c=c+Math.imul(G0,q0)|0,h=h+Math.imul(G0,j0)|0,f=f+Math.imul($0,g0)|0,c=c+Math.imul($0,_0)|0,c=c+Math.imul(Q0,g0)|0,h=h+Math.imul(Q0,_0)|0,f=f+Math.imul(e,x0)|0,c=c+Math.imul(e,B0)|0,c=c+Math.imul(r,x0)|0,h=h+Math.imul(r,B0)|0,f=f+Math.imul(t,w0)|0,c=c+Math.imul(t,p0)|0,c=c+Math.imul(m,w0)|0,h=h+Math.imul(m,p0)|0,f=f+Math.imul(u,c0)|0,c=c+Math.imul(u,h0)|0,c=c+Math.imul(n,c0)|0,h=h+Math.imul(n,h0)|0,f=f+Math.imul(b,b0)|0,c=c+Math.imul(b,l0)|0,c=c+Math.imul(l,b0)|0,h=h+Math.imul(l,l0)|0;var Q$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,f=Math.imul(W0,D0),c=Math.imul(W0,C0),c=c+Math.imul(E0,D0)|0,h=Math.imul(E0,C0),f=f+Math.imul(F0,R0)|0,c=c+Math.imul(F0,P0)|0,c=c+Math.imul(A0,R0)|0,h=h+Math.imul(A0,P0)|0,f=f+Math.imul(I0,M0)|0,c=c+Math.imul(I0,S0)|0,c=c+Math.imul(O0,M0)|0,h=h+Math.imul(O0,S0)|0,f=f+Math.imul(U0,q0)|0,c=c+Math.imul(U0,j0)|0,c=c+Math.imul(X0,q0)|0,h=h+Math.imul(X0,j0)|0,f=f+Math.imul(Z0,g0)|0,c=c+Math.imul(Z0,_0)|0,c=c+Math.imul(G0,g0)|0,h=h+Math.imul(G0,_0)|0,f=f+Math.imul($0,x0)|0,c=c+Math.imul($0,B0)|0,c=c+Math.imul(Q0,x0)|0,h=h+Math.imul(Q0,B0)|0,f=f+Math.imul(e,w0)|0,c=c+Math.imul(e,p0)|0,c=c+Math.imul(r,w0)|0,h=h+Math.imul(r,p0)|0,f=f+Math.imul(t,c0)|0,c=c+Math.imul(t,h0)|0,c=c+Math.imul(m,c0)|0,h=h+Math.imul(m,h0)|0,f=f+Math.imul(u,b0)|0,c=c+Math.imul(u,l0)|0,c=c+Math.imul(n,b0)|0,h=h+Math.imul(n,l0)|0,f=f+Math.imul(b,u0)|0,c=c+Math.imul(b,n0)|0,c=c+Math.imul(l,u0)|0,h=h+Math.imul(l,n0)|0;var Y$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,f=Math.imul(W0,R0),c=Math.imul(W0,P0),c=c+Math.imul(E0,R0)|0,h=Math.imul(E0,P0),f=f+Math.imul(F0,M0)|0,c=c+Math.imul(F0,S0)|0,c=c+Math.imul(A0,M0)|0,h=h+Math.imul(A0,S0)|0,f=f+Math.imul(I0,q0)|0,c=c+Math.imul(I0,j0)|0,c=c+Math.imul(O0,q0)|0,h=h+Math.imul(O0,j0)|0,f=f+Math.imul(U0,g0)|0,c=c+Math.imul(U0,_0)|0,c=c+Math.imul(X0,g0)|0,h=h+Math.imul(X0,_0)|0,f=f+Math.imul(Z0,x0)|0,c=c+Math.imul(Z0,B0)|0,c=c+Math.imul(G0,x0)|0,h=h+Math.imul(G0,B0)|0,f=f+Math.imul($0,w0)|0,c=c+Math.imul($0,p0)|0,c=c+Math.imul(Q0,w0)|0,h=h+Math.imul(Q0,p0)|0,f=f+Math.imul(e,c0)|0,c=c+Math.imul(e,h0)|0,c=c+Math.imul(r,c0)|0,h=h+Math.imul(r,h0)|0,f=f+Math.imul(t,b0)|0,c=c+Math.imul(t,l0)|0,c=c+Math.imul(m,b0)|0,h=h+Math.imul(m,l0)|0,f=f+Math.imul(u,u0)|0,c=c+Math.imul(u,n0)|0,c=c+Math.imul(n,u0)|0,h=h+Math.imul(n,n0)|0;var Z$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,f=Math.imul(W0,M0),c=Math.imul(W0,S0),c=c+Math.imul(E0,M0)|0,h=Math.imul(E0,S0),f=f+Math.imul(F0,q0)|0,c=c+Math.imul(F0,j0)|0,c=c+Math.imul(A0,q0)|0,h=h+Math.imul(A0,j0)|0,f=f+Math.imul(I0,g0)|0,c=c+Math.imul(I0,_0)|0,c=c+Math.imul(O0,g0)|0,h=h+Math.imul(O0,_0)|0,f=f+Math.imul(U0,x0)|0,c=c+Math.imul(U0,B0)|0,c=c+Math.imul(X0,x0)|0,h=h+Math.imul(X0,B0)|0,f=f+Math.imul(Z0,w0)|0,c=c+Math.imul(Z0,p0)|0,c=c+Math.imul(G0,w0)|0,h=h+Math.imul(G0,p0)|0,f=f+Math.imul($0,c0)|0,c=c+Math.imul($0,h0)|0,c=c+Math.imul(Q0,c0)|0,h=h+Math.imul(Q0,h0)|0,f=f+Math.imul(e,b0)|0,c=c+Math.imul(e,l0)|0,c=c+Math.imul(r,b0)|0,h=h+Math.imul(r,l0)|0,f=f+Math.imul(t,u0)|0,c=c+Math.imul(t,n0)|0,c=c+Math.imul(m,u0)|0,h=h+Math.imul(m,n0)|0;var G$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(G$>>>26)|0,G$&=67108863,f=Math.imul(W0,q0),c=Math.imul(W0,j0),c=c+Math.imul(E0,q0)|0,h=Math.imul(E0,j0),f=f+Math.imul(F0,g0)|0,c=c+Math.imul(F0,_0)|0,c=c+Math.imul(A0,g0)|0,h=h+Math.imul(A0,_0)|0,f=f+Math.imul(I0,x0)|0,c=c+Math.imul(I0,B0)|0,c=c+Math.imul(O0,x0)|0,h=h+Math.imul(O0,B0)|0,f=f+Math.imul(U0,w0)|0,c=c+Math.imul(U0,p0)|0,c=c+Math.imul(X0,w0)|0,h=h+Math.imul(X0,p0)|0,f=f+Math.imul(Z0,c0)|0,c=c+Math.imul(Z0,h0)|0,c=c+Math.imul(G0,c0)|0,h=h+Math.imul(G0,h0)|0,f=f+Math.imul($0,b0)|0,c=c+Math.imul($0,l0)|0,c=c+Math.imul(Q0,b0)|0,h=h+Math.imul(Q0,l0)|0,f=f+Math.imul(e,u0)|0,c=c+Math.imul(e,n0)|0,c=c+Math.imul(r,u0)|0,h=h+Math.imul(r,n0)|0;var V$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(V$>>>26)|0,V$&=67108863,f=Math.imul(W0,g0),c=Math.imul(W0,_0),c=c+Math.imul(E0,g0)|0,h=Math.imul(E0,_0),f=f+Math.imul(F0,x0)|0,c=c+Math.imul(F0,B0)|0,c=c+Math.imul(A0,x0)|0,h=h+Math.imul(A0,B0)|0,f=f+Math.imul(I0,w0)|0,c=c+Math.imul(I0,p0)|0,c=c+Math.imul(O0,w0)|0,h=h+Math.imul(O0,p0)|0,f=f+Math.imul(U0,c0)|0,c=c+Math.imul(U0,h0)|0,c=c+Math.imul(X0,c0)|0,h=h+Math.imul(X0,h0)|0,f=f+Math.imul(Z0,b0)|0,c=c+Math.imul(Z0,l0)|0,c=c+Math.imul(G0,b0)|0,h=h+Math.imul(G0,l0)|0,f=f+Math.imul($0,u0)|0,c=c+Math.imul($0,n0)|0,c=c+Math.imul(Q0,u0)|0,h=h+Math.imul(Q0,n0)|0;var U$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(U$>>>26)|0,U$&=67108863,f=Math.imul(W0,x0),c=Math.imul(W0,B0),c=c+Math.imul(E0,x0)|0,h=Math.imul(E0,B0),f=f+Math.imul(F0,w0)|0,c=c+Math.imul(F0,p0)|0,c=c+Math.imul(A0,w0)|0,h=h+Math.imul(A0,p0)|0,f=f+Math.imul(I0,c0)|0,c=c+Math.imul(I0,h0)|0,c=c+Math.imul(O0,c0)|0,h=h+Math.imul(O0,h0)|0,f=f+Math.imul(U0,b0)|0,c=c+Math.imul(U0,l0)|0,c=c+Math.imul(X0,b0)|0,h=h+Math.imul(X0,l0)|0,f=f+Math.imul(Z0,u0)|0,c=c+Math.imul(Z0,n0)|0,c=c+Math.imul(G0,u0)|0,h=h+Math.imul(G0,n0)|0;var X$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(X$>>>26)|0,X$&=67108863,f=Math.imul(W0,w0),c=Math.imul(W0,p0),c=c+Math.imul(E0,w0)|0,h=Math.imul(E0,p0),f=f+Math.imul(F0,c0)|0,c=c+Math.imul(F0,h0)|0,c=c+Math.imul(A0,c0)|0,h=h+Math.imul(A0,h0)|0,f=f+Math.imul(I0,b0)|0,c=c+Math.imul(I0,l0)|0,c=c+Math.imul(O0,b0)|0,h=h+Math.imul(O0,l0)|0,f=f+Math.imul(U0,u0)|0,c=c+Math.imul(U0,n0)|0,c=c+Math.imul(X0,u0)|0,h=h+Math.imul(X0,n0)|0;var K$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(K$>>>26)|0,K$&=67108863,f=Math.imul(W0,c0),c=Math.imul(W0,h0),c=c+Math.imul(E0,c0)|0,h=Math.imul(E0,h0),f=f+Math.imul(F0,b0)|0,c=c+Math.imul(F0,l0)|0,c=c+Math.imul(A0,b0)|0,h=h+Math.imul(A0,l0)|0,f=f+Math.imul(I0,u0)|0,c=c+Math.imul(I0,n0)|0,c=c+Math.imul(O0,u0)|0,h=h+Math.imul(O0,n0)|0;var I$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(I$>>>26)|0,I$&=67108863,f=Math.imul(W0,b0),c=Math.imul(W0,l0),c=c+Math.imul(E0,b0)|0,h=Math.imul(E0,l0),f=f+Math.imul(F0,u0)|0,c=c+Math.imul(F0,n0)|0,c=c+Math.imul(A0,u0)|0,h=h+Math.imul(A0,n0)|0;var O$=(p+f|0)+((c&8191)<<13)|0;p=(h+(c>>>13)|0)+(O$>>>26)|0,O$&=67108863,f=Math.imul(W0,u0),c=Math.imul(W0,n0),c=c+Math.imul(E0,u0)|0,h=Math.imul(E0,n0);var J$=(p+f|0)+((c&8191)<<13)|0;return p=(h+(c>>>13)|0)+(J$>>>26)|0,J$&=67108863,w[0]=s0,w[1]=t0,w[2]=m0,w[3]=a0,w[4]=e0,w[5]=r0,w[6]=i0,w[7]=$$,w[8]=Q$,w[9]=Y$,w[10]=Z$,w[11]=G$,w[12]=V$,w[13]=U$,w[14]=X$,w[15]=K$,w[16]=I$,w[17]=O$,w[18]=J$,p!==0&&(w[19]=p,x.length++),x};Math.imul||(C=D);function L(_,N,x){x.negative=N.negative^_.negative,x.length=_.length+N.length;for(var B=0,y=0,w=0;w>>26)|0,y+=p>>>26,p&=67108863}x.words[w]=f,B=p,p=y}return B!==0?x.words[w]=B:x.length--,x._strip()}function R(_,N,x){return L(_,N,x)}U.prototype.mulTo=function(_,N){var x,B=this.length+_.length;return this.length===10&&_.length===10?x=C(this,_,N):B<63?x=D(this,_,N):B<1024?x=L(this,_,N):x=R(this,_,N),x};function P(_,N){this.x=_,this.y=N}P.prototype.makeRBT=function(_){for(var N=new Array(_),x=U.prototype._countBits(_)-1,B=0;B<_;B++)N[B]=this.revBin(B,x,_);return N},P.prototype.revBin=function(_,N,x){if(_===0||_===x-1)return _;for(var B=0,y=0;y>=1;return B},P.prototype.permute=function(_,N,x,B,y,w){for(var p=0;p>>1)y++;return 1<>>13,x[2*w+1]=y&8191,y=y>>>13;for(w=2*N;w>=26,x+=y/67108864|0,x+=w>>>26,this.words[B]=w&67108863}return x!==0&&(this.words[B]=x,this.length++),N?this.ineg():this},U.prototype.muln=function(_){return this.clone().imuln(_)},U.prototype.sqr=function(){return this.mul(this)},U.prototype.isqr=function(){return this.imul(this.clone())},U.prototype.pow=function(_){var N=T(_);if(N.length===0)return new U(1);for(var x=this,B=0;B=0);var N=_%26,x=(_-N)/26,B=67108863>>>26-N<<26-N,y;if(N!==0){var w=0;for(y=0;y>>26-N}w&&(this.words[y]=w,this.length++)}if(x!==0){for(y=this.length-1;y>=0;y--)this.words[y+x]=this.words[y];for(y=0;y=0);var B;N?B=(N-N%26)/26:B=0;var y=_%26,w=Math.min((_-y)/26,this.length),p=67108863^67108863>>>y<w)for(this.length-=w,c=0;c=0&&(h!==0||c>=B);c--){var d=this.words[c]|0;this.words[c]=h<<26-y|d>>>y,h=d&p}return f&&h!==0&&(f.words[f.length++]=h),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},U.prototype.ishrn=function(_,N,x){return G(this.negative===0),this.iushrn(_,N,x)},U.prototype.shln=function(_){return this.clone().ishln(_)},U.prototype.ushln=function(_){return this.clone().iushln(_)},U.prototype.shrn=function(_){return this.clone().ishrn(_)},U.prototype.ushrn=function(_){return this.clone().iushrn(_)},U.prototype.testn=function(_){G(typeof _=="number"&&_>=0);var N=_%26,x=(_-N)/26,B=1<=0);var N=_%26,x=(_-N)/26;if(G(this.negative===0,"imaskn works only with positive numbers"),this.length<=x)return this;if(N!==0&&x++,this.length=Math.min(x,this.length),N!==0){var B=67108863^67108863>>>N<=67108864;N++)this.words[N]-=67108864,N===this.length-1?this.words[N+1]=1:this.words[N+1]++;return this.length=Math.max(this.length,N+1),this},U.prototype.isubn=function(_){if(G(typeof _=="number"),G(_<67108864),_<0)return this.iaddn(-_);if(this.negative!==0)return this.negative=0,this.iaddn(_),this.negative=1,this;if(this.words[0]-=_,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var N=0;N>26)-(f/67108864|0),this.words[y+x]=w&67108863}for(;y>26,this.words[y+x]=w&67108863;if(p===0)return this._strip();for(G(p===-1),p=0,y=0;y>26,this.words[y]=w&67108863;return this.negative=1,this._strip()},U.prototype._wordDiv=function(_,N){var x=this.length-_.length,B=this.clone(),y=_,w=y.words[y.length-1]|0,p=this._countBits(w);x=26-p,x!==0&&(y=y.ushln(x),B.iushln(x),w=y.words[y.length-1]|0);var f=B.length-y.length,c;if(N!=="mod"){c=new U(null),c.length=f+1,c.words=new Array(c.length);for(var h=0;h=0;b--){var l=(B.words[y.length+b]|0)*67108864+(B.words[y.length+b-1]|0);for(l=Math.min(l/w|0,67108863),B._ishlnsubmul(y,l,b);B.negative!==0;)l--,B.negative=0,B._ishlnsubmul(y,1,b),B.isZero()||(B.negative^=1);c&&(c.words[b]=l)}return c&&c._strip(),B._strip(),N!=="div"&&x!==0&&B.iushrn(x),{div:c||null,mod:B}},U.prototype.divmod=function(_,N,x){if(G(!_.isZero()),this.isZero())return{div:new U(0),mod:new U(0)};var B,y,w;return this.negative!==0&&_.negative===0?(w=this.neg().divmod(_,N),N!=="mod"&&(B=w.div.neg()),N!=="div"&&(y=w.mod.neg(),x&&y.negative!==0&&y.iadd(_)),{div:B,mod:y}):this.negative===0&&_.negative!==0?(w=this.divmod(_.neg(),N),N!=="mod"&&(B=w.div.neg()),{div:B,mod:w.mod}):(this.negative&_.negative)!==0?(w=this.neg().divmod(_.neg(),N),N!=="div"&&(y=w.mod.neg(),x&&y.negative!==0&&y.isub(_)),{div:w.div,mod:y}):_.length>this.length||this.cmp(_)<0?{div:new U(0),mod:this}:_.length===1?N==="div"?{div:this.divn(_.words[0]),mod:null}:N==="mod"?{div:null,mod:new U(this.modrn(_.words[0]))}:{div:this.divn(_.words[0]),mod:new U(this.modrn(_.words[0]))}:this._wordDiv(_,N)},U.prototype.div=function(_){return this.divmod(_,"div",!1).div},U.prototype.mod=function(_){return this.divmod(_,"mod",!1).mod},U.prototype.umod=function(_){return this.divmod(_,"mod",!0).mod},U.prototype.divRound=function(_){var N=this.divmod(_);if(N.mod.isZero())return N.div;var x=N.div.negative!==0?N.mod.isub(_):N.mod,B=_.ushrn(1),y=_.andln(1),w=x.cmp(B);return w<0||y===1&&w===0?N.div:N.div.negative!==0?N.div.isubn(1):N.div.iaddn(1)},U.prototype.modrn=function(_){var N=_<0;N&&(_=-_),G(_<=67108863);for(var x=(1<<26)%_,B=0,y=this.length-1;y>=0;y--)B=(x*B+(this.words[y]|0))%_;return N?-B:B},U.prototype.modn=function(_){return this.modrn(_)},U.prototype.idivn=function(_){var N=_<0;N&&(_=-_),G(_<=67108863);for(var x=0,B=this.length-1;B>=0;B--){var y=(this.words[B]|0)+x*67108864;this.words[B]=y/_|0,x=y%_}return this._strip(),N?this.ineg():this},U.prototype.divn=function(_){return this.clone().idivn(_)},U.prototype.egcd=function(_){G(_.negative===0),G(!_.isZero());var N=this,x=_.clone();N.negative!==0?N=N.umod(_):N=N.clone();for(var B=new U(1),y=new U(0),w=new U(0),p=new U(1),f=0;N.isEven()&&x.isEven();)N.iushrn(1),x.iushrn(1),++f;for(var c=x.clone(),h=N.clone();!N.isZero();){for(var d=0,b=1;(N.words[0]&b)===0&&d<26;++d,b<<=1);if(d>0)for(N.iushrn(d);d-- >0;)(B.isOdd()||y.isOdd())&&(B.iadd(c),y.isub(h)),B.iushrn(1),y.iushrn(1);for(var l=0,o=1;(x.words[0]&o)===0&&l<26;++l,o<<=1);if(l>0)for(x.iushrn(l);l-- >0;)(w.isOdd()||p.isOdd())&&(w.iadd(c),p.isub(h)),w.iushrn(1),p.iushrn(1);N.cmp(x)>=0?(N.isub(x),B.isub(w),y.isub(p)):(x.isub(N),w.isub(B),p.isub(y))}return{a:w,b:p,gcd:x.iushln(f)}},U.prototype._invmp=function(_){G(_.negative===0),G(!_.isZero());var N=this,x=_.clone();N.negative!==0?N=N.umod(_):N=N.clone();for(var B=new U(1),y=new U(0),w=x.clone();N.cmpn(1)>0&&x.cmpn(1)>0;){for(var p=0,f=1;(N.words[0]&f)===0&&p<26;++p,f<<=1);if(p>0)for(N.iushrn(p);p-- >0;)B.isOdd()&&B.iadd(w),B.iushrn(1);for(var c=0,h=1;(x.words[0]&h)===0&&c<26;++c,h<<=1);if(c>0)for(x.iushrn(c);c-- >0;)y.isOdd()&&y.iadd(w),y.iushrn(1);N.cmp(x)>=0?(N.isub(x),B.isub(y)):(x.isub(N),y.isub(B))}var d;return N.cmpn(1)===0?d=B:d=y,d.cmpn(0)<0&&d.iadd(_),d},U.prototype.gcd=function(_){if(this.isZero())return _.abs();if(_.isZero())return this.abs();var N=this.clone(),x=_.clone();N.negative=0,x.negative=0;for(var B=0;N.isEven()&&x.isEven();B++)N.iushrn(1),x.iushrn(1);do{for(;N.isEven();)N.iushrn(1);for(;x.isEven();)x.iushrn(1);var y=N.cmp(x);if(y<0){var w=N;N=x,x=w}else if(y===0||x.cmpn(1)===0)break;N.isub(x)}while(!0);return x.iushln(B)},U.prototype.invm=function(_){return this.egcd(_).a.umod(_)},U.prototype.isEven=function(){return(this.words[0]&1)===0},U.prototype.isOdd=function(){return(this.words[0]&1)===1},U.prototype.andln=function(_){return this.words[0]&_},U.prototype.bincn=function(_){G(typeof _=="number");var N=_%26,x=(_-N)/26,B=1<>>26,p&=67108863,this.words[w]=p}return y!==0&&(this.words[w]=y,this.length++),this},U.prototype.isZero=function(){return this.length===1&&this.words[0]===0},U.prototype.cmpn=function(_){var N=_<0;if(this.negative!==0&&!N)return-1;if(this.negative===0&&N)return 1;this._strip();var x;if(this.length>1)x=1;else{N&&(_=-_),G(_<=67108863,"Number is too big");var B=this.words[0]|0;x=B===_?0:B<_?-1:1}return this.negative!==0?-x|0:x},U.prototype.cmp=function(_){if(this.negative!==0&&_.negative===0)return-1;if(this.negative===0&&_.negative!==0)return 1;var N=this.ucmp(_);return this.negative!==0?-N|0:N},U.prototype.ucmp=function(_){if(this.length>_.length)return 1;if(this.length<_.length)return-1;for(var N=0,x=this.length-1;x>=0;x--){var B=this.words[x]|0,y=_.words[x]|0;if(B!==y){By&&(N=1);break}}return N},U.prototype.gtn=function(_){return this.cmpn(_)===1},U.prototype.gt=function(_){return this.cmp(_)===1},U.prototype.gten=function(_){return this.cmpn(_)>=0},U.prototype.gte=function(_){return this.cmp(_)>=0},U.prototype.ltn=function(_){return this.cmpn(_)===-1},U.prototype.lt=function(_){return this.cmp(_)===-1},U.prototype.lten=function(_){return this.cmpn(_)<=0},U.prototype.lte=function(_){return this.cmp(_)<=0},U.prototype.eqn=function(_){return this.cmpn(_)===0},U.prototype.eq=function(_){return this.cmp(_)===0},U.red=function(_){return new k(_)},U.prototype.toRed=function(_){return G(!this.red,"Already a number in reduction context"),G(this.negative===0,"red works only with positives"),_.convertTo(this)._forceRed(_)},U.prototype.fromRed=function(){return G(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},U.prototype._forceRed=function(_){return this.red=_,this},U.prototype.forceRed=function(_){return G(!this.red,"Already a number in reduction context"),this._forceRed(_)},U.prototype.redAdd=function(_){return G(this.red,"redAdd works only with red numbers"),this.red.add(this,_)},U.prototype.redIAdd=function(_){return G(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,_)},U.prototype.redSub=function(_){return G(this.red,"redSub works only with red numbers"),this.red.sub(this,_)},U.prototype.redISub=function(_){return G(this.red,"redISub works only with red numbers"),this.red.isub(this,_)},U.prototype.redShl=function(_){return G(this.red,"redShl works only with red numbers"),this.red.shl(this,_)},U.prototype.redMul=function(_){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,_),this.red.mul(this,_)},U.prototype.redIMul=function(_){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,_),this.red.imul(this,_)},U.prototype.redSqr=function(){return G(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},U.prototype.redISqr=function(){return G(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},U.prototype.redSqrt=function(){return G(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},U.prototype.redInvm=function(){return G(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},U.prototype.redNeg=function(){return G(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},U.prototype.redPow=function(_){return G(this.red&&!_.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,_)};var z={k256:null,p224:null,p192:null,p25519:null};function M(_,N){this.name=_,this.p=new U(N,16),this.n=this.p.bitLength(),this.k=new U(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}M.prototype._tmp=function(){var _=new U(null);return _.words=new Array(Math.ceil(this.n/13)),_},M.prototype.ireduce=function(_){var N=_,x;do this.split(N,this.tmp),N=this.imulK(N),N=N.iadd(this.tmp),x=N.bitLength();while(x>this.n);var B=x0?N.isub(this.p):N.strip!==void 0?N.strip():N._strip(),N},M.prototype.split=function(_,N){_.iushrn(this.n,0,N)},M.prototype.imulK=function(_){return _.imul(this.k)};function S(){M.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}V(S,M),S.prototype.split=function(_,N){for(var x=4194303,B=Math.min(_.length,9),y=0;y>>22,w=p}w>>>=22,_.words[y-10]=w,w===0&&_.length>10?_.length-=10:_.length-=9},S.prototype.imulK=function(_){_.words[_.length]=0,_.words[_.length+1]=0,_.length+=2;for(var N=0,x=0;x<_.length;x++){var B=_.words[x]|0;N+=B*977,_.words[x]=N&67108863,N=B*64+(N/67108864|0)}return _.words[_.length-1]===0&&(_.length--,_.words[_.length-1]===0&&_.length--),_};function v(){M.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}V(v,M);function q(){M.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}V(q,M);function j(){M.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}V(j,M),j.prototype.imulK=function(_){for(var N=0,x=0;x<_.length;x++){var B=(_.words[x]|0)*19+N,y=B&67108863;B>>>=26,_.words[x]=y,N=B}return N!==0&&(_.words[_.length++]=N),_},U._prime=function(_){if(z[_])return z[_];var N;if(_==="k256")N=new S;else if(_==="p224")N=new v;else if(_==="p192")N=new q;else if(_==="p25519")N=new j;else throw new Error("Unknown prime "+_);return z[_]=N,N};function k(_){if(typeof _=="string"){var N=U._prime(_);this.m=N.p,this.prime=N}else G(_.gtn(1),"modulus must be greater than 1"),this.m=_,this.prime=null}k.prototype._verify1=function(_){G(_.negative===0,"red works only with positives"),G(_.red,"red works only with red numbers")},k.prototype._verify2=function(_,N){G((_.negative|N.negative)===0,"red works only with positives"),G(_.red&&_.red===N.red,"red works only with red numbers")},k.prototype.imod=function(_){return this.prime?this.prime.ireduce(_)._forceRed(this):(J(_,_.umod(this.m)._forceRed(this)),_)},k.prototype.neg=function(_){return _.isZero()?_.clone():this.m.sub(_)._forceRed(this)},k.prototype.add=function(_,N){this._verify2(_,N);var x=_.add(N);return x.cmp(this.m)>=0&&x.isub(this.m),x._forceRed(this)},k.prototype.iadd=function(_,N){this._verify2(_,N);var x=_.iadd(N);return x.cmp(this.m)>=0&&x.isub(this.m),x},k.prototype.sub=function(_,N){this._verify2(_,N);var x=_.sub(N);return x.cmpn(0)<0&&x.iadd(this.m),x._forceRed(this)},k.prototype.isub=function(_,N){this._verify2(_,N);var x=_.isub(N);return x.cmpn(0)<0&&x.iadd(this.m),x},k.prototype.shl=function(_,N){return this._verify1(_),this.imod(_.ushln(N))},k.prototype.imul=function(_,N){return this._verify2(_,N),this.imod(_.imul(N))},k.prototype.mul=function(_,N){return this._verify2(_,N),this.imod(_.mul(N))},k.prototype.isqr=function(_){return this.imul(_,_.clone())},k.prototype.sqr=function(_){return this.mul(_,_)},k.prototype.sqrt=function(_){if(_.isZero())return _.clone();var N=this.m.andln(3);if(G(N%2===1),N===3){var x=this.m.add(new U(1)).iushrn(2);return this.pow(_,x)}for(var B=this.m.subn(1),y=0;!B.isZero()&&B.andln(1)===0;)y++,B.iushrn(1);G(!B.isZero());var w=new U(1).toRed(this),p=w.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new U(2*c*c).toRed(this);this.pow(c,f).cmp(p)!==0;)c.redIAdd(p);for(var h=this.pow(c,B),d=this.pow(_,B.addn(1).iushrn(1)),b=this.pow(_,B),l=y;b.cmp(w)!==0;){for(var o=b,u=0;o.cmp(w)!==0;u++)o=o.redSqr();G(u=0;y--){for(var h=N.words[y],d=c-1;d>=0;d--){var b=h>>d&1;if(w!==B[0]&&(w=this.sqr(w)),b===0&&p===0){f=0;continue}p<<=1,p|=b,f++,!(f!==x&&(y!==0||d!==0))&&(w=this.mul(w,B[p]),f=0,p=0)}c=26}return w},k.prototype.convertTo=function(_){var N=_.umod(this.m);return N===_?N.clone():N},k.prototype.convertFrom=function(_){var N=_.clone();return N.red=null,N},U.mont=function(_){return new g(_)};function g(_){k.call(this,_),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new U(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}V(g,k),g.prototype.convertTo=function(_){return this.imod(_.ushln(this.shift))},g.prototype.convertFrom=function(_){var N=this.imod(_.mul(this.rinv));return N.red=null,N},g.prototype.imul=function(_,N){if(_.isZero()||N.isZero())return _.words[0]=0,_.length=1,_;var x=_.imul(N),B=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=x.isub(B).iushrn(this.shift),w=y;return y.cmp(this.m)>=0?w=y.isub(this.m):y.cmpn(0)<0&&(w=y.iadd(this.m)),w._forceRed(this)},g.prototype.mul=function(_,N){if(_.isZero()||N.isZero())return new U(0)._forceRed(this);var x=_.mul(N),B=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=x.isub(B).iushrn(this.shift),w=y;return y.cmp(this.m)>=0?w=y.isub(this.m):y.cmpn(0)<0&&(w=y.iadd(this.m)),w._forceRed(this)},g.prototype.invm=function(_){var N=this.imod(_._invmp(this.m).mul(this.r2));return N._forceRed(this)}})(typeof Q>"u"||Q,$)}}),hQ=q$({"node_modules/browserify-rsa/index.js"($,Q){var Y=cQ(),Z=g$();function G(X){var K=V(X),I=K.toRed(Y.mont(X.modulus)).redPow(new Y(X.publicExponent)).fromRed();return{blinder:I,unblinder:K.invm(X.modulus)}}function V(X){var K=X.modulus.byteLength(),I;do I=new Y(Z(K));while(I.cmp(X.modulus)>=0||!I.umod(X.prime1)||!I.umod(X.prime2));return I}function U(X,K){var I=G(K),O=K.modulus.byteLength(),J=new Y(X).mul(I.blinder).umod(K.modulus),F=J.toRed(Y.mont(K.prime1)),A=J.toRed(Y.mont(K.prime2)),H=K.coefficient,W=K.prime1,E=K.prime2,T=F.redPow(K.exponent1).fromRed(),D=A.redPow(K.exponent2).fromRed(),C=T.isub(D).imul(H).umod(W).imul(E);return D.iadd(C).imul(I.unblinder).umod(K.modulus).toArrayLike(F$,"be",O)}U.getr=V,Q.exports=U}}),dQ=q$({"node_modules/elliptic/package.json"($,Q){Q.exports={name:"elliptic",version:"6.5.4",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}}}),bQ=q$({"node_modules/elliptic/node_modules/bn.js/lib/bn.js"($,Q){(function(Y,Z){function G(j,k){if(!j)throw new Error(k||"Assertion failed")}function V(j,k){j.super_=k;var g=function(){};g.prototype=k.prototype,j.prototype=new g,j.prototype.constructor=j}function U(j,k,g){if(U.isBN(j))return j;this.negative=0,this.words=null,this.length=0,this.red=null,j!==null&&((k==="le"||k==="be")&&(g=k,k=10),this._init(j||0,k||10,g||"be"))}typeof Y=="object"?Y.exports=U:Z.BN=U,U.BN=U,U.wordSize=26;var X=F$;U.isBN=function(j){return j instanceof U?!0:j!==null&&typeof j=="object"&&j.constructor.wordSize===U.wordSize&&Array.isArray(j.words)},U.max=function(j,k){return j.cmp(k)>0?j:k},U.min=function(j,k){return j.cmp(k)<0?j:k},U.prototype._init=function(j,k,g){if(typeof j=="number")return this._initNumber(j,k,g);if(typeof j=="object")return this._initArray(j,k,g);k==="hex"&&(k=16),G(k===(k|0)&&k>=2&&k<=36),j=j.toString().replace(/\s+/g,"");var _=0;j[0]==="-"&&(_++,this.negative=1),_=0;_-=3)x=j[_]|j[_-1]<<8|j[_-2]<<16,this.words[N]|=x<>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);else if(g==="le")for(_=0,N=0;_>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);return this.strip()};function K(j,k){var g=j.charCodeAt(k);return g>=65&&g<=70?g-55:g>=97&&g<=102?g-87:g-48&15}function I(j,k,g){var _=K(j,g);return g-1>=k&&(_|=K(j,g-1)<<4),_}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var _=0;_=k;_-=2)B=I(j,k,_)<=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8;else{var y=j.length-k;for(_=y%2===0?k+1:k;_=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8}this.strip()};function O(j,k,g,_){for(var N=0,x=Math.min(j.length,g),B=k;B=49?N+=y-49+10:y>=17?N+=y-17+10:N+=y}return N}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var _=0,N=1;N<=67108863;N*=k)_++;_--,N=N/k|0;for(var x=j.length-g,B=x%_,y=Math.min(x,x-B)+g,w=0,p=g;p1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},U.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},U.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],F=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],A=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];U.prototype.toString=function(j,k){j=j||10,k=k|0||1;var g;if(j===16||j==="hex"){g="";for(var _=0,N=0,x=0;x>>24-_&16777215,N!==0||x!==this.length-1?g=J[6-y.length]+y+g:g=y+g,_+=2,_>=26&&(_-=26,x--)}for(N!==0&&(g=N.toString(16)+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}if(j===(j|0)&&j>=2&&j<=36){var w=F[j],p=A[j];g="";var f=this.clone();for(f.negative=0;!f.isZero();){var c=f.modn(p).toString(j);f=f.idivn(p),f.isZero()?g=c+g:g=J[w-c.length]+c+g}for(this.isZero()&&(g="0"+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}G(!1,"Base should be between 2 and 36")},U.prototype.toNumber=function(){var j=this.words[0];return this.length===2?j+=this.words[1]*67108864:this.length===3&&this.words[2]===1?j+=4503599627370496+this.words[1]*67108864:this.length>2&&G(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-j:j},U.prototype.toJSON=function(){return this.toString(16)},U.prototype.toBuffer=function(j,k){return G(typeof X<"u"),this.toArrayLike(X,j,k)},U.prototype.toArray=function(j,k){return this.toArrayLike(Array,j,k)},U.prototype.toArrayLike=function(j,k,g){var _=this.byteLength(),N=g||Math.max(1,_);G(_<=N,"byte array longer than desired length"),G(N>0,"Requested array length <= 0"),this.strip();var x=k==="le",B=new j(N),y,w,p=this.clone();if(x){for(w=0;!p.isZero();w++)y=p.andln(255),p.iushrn(8),B[w]=y;for(;w=4096&&(g+=13,k>>>=13),k>=64&&(g+=7,k>>>=7),k>=8&&(g+=4,k>>>=4),k>=2&&(g+=2,k>>>=2),g+k},U.prototype._zeroBits=function(j){if(j===0)return 26;var k=j,g=0;return(k&8191)===0&&(g+=13,k>>>=13),(k&127)===0&&(g+=7,k>>>=7),(k&15)===0&&(g+=4,k>>>=4),(k&3)===0&&(g+=2,k>>>=2),(k&1)===0&&g++,g},U.prototype.bitLength=function(){var j=this.words[this.length-1],k=this._countBits(j);return(this.length-1)*26+k};function H(j){for(var k=new Array(j.bitLength()),g=0;g>>N}return k}U.prototype.zeroBits=function(){if(this.isZero())return 0;for(var j=0,k=0;kj.length?this.clone().ior(j):j.clone().ior(this)},U.prototype.uor=function(j){return this.length>j.length?this.clone().iuor(j):j.clone().iuor(this)},U.prototype.iuand=function(j){var k;this.length>j.length?k=j:k=this;for(var g=0;gj.length?this.clone().iand(j):j.clone().iand(this)},U.prototype.uand=function(j){return this.length>j.length?this.clone().iuand(j):j.clone().iuand(this)},U.prototype.iuxor=function(j){var k,g;this.length>j.length?(k=this,g=j):(k=j,g=this);for(var _=0;_j.length?this.clone().ixor(j):j.clone().ixor(this)},U.prototype.uxor=function(j){return this.length>j.length?this.clone().iuxor(j):j.clone().iuxor(this)},U.prototype.inotn=function(j){G(typeof j=="number"&&j>=0);var k=Math.ceil(j/26)|0,g=j%26;this._expand(k),g>0&&k--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-g),this.strip()},U.prototype.notn=function(j){return this.clone().inotn(j)},U.prototype.setn=function(j,k){G(typeof j=="number"&&j>=0);var g=j/26|0,_=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<<_:this.words[g]=this.words[g]&~(1<<_),this.strip()},U.prototype.iadd=function(j){var k;if(this.negative!==0&&j.negative===0)return this.negative=0,k=this.isub(j),this.negative^=1,this._normSign();if(this.negative===0&&j.negative!==0)return j.negative=0,k=this.isub(j),j.negative=1,k._normSign();var g,_;this.length>j.length?(g=this,_=j):(g=j,_=this);for(var N=0,x=0;x<_.length;x++)k=(g.words[x]|0)+(_.words[x]|0)+N,this.words[x]=k&67108863,N=k>>>26;for(;N!==0&&x>>26;if(this.length=g.length,N!==0)this.words[this.length]=N,this.length++;else if(g!==this)for(;xj.length?this.clone().iadd(j):j.clone().iadd(this)},U.prototype.isub=function(j){if(j.negative!==0){j.negative=0;var k=this.iadd(j);return j.negative=1,k._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(j),this.negative=1,this._normSign();var g=this.cmp(j);if(g===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,N;g>0?(_=this,N=j):(_=j,N=this);for(var x=0,B=0;B>26,this.words[B]=k&67108863;for(;x!==0&&B<_.length;B++)k=(_.words[B]|0)+x,x=k>>26,this.words[B]=k&67108863;if(x===0&&B<_.length&&_!==this)for(;B<_.length;B++)this.words[B]=_.words[B];return this.length=Math.max(this.length,B),_!==this&&(this.negative=1),this.strip()},U.prototype.sub=function(j){return this.clone().isub(j)};function W(j,k,g){g.negative=k.negative^j.negative;var _=j.length+k.length|0;g.length=_,_=_-1|0;var N=j.words[0]|0,x=k.words[0]|0,B=N*x,y=B&67108863,w=B/67108864|0;g.words[0]=y;for(var p=1;p<_;p++){for(var f=w>>>26,c=w&67108863,h=Math.min(p,k.length-1),d=Math.max(0,p-j.length+1);d<=h;d++){var b=p-d|0;N=j.words[b]|0,x=k.words[d]|0,B=N*x+c,f+=B/67108864|0,c=B&67108863}g.words[p]=c|0,w=f|0}return w!==0?g.words[p]=w|0:g.length--,g.strip()}var E=function(j,k,g){var _=j.words,N=k.words,x=g.words,B=0,y,w,p,f=_[0]|0,c=f&8191,h=f>>>13,d=_[1]|0,b=d&8191,l=d>>>13,o=_[2]|0,u=o&8191,n=o>>>13,s=_[3]|0,t=s&8191,m=s>>>13,a=_[4]|0,e=a&8191,r=a>>>13,i=_[5]|0,$0=i&8191,Q0=i>>>13,Y0=_[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=_[7]|0,U0=V0&8191,X0=V0>>>13,K0=_[8]|0,I0=K0&8191,O0=K0>>>13,J0=_[9]|0,F0=J0&8191,A0=J0>>>13,H0=N[0]|0,W0=H0&8191,E0=H0>>>13,T0=N[1]|0,D0=T0&8191,C0=T0>>>13,L0=N[2]|0,R0=L0&8191,P0=L0>>>13,z0=N[3]|0,M0=z0&8191,S0=z0>>>13,v0=N[4]|0,q0=v0&8191,j0=v0>>>13,k0=N[5]|0,g0=k0&8191,_0=k0>>>13,N0=N[6]|0,x0=N0&8191,B0=N0>>>13,y0=N[7]|0,w0=y0&8191,p0=y0>>>13,f0=N[8]|0,c0=f0&8191,h0=f0>>>13,d0=N[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,W0),w=Math.imul(c,E0),w=w+Math.imul(h,W0)|0,p=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,W0),w=Math.imul(b,E0),w=w+Math.imul(l,W0)|0,p=Math.imul(l,E0),y=y+Math.imul(c,D0)|0,w=w+Math.imul(c,C0)|0,w=w+Math.imul(h,D0)|0,p=p+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,W0),w=Math.imul(u,E0),w=w+Math.imul(n,W0)|0,p=Math.imul(n,E0),y=y+Math.imul(b,D0)|0,w=w+Math.imul(b,C0)|0,w=w+Math.imul(l,D0)|0,p=p+Math.imul(l,C0)|0,y=y+Math.imul(c,R0)|0,w=w+Math.imul(c,P0)|0,w=w+Math.imul(h,R0)|0,p=p+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,W0),w=Math.imul(t,E0),w=w+Math.imul(m,W0)|0,p=Math.imul(m,E0),y=y+Math.imul(u,D0)|0,w=w+Math.imul(u,C0)|0,w=w+Math.imul(n,D0)|0,p=p+Math.imul(n,C0)|0,y=y+Math.imul(b,R0)|0,w=w+Math.imul(b,P0)|0,w=w+Math.imul(l,R0)|0,p=p+Math.imul(l,P0)|0,y=y+Math.imul(c,M0)|0,w=w+Math.imul(c,S0)|0,w=w+Math.imul(h,M0)|0,p=p+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(e,W0),w=Math.imul(e,E0),w=w+Math.imul(r,W0)|0,p=Math.imul(r,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,p=p+Math.imul(m,C0)|0,y=y+Math.imul(u,R0)|0,w=w+Math.imul(u,P0)|0,w=w+Math.imul(n,R0)|0,p=p+Math.imul(n,P0)|0,y=y+Math.imul(b,M0)|0,w=w+Math.imul(b,S0)|0,w=w+Math.imul(l,M0)|0,p=p+Math.imul(l,S0)|0,y=y+Math.imul(c,q0)|0,w=w+Math.imul(c,j0)|0,w=w+Math.imul(h,q0)|0,p=p+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,W0),w=Math.imul($0,E0),w=w+Math.imul(Q0,W0)|0,p=Math.imul(Q0,E0),y=y+Math.imul(e,D0)|0,w=w+Math.imul(e,C0)|0,w=w+Math.imul(r,D0)|0,p=p+Math.imul(r,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,p=p+Math.imul(m,P0)|0,y=y+Math.imul(u,M0)|0,w=w+Math.imul(u,S0)|0,w=w+Math.imul(n,M0)|0,p=p+Math.imul(n,S0)|0,y=y+Math.imul(b,q0)|0,w=w+Math.imul(b,j0)|0,w=w+Math.imul(l,q0)|0,p=p+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,_0)|0,w=w+Math.imul(h,g0)|0,p=p+Math.imul(h,_0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,W0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,W0)|0,p=Math.imul(G0,E0),y=y+Math.imul($0,D0)|0,w=w+Math.imul($0,C0)|0,w=w+Math.imul(Q0,D0)|0,p=p+Math.imul(Q0,C0)|0,y=y+Math.imul(e,R0)|0,w=w+Math.imul(e,P0)|0,w=w+Math.imul(r,R0)|0,p=p+Math.imul(r,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,p=p+Math.imul(m,S0)|0,y=y+Math.imul(u,q0)|0,w=w+Math.imul(u,j0)|0,w=w+Math.imul(n,q0)|0,p=p+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,_0)|0,w=w+Math.imul(l,g0)|0,p=p+Math.imul(l,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,x0)|0,p=p+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,W0),w=Math.imul(U0,E0),w=w+Math.imul(X0,W0)|0,p=Math.imul(X0,E0),y=y+Math.imul(Z0,D0)|0,w=w+Math.imul(Z0,C0)|0,w=w+Math.imul(G0,D0)|0,p=p+Math.imul(G0,C0)|0,y=y+Math.imul($0,R0)|0,w=w+Math.imul($0,P0)|0,w=w+Math.imul(Q0,R0)|0,p=p+Math.imul(Q0,P0)|0,y=y+Math.imul(e,M0)|0,w=w+Math.imul(e,S0)|0,w=w+Math.imul(r,M0)|0,p=p+Math.imul(r,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,p=p+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,_0)|0,w=w+Math.imul(n,g0)|0,p=p+Math.imul(n,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,x0)|0,p=p+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,p0)|0,w=w+Math.imul(h,w0)|0,p=p+Math.imul(h,p0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(I0,W0),w=Math.imul(I0,E0),w=w+Math.imul(O0,W0)|0,p=Math.imul(O0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,p=p+Math.imul(X0,C0)|0,y=y+Math.imul(Z0,R0)|0,w=w+Math.imul(Z0,P0)|0,w=w+Math.imul(G0,R0)|0,p=p+Math.imul(G0,P0)|0,y=y+Math.imul($0,M0)|0,w=w+Math.imul($0,S0)|0,w=w+Math.imul(Q0,M0)|0,p=p+Math.imul(Q0,S0)|0,y=y+Math.imul(e,q0)|0,w=w+Math.imul(e,j0)|0,w=w+Math.imul(r,q0)|0,p=p+Math.imul(r,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,_0)|0,w=w+Math.imul(m,g0)|0,p=p+Math.imul(m,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,x0)|0,p=p+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,p0)|0,w=w+Math.imul(l,w0)|0,p=p+Math.imul(l,p0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,p=p+Math.imul(h,h0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(F0,W0),w=Math.imul(F0,E0),w=w+Math.imul(A0,W0)|0,p=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(O0,D0)|0,p=p+Math.imul(O0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,p=p+Math.imul(X0,P0)|0,y=y+Math.imul(Z0,M0)|0,w=w+Math.imul(Z0,S0)|0,w=w+Math.imul(G0,M0)|0,p=p+Math.imul(G0,S0)|0,y=y+Math.imul($0,q0)|0,w=w+Math.imul($0,j0)|0,w=w+Math.imul(Q0,q0)|0,p=p+Math.imul(Q0,j0)|0,y=y+Math.imul(e,g0)|0,w=w+Math.imul(e,_0)|0,w=w+Math.imul(r,g0)|0,p=p+Math.imul(r,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,x0)|0,p=p+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,p0)|0,w=w+Math.imul(n,w0)|0,p=p+Math.imul(n,p0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,p=p+Math.imul(l,h0)|0,y=y+Math.imul(c,b0)|0,w=w+Math.imul(c,l0)|0,w=w+Math.imul(h,b0)|0,p=p+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(i0>>>26)|0,i0&=67108863,y=Math.imul(F0,D0),w=Math.imul(F0,C0),w=w+Math.imul(A0,D0)|0,p=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(O0,R0)|0,p=p+Math.imul(O0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,p=p+Math.imul(X0,S0)|0,y=y+Math.imul(Z0,q0)|0,w=w+Math.imul(Z0,j0)|0,w=w+Math.imul(G0,q0)|0,p=p+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,_0)|0,w=w+Math.imul(Q0,g0)|0,p=p+Math.imul(Q0,_0)|0,y=y+Math.imul(e,x0)|0,w=w+Math.imul(e,B0)|0,w=w+Math.imul(r,x0)|0,p=p+Math.imul(r,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,p0)|0,w=w+Math.imul(m,w0)|0,p=p+Math.imul(m,p0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,p=p+Math.imul(n,h0)|0,y=y+Math.imul(b,b0)|0,w=w+Math.imul(b,l0)|0,w=w+Math.imul(l,b0)|0,p=p+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,p=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(O0,M0)|0,p=p+Math.imul(O0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,p=p+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,_0)|0,w=w+Math.imul(G0,g0)|0,p=p+Math.imul(G0,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,x0)|0,p=p+Math.imul(Q0,B0)|0,y=y+Math.imul(e,w0)|0,w=w+Math.imul(e,p0)|0,w=w+Math.imul(r,w0)|0,p=p+Math.imul(r,p0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,p=p+Math.imul(m,h0)|0,y=y+Math.imul(u,b0)|0,w=w+Math.imul(u,l0)|0,w=w+Math.imul(n,b0)|0,p=p+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,y=Math.imul(F0,M0),w=Math.imul(F0,S0),w=w+Math.imul(A0,M0)|0,p=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(O0,q0)|0,p=p+Math.imul(O0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,_0)|0,w=w+Math.imul(X0,g0)|0,p=p+Math.imul(X0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,x0)|0,p=p+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,p0)|0,w=w+Math.imul(Q0,w0)|0,p=p+Math.imul(Q0,p0)|0,y=y+Math.imul(e,c0)|0,w=w+Math.imul(e,h0)|0,w=w+Math.imul(r,c0)|0,p=p+Math.imul(r,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,p=p+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,y=Math.imul(F0,q0),w=Math.imul(F0,j0),w=w+Math.imul(A0,q0)|0,p=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,_0)|0,w=w+Math.imul(O0,g0)|0,p=p+Math.imul(O0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,x0)|0,p=p+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,p0)|0,w=w+Math.imul(G0,w0)|0,p=p+Math.imul(G0,p0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,p=p+Math.imul(Q0,h0)|0,y=y+Math.imul(e,b0)|0,w=w+Math.imul(e,l0)|0,w=w+Math.imul(r,b0)|0,p=p+Math.imul(r,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,_0),w=w+Math.imul(A0,g0)|0,p=Math.imul(A0,_0),y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(O0,x0)|0,p=p+Math.imul(O0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,p0)|0,w=w+Math.imul(X0,w0)|0,p=p+Math.imul(X0,p0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,p=p+Math.imul(G0,h0)|0,y=y+Math.imul($0,b0)|0,w=w+Math.imul($0,l0)|0,w=w+Math.imul(Q0,b0)|0,p=p+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,x0),w=Math.imul(F0,B0),w=w+Math.imul(A0,x0)|0,p=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,p0)|0,w=w+Math.imul(O0,w0)|0,p=p+Math.imul(O0,p0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,p=p+Math.imul(X0,h0)|0,y=y+Math.imul(Z0,b0)|0,w=w+Math.imul(Z0,l0)|0,w=w+Math.imul(G0,b0)|0,p=p+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,p0),w=w+Math.imul(A0,w0)|0,p=Math.imul(A0,p0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(O0,c0)|0,p=p+Math.imul(O0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,p=p+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(U$>>>26)|0,U$&=67108863,y=Math.imul(F0,c0),w=Math.imul(F0,h0),w=w+Math.imul(A0,c0)|0,p=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(O0,b0)|0,p=p+Math.imul(O0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(X$>>>26)|0,X$&=67108863,y=Math.imul(F0,b0),w=Math.imul(F0,l0),w=w+Math.imul(A0,b0)|0,p=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(p+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,x[0]=o0,x[1]=u0,x[2]=n0,x[3]=s0,x[4]=t0,x[5]=m0,x[6]=a0,x[7]=e0,x[8]=r0,x[9]=i0,x[10]=$$,x[11]=Q$,x[12]=Y$,x[13]=Z$,x[14]=G$,x[15]=V$,x[16]=U$,x[17]=X$,x[18]=K$,B!==0&&(x[19]=B,g.length++),g};Math.imul||(E=W);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var _=0,N=0,x=0;x>>26)|0,N+=B>>>26,B&=67108863}g.words[x]=y,_=B,B=N}return _!==0?g.words[x]=_:g.length--,g.strip()}function D(j,k,g){var _=new C;return _.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,_=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):_<63?g=W(this,j,k):_<1024?g=T(this,j,k):g=D(this,j,k),g};function C(j,k){this.x=j,this.y=k}C.prototype.makeRBT=function(j){for(var k=new Array(j),g=U.prototype._countBits(j)-1,_=0;_>=1;return _},C.prototype.permute=function(j,k,g,_,N,x){for(var B=0;B>>1)N++;return 1<>>13,g[2*x+1]=N&8191,N=N>>>13;for(x=2*k;x<_;++x)g[x]=0;G(N===0),G((N&-8192)===0)},C.prototype.stub=function(j){for(var k=new Array(j),g=0;g>=26,k+=_/67108864|0,k+=N>>>26,this.words[g]=N&67108863}return k!==0&&(this.words[g]=k,this.length++),this},U.prototype.muln=function(j){return this.clone().imuln(j)},U.prototype.sqr=function(){return this.mul(this)},U.prototype.isqr=function(){return this.imul(this.clone())},U.prototype.pow=function(j){var k=H(j);if(k.length===0)return new U(1);for(var g=this,_=0;_=0);var k=j%26,g=(j-k)/26,_=67108863>>>26-k<<26-k,N;if(k!==0){var x=0;for(N=0;N>>26-k}x&&(this.words[N]=x,this.length++)}if(g!==0){for(N=this.length-1;N>=0;N--)this.words[N+g]=this.words[N];for(N=0;N=0);var _;k?_=(k-k%26)/26:_=0;var N=j%26,x=Math.min((j-N)/26,this.length),B=67108863^67108863>>>N<x)for(this.length-=x,w=0;w=0&&(p!==0||w>=_);w--){var f=this.words[w]|0;this.words[w]=p<<26-N|f>>>N,p=f&B}return y&&p!==0&&(y.words[y.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},U.prototype.ishrn=function(j,k,g){return G(this.negative===0),this.iushrn(j,k,g)},U.prototype.shln=function(j){return this.clone().ishln(j)},U.prototype.ushln=function(j){return this.clone().iushln(j)},U.prototype.shrn=function(j){return this.clone().ishrn(j)},U.prototype.ushrn=function(j){return this.clone().iushrn(j)},U.prototype.testn=function(j){G(typeof j=="number"&&j>=0);var k=j%26,g=(j-k)/26,_=1<=0);var k=j%26,g=(j-k)/26;if(G(this.negative===0,"imaskn works only with positive numbers"),this.length<=g)return this;if(k!==0&&g++,this.length=Math.min(g,this.length),k!==0){var _=67108863^67108863>>>k<=67108864;k++)this.words[k]-=67108864,k===this.length-1?this.words[k+1]=1:this.words[k+1]++;return this.length=Math.max(this.length,k+1),this},U.prototype.isubn=function(j){if(G(typeof j=="number"),G(j<67108864),j<0)return this.iaddn(-j);if(this.negative!==0)return this.negative=0,this.iaddn(j),this.negative=1,this;if(this.words[0]-=j,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var k=0;k>26)-(y/67108864|0),this.words[N+g]=x&67108863}for(;N>26,this.words[N+g]=x&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,_=this.clone(),N=j,x=N.words[N.length-1]|0,B=this._countBits(x);g=26-B,g!==0&&(N=N.ushln(g),_.iushln(g),x=N.words[N.length-1]|0);var y=_.length-N.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var p=0;p=0;c--){var h=(_.words[N.length+c]|0)*67108864+(_.words[N.length+c-1]|0);for(h=Math.min(h/x|0,67108863),_._ishlnsubmul(N,h,c);_.negative!==0;)h--,_.negative=0,_._ishlnsubmul(N,1,c),_.isZero()||(_.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),_.strip(),k!=="div"&&g!==0&&_.iushrn(g),{div:w||null,mod:_}},U.prototype.divmod=function(j,k,g){if(G(!j.isZero()),this.isZero())return{div:new U(0),mod:new U(0)};var _,N,x;return this.negative!==0&&j.negative===0?(x=this.neg().divmod(j,k),k!=="mod"&&(_=x.div.neg()),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.iadd(j)),{div:_,mod:N}):this.negative===0&&j.negative!==0?(x=this.divmod(j.neg(),k),k!=="mod"&&(_=x.div.neg()),{div:_,mod:x.mod}):(this.negative&j.negative)!==0?(x=this.neg().divmod(j.neg(),k),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.isub(j)),{div:x.div,mod:N}):j.length>this.length||this.cmp(j)<0?{div:new U(0),mod:this}:j.length===1?k==="div"?{div:this.divn(j.words[0]),mod:null}:k==="mod"?{div:null,mod:new U(this.modn(j.words[0]))}:{div:this.divn(j.words[0]),mod:new U(this.modn(j.words[0]))}:this._wordDiv(j,k)},U.prototype.div=function(j){return this.divmod(j,"div",!1).div},U.prototype.mod=function(j){return this.divmod(j,"mod",!1).mod},U.prototype.umod=function(j){return this.divmod(j,"mod",!0).mod},U.prototype.divRound=function(j){var k=this.divmod(j);if(k.mod.isZero())return k.div;var g=k.div.negative!==0?k.mod.isub(j):k.mod,_=j.ushrn(1),N=j.andln(1),x=g.cmp(_);return x<0||N===1&&x===0?k.div:k.div.negative!==0?k.div.isubn(1):k.div.iaddn(1)},U.prototype.modn=function(j){G(j<=67108863);for(var k=(1<<26)%j,g=0,_=this.length-1;_>=0;_--)g=(k*g+(this.words[_]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var _=(this.words[g]|0)+k*67108864;this.words[g]=_/j|0,k=_%j}return this.strip()},U.prototype.divn=function(j){return this.clone().idivn(j)},U.prototype.egcd=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=new U(0),B=new U(1),y=0;k.isEven()&&g.isEven();)k.iushrn(1),g.iushrn(1),++y;for(var w=g.clone(),p=k.clone();!k.isZero();){for(var f=0,c=1;(k.words[0]&c)===0&&f<26;++f,c<<=1);if(f>0)for(k.iushrn(f);f-- >0;)(_.isOdd()||N.isOdd())&&(_.iadd(w),N.isub(p)),_.iushrn(1),N.iushrn(1);for(var h=0,d=1;(g.words[0]&d)===0&&h<26;++h,d<<=1);if(h>0)for(g.iushrn(h);h-- >0;)(x.isOdd()||B.isOdd())&&(x.iadd(w),B.isub(p)),x.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(x),N.isub(B)):(g.isub(k),x.isub(_),B.isub(N))}return{a:x,b:B,gcd:g.iushln(y)}},U.prototype._invmp=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=g.clone();k.cmpn(1)>0&&g.cmpn(1)>0;){for(var B=0,y=1;(k.words[0]&y)===0&&B<26;++B,y<<=1);if(B>0)for(k.iushrn(B);B-- >0;)_.isOdd()&&_.iadd(x),_.iushrn(1);for(var w=0,p=1;(g.words[0]&p)===0&&w<26;++w,p<<=1);if(w>0)for(g.iushrn(w);w-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(N)):(g.isub(k),N.isub(_))}var f;return k.cmpn(1)===0?f=_:f=N,f.cmpn(0)<0&&f.iadd(j),f},U.prototype.gcd=function(j){if(this.isZero())return j.abs();if(j.isZero())return this.abs();var k=this.clone(),g=j.clone();k.negative=0,g.negative=0;for(var _=0;k.isEven()&&g.isEven();_++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var N=k.cmp(g);if(N<0){var x=k;k=g,g=x}else if(N===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(_)},U.prototype.invm=function(j){return this.egcd(j).a.umod(j)},U.prototype.isEven=function(){return(this.words[0]&1)===0},U.prototype.isOdd=function(){return(this.words[0]&1)===1},U.prototype.andln=function(j){return this.words[0]&j},U.prototype.bincn=function(j){G(typeof j=="number");var k=j%26,g=(j-k)/26,_=1<>>26,B&=67108863,this.words[x]=B}return N!==0&&(this.words[x]=N,this.length++),this},U.prototype.isZero=function(){return this.length===1&&this.words[0]===0},U.prototype.cmpn=function(j){var k=j<0;if(this.negative!==0&&!k)return-1;if(this.negative===0&&k)return 1;this.strip();var g;if(this.length>1)g=1;else{k&&(j=-j),G(j<=67108863,"Number is too big");var _=this.words[0]|0;g=_===j?0:_j.length)return 1;if(this.length=0;g--){var _=this.words[g]|0,N=j.words[g]|0;if(_!==N){_N&&(k=1);break}}return k},U.prototype.gtn=function(j){return this.cmpn(j)===1},U.prototype.gt=function(j){return this.cmp(j)===1},U.prototype.gten=function(j){return this.cmpn(j)>=0},U.prototype.gte=function(j){return this.cmp(j)>=0},U.prototype.ltn=function(j){return this.cmpn(j)===-1},U.prototype.lt=function(j){return this.cmp(j)===-1},U.prototype.lten=function(j){return this.cmpn(j)<=0},U.prototype.lte=function(j){return this.cmp(j)<=0},U.prototype.eqn=function(j){return this.cmpn(j)===0},U.prototype.eq=function(j){return this.cmp(j)===0},U.red=function(j){return new v(j)},U.prototype.toRed=function(j){return G(!this.red,"Already a number in reduction context"),G(this.negative===0,"red works only with positives"),j.convertTo(this)._forceRed(j)},U.prototype.fromRed=function(){return G(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},U.prototype._forceRed=function(j){return this.red=j,this},U.prototype.forceRed=function(j){return G(!this.red,"Already a number in reduction context"),this._forceRed(j)},U.prototype.redAdd=function(j){return G(this.red,"redAdd works only with red numbers"),this.red.add(this,j)},U.prototype.redIAdd=function(j){return G(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,j)},U.prototype.redSub=function(j){return G(this.red,"redSub works only with red numbers"),this.red.sub(this,j)},U.prototype.redISub=function(j){return G(this.red,"redISub works only with red numbers"),this.red.isub(this,j)},U.prototype.redShl=function(j){return G(this.red,"redShl works only with red numbers"),this.red.shl(this,j)},U.prototype.redMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.mul(this,j)},U.prototype.redIMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.imul(this,j)},U.prototype.redSqr=function(){return G(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},U.prototype.redISqr=function(){return G(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},U.prototype.redSqrt=function(){return G(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},U.prototype.redInvm=function(){return G(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},U.prototype.redNeg=function(){return G(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},U.prototype.redPow=function(j){return G(this.red&&!j.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,j)};var L={k256:null,p224:null,p192:null,p25519:null};function R(j,k){this.name=j,this.p=new U(k,16),this.n=this.p.bitLength(),this.k=new U(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}R.prototype._tmp=function(){var j=new U(null);return j.words=new Array(Math.ceil(this.n/13)),j},R.prototype.ireduce=function(j){var k=j,g;do this.split(k,this.tmp),k=this.imulK(k),k=k.iadd(this.tmp),g=k.bitLength();while(g>this.n);var _=g0?k.isub(this.p):k.strip!==void 0?k.strip():k._strip(),k},R.prototype.split=function(j,k){j.iushrn(this.n,0,k)},R.prototype.imulK=function(j){return j.imul(this.k)};function P(){R.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}V(P,R),P.prototype.split=function(j,k){for(var g=4194303,_=Math.min(j.length,9),N=0;N<_;N++)k.words[N]=j.words[N];if(k.length=_,j.length<=9){j.words[0]=0,j.length=1;return}var x=j.words[9];for(k.words[k.length++]=x&g,N=10;N>>22,x=B}x>>>=22,j.words[N-10]=x,x===0&&j.length>10?j.length-=10:j.length-=9},P.prototype.imulK=function(j){j.words[j.length]=0,j.words[j.length+1]=0,j.length+=2;for(var k=0,g=0;g>>=26,j.words[g]=N,k=_}return k!==0&&(j.words[j.length++]=k),j},U._prime=function(j){if(L[j])return L[j];var k;if(j==="k256")k=new P;else if(j==="p224")k=new z;else if(j==="p192")k=new M;else if(j==="p25519")k=new S;else throw new Error("Unknown prime "+j);return L[j]=k,k};function v(j){if(typeof j=="string"){var k=U._prime(j);this.m=k.p,this.prime=k}else G(j.gtn(1),"modulus must be greater than 1"),this.m=j,this.prime=null}v.prototype._verify1=function(j){G(j.negative===0,"red works only with positives"),G(j.red,"red works only with red numbers")},v.prototype._verify2=function(j,k){G((j.negative|k.negative)===0,"red works only with positives"),G(j.red&&j.red===k.red,"red works only with red numbers")},v.prototype.imod=function(j){return this.prime?this.prime.ireduce(j)._forceRed(this):j.umod(this.m)._forceRed(this)},v.prototype.neg=function(j){return j.isZero()?j.clone():this.m.sub(j)._forceRed(this)},v.prototype.add=function(j,k){this._verify2(j,k);var g=j.add(k);return g.cmp(this.m)>=0&&g.isub(this.m),g._forceRed(this)},v.prototype.iadd=function(j,k){this._verify2(j,k);var g=j.iadd(k);return g.cmp(this.m)>=0&&g.isub(this.m),g},v.prototype.sub=function(j,k){this._verify2(j,k);var g=j.sub(k);return g.cmpn(0)<0&&g.iadd(this.m),g._forceRed(this)},v.prototype.isub=function(j,k){this._verify2(j,k);var g=j.isub(k);return g.cmpn(0)<0&&g.iadd(this.m),g},v.prototype.shl=function(j,k){return this._verify1(j),this.imod(j.ushln(k))},v.prototype.imul=function(j,k){return this._verify2(j,k),this.imod(j.imul(k))},v.prototype.mul=function(j,k){return this._verify2(j,k),this.imod(j.mul(k))},v.prototype.isqr=function(j){return this.imul(j,j.clone())},v.prototype.sqr=function(j){return this.mul(j,j)},v.prototype.sqrt=function(j){if(j.isZero())return j.clone();var k=this.m.andln(3);if(G(k%2===1),k===3){var g=this.m.add(new U(1)).iushrn(2);return this.pow(j,g)}for(var _=this.m.subn(1),N=0;!_.isZero()&&_.andln(1)===0;)N++,_.iushrn(1);G(!_.isZero());var x=new U(1).toRed(this),B=x.redNeg(),y=this.m.subn(1).iushrn(1),w=this.m.bitLength();for(w=new U(2*w*w).toRed(this);this.pow(w,y).cmp(B)!==0;)w.redIAdd(B);for(var p=this.pow(w,_),f=this.pow(j,_.addn(1).iushrn(1)),c=this.pow(j,_),h=N;c.cmp(x)!==0;){for(var d=c,b=0;d.cmp(x)!==0;b++)d=d.redSqr();G(b=0;N--){for(var p=k.words[N],f=w-1;f>=0;f--){var c=p>>f&1;if(x!==_[0]&&(x=this.sqr(x)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(N!==0||f!==0))&&(x=this.mul(x,_[B]),y=0,B=0)}w=26}return x},v.prototype.convertTo=function(j){var k=j.umod(this.m);return k===j?k.clone():k},v.prototype.convertFrom=function(j){var k=j.clone();return k.red=null,k},U.mont=function(j){return new q(j)};function q(j){v.call(this,j),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new U(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}V(q,v),q.prototype.convertTo=function(j){return this.imod(j.ushln(this.shift))},q.prototype.convertFrom=function(j){var k=this.imod(j.mul(this.rinv));return k.red=null,k},q.prototype.imul=function(j,k){if(j.isZero()||k.isZero())return j.words[0]=0,j.length=1,j;var g=j.imul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.invm=function(j){var k=this.imod(j._invmp(this.m).mul(this.r2));return k._forceRed(this)}})(typeof Q>"u"||Q,$)}}),lQ=q$({"node_modules/minimalistic-crypto-utils/lib/utils.js"($){var Q=$;function Y(V,U){if(Array.isArray(V))return V.slice();if(!V)return[];var X=[];if(typeof V!="string"){for(var K=0;K>8,J=I&255;O?X.push(O,J):X.push(J)}return X}Q.toArray=Y;function Z(V){return V.length===1?"0"+V:V}Q.zero2=Z;function G(V){for(var U="",X=0;X(H>>1)-1?T=(H>>1)-D:T=D,W.isubn(T)):T=0,A[E]=T,W.iushrn(1)}return A}Q.getNAF=V;function U(O,J){var F=[[],[]];O=O.clone(),J=J.clone();for(var A=0,H=0,W;O.cmpn(-A)>0||J.cmpn(-H)>0;){var E=O.andln(3)+A&3,T=J.andln(3)+H&3;E===3&&(E=-1),T===3&&(T=-1);var D;(E&1)===0?D=0:(W=O.andln(7)+A&7,(W===3||W===5)&&T===2?D=-E:D=E),F[0].push(D);var C;(T&1)===0?C=0:(W=J.andln(7)+H&7,(W===3||W===5)&&E===2?C=-T:C=T),F[1].push(C),2*A===D+1&&(A=1-A),2*H===C+1&&(H=1-H),O.iushrn(1),J.iushrn(1)}return F}Q.getJSF=U;function X(O,J,F){var A="_"+J;O.prototype[J]=function(){return this[A]!==void 0?this[A]:this[A]=F.call(this)}}Q.cachedProperty=X;function K(O){return typeof O=="string"?Q.toArray(O,"hex"):O}Q.parseBytes=K;function I(O){return new Y(O,"hex","le")}Q.intFromLE=I}}),uQ=q$({"node_modules/elliptic/lib/elliptic/curve/base.js"($,Q){var Y=bQ(),Z=oQ(),G=Z.getNAF,V=Z.getJSF,U=Z.assert;function X(I,O){this.type=I,this.p=new Y(O.p,16),this.red=O.prime?Y.red(O.prime):Y.mont(this.p),this.zero=new Y(0).toRed(this.red),this.one=new Y(1).toRed(this.red),this.two=new Y(2).toRed(this.red),this.n=O.n&&new Y(O.n,16),this.g=O.g&&this.pointFromJSON(O.g,O.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var J=this.n&&this.p.div(this.n);!J||J.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Q.exports=X,X.prototype.point=function(){throw new Error("Not implemented")},X.prototype.validate=function(){throw new Error("Not implemented")},X.prototype._fixedNafMul=function(I,O){U(I.precomputed);var J=I._getDoubles(),F=G(O,1,this._bitLength),A=(1<=W;T--)E=(E<<1)+F[T];H.push(E)}for(var D=this.jpoint(null,null,null),C=this.jpoint(null,null,null),L=A;L>0;L--){for(W=0;W=0;E--){for(var T=0;E>=0&&H[E]===0;E--)T++;if(E>=0&&T++,W=W.dblp(T),E<0)break;var D=H[E];U(D!==0),I.type==="affine"?D>0?W=W.mixedAdd(A[D-1>>1]):W=W.mixedAdd(A[-D-1>>1].neg()):D>0?W=W.add(A[D-1>>1]):W=W.add(A[-D-1>>1].neg())}return I.type==="affine"?W.toP():W},X.prototype._wnafMulAdd=function(I,O,J,F,A){var H=this._wnafT1,W=this._wnafT2,E=this._wnafT3,T=0,D,C,L;for(D=0;D=1;D-=2){var P=D-1,z=D;if(H[P]!==1||H[z]!==1){E[P]=G(J[P],H[P],this._bitLength),E[z]=G(J[z],H[z],this._bitLength),T=Math.max(E[P].length,T),T=Math.max(E[z].length,T);continue}var M=[O[P],null,null,O[z]];O[P].y.cmp(O[z].y)===0?(M[1]=O[P].add(O[z]),M[2]=O[P].toJ().mixedAdd(O[z].neg())):O[P].y.cmp(O[z].y.redNeg())===0?(M[1]=O[P].toJ().mixedAdd(O[z]),M[2]=O[P].add(O[z].neg())):(M[1]=O[P].toJ().mixedAdd(O[z]),M[2]=O[P].toJ().mixedAdd(O[z].neg()));var S=[-3,-1,-5,-7,0,7,5,1,3],v=V(J[P],J[z]);for(T=Math.max(v[0].length,T),E[P]=new Array(T),E[z]=new Array(T),C=0;C=0;D--){for(var _=0;D>=0;){var N=!0;for(C=0;C=0&&_++,k=k.dblp(_),D<0)break;for(C=0;C0?L=W[C][x-1>>1]:x<0&&(L=W[C][-x-1>>1].neg()),L.type==="affine"?k=k.mixedAdd(L):k=k.add(L))}}for(D=0;D=Math.ceil((I.bitLength()+1)/O.step):!1},K.prototype._getDoubles=function(I,O){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var J=[this],F=this,A=0;A=0&&(P=D,z=C),L.negative&&(L=L.neg(),R=R.neg()),P.negative&&(P=P.neg(),z=z.neg()),[{a:L,b:R},{a:P,b:z}]},X.prototype._endoSplit=function(O){var J=this.endo.basis,F=J[0],A=J[1],H=A.b.mul(O).divRound(this.n),W=F.b.neg().mul(O).divRound(this.n),E=H.mul(F.a),T=W.mul(A.a),D=H.mul(F.b),C=W.mul(A.b),L=O.sub(E).sub(T),R=D.add(C).neg();return{k1:L,k2:R}},X.prototype.pointFromX=function(O,J){O=new Z(O,16),O.red||(O=O.toRed(this.red));var F=O.redSqr().redMul(O).redIAdd(O.redMul(this.a)).redIAdd(this.b),A=F.redSqrt();if(A.redSqr().redSub(F).cmp(this.zero)!==0)throw new Error("invalid point");var H=A.fromRed().isOdd();return(J&&!H||!J&&H)&&(A=A.redNeg()),this.point(O,A)},X.prototype.validate=function(O){if(O.inf)return!0;var{x:J,y:F}=O,A=this.a.redMul(J),H=J.redSqr().redMul(J).redIAdd(A).redIAdd(this.b);return F.redSqr().redISub(H).cmpn(0)===0},X.prototype._endoWnafMulAdd=function(O,J,F){for(var A=this._endoWnafT1,H=this._endoWnafT2,W=0;W":""},K.prototype.isInfinity=function(){return this.inf},K.prototype.add=function(O){if(this.inf)return O;if(O.inf)return this;if(this.eq(O))return this.dbl();if(this.neg().eq(O))return this.curve.point(null,null);if(this.x.cmp(O.x)===0)return this.curve.point(null,null);var J=this.y.redSub(O.y);J.cmpn(0)!==0&&(J=J.redMul(this.x.redSub(O.x).redInvm()));var F=J.redSqr().redISub(this.x).redISub(O.x),A=J.redMul(this.x.redSub(F)).redISub(this.y);return this.curve.point(F,A)},K.prototype.dbl=function(){if(this.inf)return this;var O=this.y.redAdd(this.y);if(O.cmpn(0)===0)return this.curve.point(null,null);var J=this.curve.a,F=this.x.redSqr(),A=O.redInvm(),H=F.redAdd(F).redIAdd(F).redIAdd(J).redMul(A),W=H.redSqr().redISub(this.x.redAdd(this.x)),E=H.redMul(this.x.redSub(W)).redISub(this.y);return this.curve.point(W,E)},K.prototype.getX=function(){return this.x.fromRed()},K.prototype.getY=function(){return this.y.fromRed()},K.prototype.mul=function(O){return O=new Z(O,16),this.isInfinity()?this:this._hasDoubles(O)?this.curve._fixedNafMul(this,O):this.curve.endo?this.curve._endoWnafMulAdd([this],[O]):this.curve._wnafMul(this,O)},K.prototype.mulAdd=function(O,J,F){var A=[this,J],H=[O,F];return this.curve.endo?this.curve._endoWnafMulAdd(A,H):this.curve._wnafMulAdd(1,A,H,2)},K.prototype.jmulAdd=function(O,J,F){var A=[this,J],H=[O,F];return this.curve.endo?this.curve._endoWnafMulAdd(A,H,!0):this.curve._wnafMulAdd(1,A,H,2,!0)},K.prototype.eq=function(O){return this===O||this.inf===O.inf&&(this.inf||this.x.cmp(O.x)===0&&this.y.cmp(O.y)===0)},K.prototype.neg=function(O){if(this.inf)return this;var J=this.curve.point(this.x,this.y.redNeg());if(O&&this.precomputed){var F=this.precomputed,A=function(H){return H.neg()};J.precomputed={naf:F.naf&&{wnd:F.naf.wnd,points:F.naf.points.map(A)},doubles:F.doubles&&{step:F.doubles.step,points:F.doubles.points.map(A)}}}return J},K.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var O=this.curve.jpoint(this.x,this.y,this.curve.one);return O};function I(O,J,F,A){V.BasePoint.call(this,O,"jacobian"),J===null&&F===null&&A===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Z(0)):(this.x=new Z(J,16),this.y=new Z(F,16),this.z=new Z(A,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}G(I,V.BasePoint),X.prototype.jpoint=function(O,J,F){return new I(this,O,J,F)},I.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var O=this.z.redInvm(),J=O.redSqr(),F=this.x.redMul(J),A=this.y.redMul(J).redMul(O);return this.curve.point(F,A)},I.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},I.prototype.add=function(O){if(this.isInfinity())return O;if(O.isInfinity())return this;var J=O.z.redSqr(),F=this.z.redSqr(),A=this.x.redMul(J),H=O.x.redMul(F),W=this.y.redMul(J.redMul(O.z)),E=O.y.redMul(F.redMul(this.z)),T=A.redSub(H),D=W.redSub(E);if(T.cmpn(0)===0)return D.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var C=T.redSqr(),L=C.redMul(T),R=A.redMul(C),P=D.redSqr().redIAdd(L).redISub(R).redISub(R),z=D.redMul(R.redISub(P)).redISub(W.redMul(L)),M=this.z.redMul(O.z).redMul(T);return this.curve.jpoint(P,z,M)},I.prototype.mixedAdd=function(O){if(this.isInfinity())return O.toJ();if(O.isInfinity())return this;var J=this.z.redSqr(),F=this.x,A=O.x.redMul(J),H=this.y,W=O.y.redMul(J).redMul(this.z),E=F.redSub(A),T=H.redSub(W);if(E.cmpn(0)===0)return T.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var D=E.redSqr(),C=D.redMul(E),L=F.redMul(D),R=T.redSqr().redIAdd(C).redISub(L).redISub(L),P=T.redMul(L.redISub(R)).redISub(H.redMul(C)),z=this.z.redMul(E);return this.curve.jpoint(R,P,z)},I.prototype.dblp=function(O){if(O===0)return this;if(this.isInfinity())return this;if(!O)return this.dbl();var J;if(this.curve.zeroA||this.curve.threeA){var F=this;for(J=0;J=0)return!1;if(F.redIAdd(H),this.x.cmp(F)===0)return!0}},I.prototype.inspect=function(){return this.isInfinity()?"":""},I.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),sQ=q$({"node_modules/elliptic/lib/elliptic/curve/mont.js"($,Q){var Y=bQ(),Z=_$(),G=uQ(),V=oQ();function U(K){G.call(this,"mont",K),this.a=new Y(K.a,16).toRed(this.red),this.b=new Y(K.b,16).toRed(this.red),this.i4=new Y(4).toRed(this.red).redInvm(),this.two=new Y(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Z(U,G),Q.exports=U,U.prototype.validate=function(K){var I=K.normalize().x,O=I.redSqr(),J=O.redMul(I).redAdd(O.redMul(this.a)).redAdd(I),F=J.redSqrt();return F.redSqr().cmp(J)===0};function X(K,I,O){G.BasePoint.call(this,K,"projective"),I===null&&O===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Y(I,16),this.z=new Y(O,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Z(X,G.BasePoint),U.prototype.decodePoint=function(K,I){return this.point(V.toArray(K,I),1)},U.prototype.point=function(K,I){return new X(this,K,I)},U.prototype.pointFromJSON=function(K){return X.fromJSON(this,K)},X.prototype.precompute=function(){},X.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},X.fromJSON=function(K,I){return new X(K,I[0],I[1]||K.one)},X.prototype.inspect=function(){return this.isInfinity()?"":""},X.prototype.isInfinity=function(){return this.z.cmpn(0)===0},X.prototype.dbl=function(){var K=this.x.redAdd(this.z),I=K.redSqr(),O=this.x.redSub(this.z),J=O.redSqr(),F=I.redSub(J),A=I.redMul(J),H=F.redMul(J.redAdd(this.curve.a24.redMul(F)));return this.curve.point(A,H)},X.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},X.prototype.diffAdd=function(K,I){var O=this.x.redAdd(this.z),J=this.x.redSub(this.z),F=K.x.redAdd(K.z),A=K.x.redSub(K.z),H=A.redMul(O),W=F.redMul(J),E=I.z.redMul(H.redAdd(W).redSqr()),T=I.x.redMul(H.redISub(W).redSqr());return this.curve.point(E,T)},X.prototype.mul=function(K){for(var I=K.clone(),O=this,J=this.curve.point(null,null),F=this,A=[];I.cmpn(0)!==0;I.iushrn(1))A.push(I.andln(1));for(var H=A.length-1;H>=0;H--)A[H]===0?(O=O.diffAdd(J,F),J=J.dbl()):(J=O.diffAdd(J,F),O=O.dbl());return J},X.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},X.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},X.prototype.eq=function(K){return this.getX().cmp(K.getX())===0},X.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},X.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),tQ=q$({"node_modules/elliptic/lib/elliptic/curve/edwards.js"($,Q){var Y=oQ(),Z=bQ(),G=_$(),V=uQ(),U=Y.assert;function X(I){this.twisted=(I.a|0)!==1,this.mOneA=this.twisted&&(I.a|0)===-1,this.extended=this.mOneA,V.call(this,"edwards",I),this.a=new Z(I.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Z(I.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Z(I.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),U(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(I.c|0)===1}G(X,V),Q.exports=X,X.prototype._mulA=function(I){return this.mOneA?I.redNeg():this.a.redMul(I)},X.prototype._mulC=function(I){return this.oneC?I:this.c.redMul(I)},X.prototype.jpoint=function(I,O,J,F){return this.point(I,O,J,F)},X.prototype.pointFromX=function(I,O){I=new Z(I,16),I.red||(I=I.toRed(this.red));var J=I.redSqr(),F=this.c2.redSub(this.a.redMul(J)),A=this.one.redSub(this.c2.redMul(this.d).redMul(J)),H=F.redMul(A.redInvm()),W=H.redSqrt();if(W.redSqr().redSub(H).cmp(this.zero)!==0)throw new Error("invalid point");var E=W.fromRed().isOdd();return(O&&!E||!O&&E)&&(W=W.redNeg()),this.point(I,W)},X.prototype.pointFromY=function(I,O){I=new Z(I,16),I.red||(I=I.toRed(this.red));var J=I.redSqr(),F=J.redSub(this.c2),A=J.redMul(this.d).redMul(this.c2).redSub(this.a),H=F.redMul(A.redInvm());if(H.cmp(this.zero)===0){if(O)throw new Error("invalid point");return this.point(this.zero,I)}var W=H.redSqrt();if(W.redSqr().redSub(H).cmp(this.zero)!==0)throw new Error("invalid point");return W.fromRed().isOdd()!==O&&(W=W.redNeg()),this.point(W,I)},X.prototype.validate=function(I){if(I.isInfinity())return!0;I.normalize();var O=I.x.redSqr(),J=I.y.redSqr(),F=O.redMul(this.a).redAdd(J),A=this.c2.redMul(this.one.redAdd(this.d.redMul(O).redMul(J)));return F.cmp(A)===0};function K(I,O,J,F,A){V.BasePoint.call(this,I,"projective"),O===null&&J===null&&F===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Z(O,16),this.y=new Z(J,16),this.z=F?new Z(F,16):this.curve.one,this.t=A&&new Z(A,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}G(K,V.BasePoint),X.prototype.pointFromJSON=function(I){return K.fromJSON(this,I)},X.prototype.point=function(I,O,J,F){return new K(this,I,O,J,F)},K.fromJSON=function(I,O){return new K(I,O[0],O[1],O[2])},K.prototype.inspect=function(){return this.isInfinity()?"":""},K.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},K.prototype._extDbl=function(){var I=this.x.redSqr(),O=this.y.redSqr(),J=this.z.redSqr();J=J.redIAdd(J);var F=this.curve._mulA(I),A=this.x.redAdd(this.y).redSqr().redISub(I).redISub(O),H=F.redAdd(O),W=H.redSub(J),E=F.redSub(O),T=A.redMul(W),D=H.redMul(E),C=A.redMul(E),L=W.redMul(H);return this.curve.point(T,D,L,C)},K.prototype._projDbl=function(){var I=this.x.redAdd(this.y).redSqr(),O=this.x.redSqr(),J=this.y.redSqr(),F,A,H,W,E,T;if(this.curve.twisted){W=this.curve._mulA(O);var D=W.redAdd(J);this.zOne?(F=I.redSub(O).redSub(J).redMul(D.redSub(this.curve.two)),A=D.redMul(W.redSub(J)),H=D.redSqr().redSub(D).redSub(D)):(E=this.z.redSqr(),T=D.redSub(E).redISub(E),F=I.redSub(O).redISub(J).redMul(T),A=D.redMul(W.redSub(J)),H=D.redMul(T))}else W=O.redAdd(J),E=this.curve._mulC(this.z).redSqr(),T=W.redSub(E).redSub(E),F=this.curve._mulC(I.redISub(W)).redMul(T),A=this.curve._mulC(W).redMul(O.redISub(J)),H=W.redMul(T);return this.curve.point(F,A,H)},K.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},K.prototype._extAdd=function(I){var O=this.y.redSub(this.x).redMul(I.y.redSub(I.x)),J=this.y.redAdd(this.x).redMul(I.y.redAdd(I.x)),F=this.t.redMul(this.curve.dd).redMul(I.t),A=this.z.redMul(I.z.redAdd(I.z)),H=J.redSub(O),W=A.redSub(F),E=A.redAdd(F),T=J.redAdd(O),D=H.redMul(W),C=E.redMul(T),L=H.redMul(T),R=W.redMul(E);return this.curve.point(D,C,R,L)},K.prototype._projAdd=function(I){var O=this.z.redMul(I.z),J=O.redSqr(),F=this.x.redMul(I.x),A=this.y.redMul(I.y),H=this.curve.d.redMul(F).redMul(A),W=J.redSub(H),E=J.redAdd(H),T=this.x.redAdd(this.y).redMul(I.x.redAdd(I.y)).redISub(F).redISub(A),D=O.redMul(W).redMul(T),C,L;return this.curve.twisted?(C=O.redMul(E).redMul(A.redSub(this.curve._mulA(F))),L=W.redMul(E)):(C=O.redMul(E).redMul(A.redSub(F)),L=this.curve._mulC(W).redMul(E)),this.curve.point(D,C,L)},K.prototype.add=function(I){return this.isInfinity()?I:I.isInfinity()?this:this.curve.extended?this._extAdd(I):this._projAdd(I)},K.prototype.mul=function(I){return this._hasDoubles(I)?this.curve._fixedNafMul(this,I):this.curve._wnafMul(this,I)},K.prototype.mulAdd=function(I,O,J){return this.curve._wnafMulAdd(1,[this,O],[I,J],2,!1)},K.prototype.jmulAdd=function(I,O,J){return this.curve._wnafMulAdd(1,[this,O],[I,J],2,!0)},K.prototype.normalize=function(){if(this.zOne)return this;var I=this.z.redInvm();return this.x=this.x.redMul(I),this.y=this.y.redMul(I),this.t&&(this.t=this.t.redMul(I)),this.z=this.curve.one,this.zOne=!0,this},K.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},K.prototype.getX=function(){return this.normalize(),this.x.fromRed()},K.prototype.getY=function(){return this.normalize(),this.y.fromRed()},K.prototype.eq=function(I){return this===I||this.getX().cmp(I.getX())===0&&this.getY().cmp(I.getY())===0},K.prototype.eqXToP=function(I){var O=I.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(O)===0)return!0;for(var J=I.clone(),F=this.curve.redN.redMul(this.z);;){if(J.iadd(this.curve.n),J.cmp(this.curve.p)>=0)return!1;if(O.redIAdd(F),this.x.cmp(O)===0)return!0}},K.prototype.toP=K.prototype.normalize,K.prototype.mixedAdd=K.prototype.add}}),mQ=q$({"node_modules/elliptic/lib/elliptic/curve/index.js"($){var Q=$;Q.base=uQ(),Q.short=nQ(),Q.mont=sQ(),Q.edwards=tQ()}}),aQ=q$({"node_modules/hash.js/lib/hash/utils.js"($){var Q=ZQ(),Y=_$();$.inherits=Y;function Z(k,g){return(k.charCodeAt(g)&64512)!==55296||g<0||g+1>=k.length?!1:(k.charCodeAt(g+1)&64512)===56320}function G(k,g){if(Array.isArray(k))return k.slice();if(!k)return[];var _=[];if(typeof k=="string")if(g){if(g==="hex")for(k=k.replace(/[^a-z0-9]+/gi,""),k.length%2!==0&&(k="0"+k),x=0;x>6|192,_[N++]=B&63|128):Z(k,x)?(B=65536+((B&1023)<<10)+(k.charCodeAt(++x)&1023),_[N++]=B>>18|240,_[N++]=B>>12&63|128,_[N++]=B>>6&63|128,_[N++]=B&63|128):(_[N++]=B>>12|224,_[N++]=B>>6&63|128,_[N++]=B&63|128)}else for(x=0;x>>24|k>>>8&65280|k<<8&16711680|(k&255)<<24;return g>>>0}$.htonl=U;function X(k,g){for(var _="",N=0;N>>0}return B}$.join32=O;function J(k,g){for(var _=new Array(k.length*4),N=0,x=0;N>>24,_[x+1]=B>>>16&255,_[x+2]=B>>>8&255,_[x+3]=B&255):(_[x+3]=B>>>24,_[x+2]=B>>>16&255,_[x+1]=B>>>8&255,_[x]=B&255)}return _}$.split32=J;function F(k,g){return k>>>g|k<<32-g}$.rotr32=F;function A(k,g){return k<>>32-g}$.rotl32=A;function H(k,g){return k+g>>>0}$.sum32=H;function W(k,g,_){return k+g+_>>>0}$.sum32_3=W;function E(k,g,_,N){return k+g+_+N>>>0}$.sum32_4=E;function T(k,g,_,N,x){return k+g+_+N+x>>>0}$.sum32_5=T;function D(k,g,_,N){var x=k[g],B=k[g+1],y=N+B>>>0,w=(y>>0,k[g+1]=y}$.sum64=D;function C(k,g,_,N){var x=g+N>>>0,B=(x>>0}$.sum64_hi=C;function L(k,g,_,N){var x=g+N;return x>>>0}$.sum64_lo=L;function R(k,g,_,N,x,B,y,w){var p=0,f=g;f=f+N>>>0,p+=f>>0,p+=f>>0,p+=f>>0}$.sum64_4_hi=R;function P(k,g,_,N,x,B,y,w){var p=g+N+B+w;return p>>>0}$.sum64_4_lo=P;function z(k,g,_,N,x,B,y,w,p,f){var c=0,h=g;h=h+N>>>0,c+=h>>0,c+=h>>0,c+=h>>0,c+=h>>0}$.sum64_5_hi=z;function M(k,g,_,N,x,B,y,w,p,f){var c=g+N+B+w+f;return c>>>0}$.sum64_5_lo=M;function S(k,g,_){var N=g<<32-_|k>>>_;return N>>>0}$.rotr64_hi=S;function v(k,g,_){var N=k<<32-_|g>>>_;return N>>>0}$.rotr64_lo=v;function q(k,g,_){return k>>>_}$.shr64_hi=q;function j(k,g,_){var N=k<<32-_|g>>>_;return N>>>0}$.shr64_lo=j}}),eQ=q$({"node_modules/hash.js/lib/hash/common.js"($){var Q=aQ(),Y=ZQ();function Z(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}$.BlockHash=Z,Z.prototype.update=function(G,V){if(G=Q.toArray(G,V),this.pending?this.pending=this.pending.concat(G):this.pending=G,this.pendingTotal+=G.length,this.pending.length>=this._delta8){G=this.pending;var U=G.length%this._delta8;this.pending=G.slice(G.length-U,G.length),this.pending.length===0&&(this.pending=null),G=Q.join32(G,0,G.length-U,this.endian);for(var X=0;X>>24&255,X[K++]=G>>>16&255,X[K++]=G>>>8&255,X[K++]=G&255}else for(X[K++]=G&255,X[K++]=G>>>8&255,X[K++]=G>>>16&255,X[K++]=G>>>24&255,X[K++]=0,X[K++]=0,X[K++]=0,X[K++]=0,I=8;I>>3}$.g0_256=I;function O(J){return Y(J,17)^Y(J,19)^J>>>10}$.g1_256=O}}),iQ=q$({"node_modules/hash.js/lib/hash/sha/1.js"($,Q){var Y=aQ(),Z=eQ(),G=rQ(),V=Y.rotl32,U=Y.sum32,X=Y.sum32_5,K=G.ft_1,I=Z.BlockHash,O=[1518500249,1859775393,2400959708,3395469782];function J(){if(!(this instanceof J))return new J;I.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Y.inherits(J,I),Q.exports=J,J.blockSize=512,J.outSize=160,J.hmacStrength=80,J.padLength=64,J.prototype._update=function(F,A){for(var H=this.W,W=0;W<16;W++)H[W]=F[A+W];for(;Wthis.blockSize&&(V=new this.Hash().update(V).digest()),Z(V.length<=this.blockSize);for(var U=V.length;U=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(X,K,I)}Q.exports=V,V.prototype._init=function(U,X,K){var I=U.concat(X).concat(K);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var O=0;O=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(U.concat(K||[])),this._reseed=1},V.prototype.generate=function(U,X,K,I){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof X!="string"&&(I=K,K=X,X=null),K&&(K=Z.toArray(K,I||"hex"),this._update(K));for(var O=[];O.length"}}}),FY=q$({"node_modules/elliptic/lib/elliptic/ec/signature.js"($,Q){var Y=bQ(),Z=oQ(),G=Z.assert;function V(O,J){if(O instanceof V)return O;this._importDER(O,J)||(G(O.r&&O.s,"Signature without r or s"),this.r=new Y(O.r,16),this.s=new Y(O.s,16),O.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=O.recoveryParam)}Q.exports=V;function U(){this.place=0}function X(O,J){var F=O[J.place++];if(!(F&128))return F;var A=F&15;if(A===0||A>4)return!1;for(var H=0,W=0,E=J.place;W>>=0;return H<=127?!1:(J.place=E,H)}function K(O){for(var J=0,F=O.length-1;!O[J]&&!(O[J+1]&128)&&J>>3);for(O.push(F|128);--F;)O.push(J>>>(F<<3)&255);O.push(J)}V.prototype.toDER=function(O){var J=this.r.toArray(),F=this.s.toArray();for(J[0]&128&&(J=[0].concat(J)),F[0]&128&&(F=[0].concat(F)),J=K(J),F=K(F);!F[0]&&!(F[1]&128);)F=F.slice(1);var A=[2];I(A,J.length),A=A.concat(J),A.push(2),I(A,F.length);var H=A.concat(F),W=[48];return I(W,H.length),W=W.concat(H),Z.encode(W,O)}}}),AY=q$({"node_modules/elliptic/lib/elliptic/ec/index.js"($,Q){var Y=bQ(),Z=OY(),G=oQ(),V=IY(),U=xQ(),X=G.assert,K=JY(),I=FY();function O(J){if(!(this instanceof O))return new O(J);typeof J=="string"&&(X(Object.prototype.hasOwnProperty.call(V,J),"Unknown curve "+J),J=V[J]),J instanceof V.PresetCurve&&(J={curve:J}),this.curve=J.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=J.curve.g,this.g.precompute(J.curve.n.bitLength()+1),this.hash=J.hash||J.curve.hash}Q.exports=O,O.prototype.keyPair=function(J){return new K(this,J)},O.prototype.keyFromPrivate=function(J,F){return K.fromPrivate(this,J,F)},O.prototype.keyFromPublic=function(J,F){return K.fromPublic(this,J,F)},O.prototype.genKeyPair=function(J){J||(J={});for(var F=new Z({hash:this.hash,pers:J.pers,persEnc:J.persEnc||"utf8",entropy:J.entropy||U(this.hash.hmacStrength),entropyEnc:J.entropy&&J.entropyEnc||"utf8",nonce:this.n.toArray()}),A=this.n.byteLength(),H=this.n.sub(new Y(2));;){var W=new Y(F.generate(A));if(!(W.cmp(H)>0))return W.iaddn(1),this.keyFromPrivate(W)}},O.prototype._truncateToN=function(J,F){var A=J.byteLength()*8-this.n.bitLength();return A>0&&(J=J.ushrn(A)),!F&&J.cmp(this.n)>=0?J.sub(this.n):J},O.prototype.sign=function(J,F,A,H){typeof A=="object"&&(H=A,A=null),H||(H={}),F=this.keyFromPrivate(F,A),J=this._truncateToN(new Y(J,16));for(var W=this.n.byteLength(),E=F.getPrivate().toArray("be",W),T=J.toArray("be",W),D=new Z({hash:this.hash,entropy:E,nonce:T,pers:H.pers,persEnc:H.persEnc||"utf8"}),C=this.n.sub(new Y(1)),L=0;;L++){var R=H.k?H.k(L):new Y(D.generate(this.n.byteLength()));if(R=this._truncateToN(R,!0),!(R.cmpn(1)<=0||R.cmp(C)>=0)){var P=this.g.mul(R);if(!P.isInfinity()){var z=P.getX(),M=z.umod(this.n);if(M.cmpn(0)!==0){var S=R.invm(this.n).mul(M.mul(F.getPrivate()).iadd(J));if(S=S.umod(this.n),S.cmpn(0)!==0){var v=(P.getY().isOdd()?1:0)|(z.cmp(M)!==0?2:0);return H.canonical&&S.cmp(this.nh)>0&&(S=this.n.sub(S),v^=1),new I({r:M,s:S,recoveryParam:v})}}}}}},O.prototype.verify=function(J,F,A,H){J=this._truncateToN(new Y(J,16)),A=this.keyFromPublic(A,H),F=new I(F,"hex");var{r:W,s:E}=F;if(W.cmpn(1)<0||W.cmp(this.n)>=0||E.cmpn(1)<0||E.cmp(this.n)>=0)return!1;var T=E.invm(this.n),D=T.mul(J).umod(this.n),C=T.mul(W).umod(this.n),L;return this.curve._maxwellTrick?(L=this.g.jmulAdd(D,A.getPublic(),C),L.isInfinity()?!1:L.eqXToP(W)):(L=this.g.mulAdd(D,A.getPublic(),C),L.isInfinity()?!1:L.getX().umod(this.n).cmp(W)===0)},O.prototype.recoverPubKey=function(J,F,A,H){X((3&A)===A,"The recovery param is more than two bits"),F=new I(F,H);var W=this.n,E=new Y(J),T=F.r,D=F.s,C=A&1,L=A>>1;if(T.cmp(this.curve.p.umod(this.curve.n))>=0&&L)throw new Error("Unable to find sencond key candinate");L?T=this.curve.pointFromX(T.add(this.curve.n),C):T=this.curve.pointFromX(T,C);var R=F.r.invm(W),P=W.sub(E).mul(R).umod(W),z=D.mul(R).umod(W);return this.g.mulAdd(P,T,z)},O.prototype.getKeyRecoveryParam=function(J,F,A,H){if(F=new I(F,H),F.recoveryParam!==null)return F.recoveryParam;for(var W=0;W<4;W++){var E;try{E=this.recoverPubKey(J,F,W)}catch{continue}if(E.eq(A))return W}throw new Error("Unable to find valid recovery factor")}}}),HY=q$({"node_modules/elliptic/lib/elliptic/eddsa/key.js"($,Q){var Y=oQ(),Z=Y.assert,G=Y.parseBytes,V=Y.cachedProperty;function U(X,K){this.eddsa=X,this._secret=G(K.secret),X.isPoint(K.pub)?this._pub=K.pub:this._pubBytes=G(K.pub)}U.fromPublic=function(X,K){return K instanceof U?K:new U(X,{pub:K})},U.fromSecret=function(X,K){return K instanceof U?K:new U(X,{secret:K})},U.prototype.secret=function(){return this._secret},V(U,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),V(U,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),V(U,"privBytes",function(){var X=this.eddsa,K=this.hash(),I=X.encodingLength-1,O=K.slice(0,X.encodingLength);return O[0]&=248,O[I]&=127,O[I]|=64,O}),V(U,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),V(U,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),V(U,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),U.prototype.sign=function(X){return Z(this._secret,"KeyPair can only verify"),this.eddsa.sign(X,this)},U.prototype.verify=function(X,K){return this.eddsa.verify(X,K,this)},U.prototype.getSecret=function(X){return Z(this._secret,"KeyPair is public only"),Y.encode(this.secret(),X)},U.prototype.getPublic=function(X){return Y.encode(this.pubBytes(),X)},Q.exports=U}}),WY=q$({"node_modules/elliptic/lib/elliptic/eddsa/signature.js"($,Q){var Y=bQ(),Z=oQ(),G=Z.assert,V=Z.cachedProperty,U=Z.parseBytes;function X(K,I){this.eddsa=K,typeof I!="object"&&(I=U(I)),Array.isArray(I)&&(I={R:I.slice(0,K.encodingLength),S:I.slice(K.encodingLength)}),G(I.R&&I.S,"Signature without R or S"),K.isPoint(I.R)&&(this._R=I.R),I.S instanceof Y&&(this._S=I.S),this._Rencoded=Array.isArray(I.R)?I.R:I.Rencoded,this._Sencoded=Array.isArray(I.S)?I.S:I.Sencoded}V(X,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),V(X,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),V(X,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),V(X,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),X.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},X.prototype.toHex=function(){return Z.encode(this.toBytes(),"hex").toUpperCase()},Q.exports=X}}),EY=q$({"node_modules/elliptic/lib/elliptic/eddsa/index.js"($,Q){var Y=XY(),Z=IY(),G=oQ(),V=G.assert,U=G.parseBytes,X=HY(),K=WY();function I(O){if(V(O==="ed25519","only tested with ed25519 so far"),!(this instanceof I))return new I(O);O=Z[O].curve,this.curve=O,this.g=O.g,this.g.precompute(O.n.bitLength()+1),this.pointClass=O.point().constructor,this.encodingLength=Math.ceil(O.n.bitLength()/8),this.hash=Y.sha512}Q.exports=I,I.prototype.sign=function(O,J){O=U(O);var F=this.keyFromSecret(J),A=this.hashInt(F.messagePrefix(),O),H=this.g.mul(A),W=this.encodePoint(H),E=this.hashInt(W,F.pubBytes(),O).mul(F.priv()),T=A.add(E).umod(this.curve.n);return this.makeSignature({R:H,S:T,Rencoded:W})},I.prototype.verify=function(O,J,F){O=U(O),J=this.makeSignature(J);var A=this.keyFromPublic(F),H=this.hashInt(J.Rencoded(),A.pubBytes(),O),W=this.g.mul(J.S()),E=J.R().add(A.pub().mul(H));return E.eq(W)},I.prototype.hashInt=function(){for(var O=this.hash(),J=0;J0?j:k},U.min=function(j,k){return j.cmp(k)<0?j:k},U.prototype._init=function(j,k,g){if(typeof j=="number")return this._initNumber(j,k,g);if(typeof j=="object")return this._initArray(j,k,g);k==="hex"&&(k=16),G(k===(k|0)&&k>=2&&k<=36),j=j.toString().replace(/\s+/g,"");var _=0;j[0]==="-"&&(_++,this.negative=1),_=0;_-=3)x=j[_]|j[_-1]<<8|j[_-2]<<16,this.words[N]|=x<>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);else if(g==="le")for(_=0,N=0;_>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);return this.strip()};function K(j,k){var g=j.charCodeAt(k);return g>=65&&g<=70?g-55:g>=97&&g<=102?g-87:g-48&15}function I(j,k,g){var _=K(j,g);return g-1>=k&&(_|=K(j,g-1)<<4),_}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var _=0;_=k;_-=2)B=I(j,k,_)<=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8;else{var y=j.length-k;for(_=y%2===0?k+1:k;_=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8}this.strip()};function O(j,k,g,_){for(var N=0,x=Math.min(j.length,g),B=k;B=49?N+=y-49+10:y>=17?N+=y-17+10:N+=y}return N}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var _=0,N=1;N<=67108863;N*=k)_++;_--,N=N/k|0;for(var x=j.length-g,B=x%_,y=Math.min(x,x-B)+g,w=0,p=g;p1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},U.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},U.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],F=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],A=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];U.prototype.toString=function(j,k){j=j||10,k=k|0||1;var g;if(j===16||j==="hex"){g="";for(var _=0,N=0,x=0;x>>24-_&16777215,N!==0||x!==this.length-1?g=J[6-y.length]+y+g:g=y+g,_+=2,_>=26&&(_-=26,x--)}for(N!==0&&(g=N.toString(16)+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}if(j===(j|0)&&j>=2&&j<=36){var w=F[j],p=A[j];g="";var f=this.clone();for(f.negative=0;!f.isZero();){var c=f.modn(p).toString(j);f=f.idivn(p),f.isZero()?g=c+g:g=J[w-c.length]+c+g}for(this.isZero()&&(g="0"+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}G(!1,"Base should be between 2 and 36")},U.prototype.toNumber=function(){var j=this.words[0];return this.length===2?j+=this.words[1]*67108864:this.length===3&&this.words[2]===1?j+=4503599627370496+this.words[1]*67108864:this.length>2&&G(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-j:j},U.prototype.toJSON=function(){return this.toString(16)},U.prototype.toBuffer=function(j,k){return G(typeof X<"u"),this.toArrayLike(X,j,k)},U.prototype.toArray=function(j,k){return this.toArrayLike(Array,j,k)},U.prototype.toArrayLike=function(j,k,g){var _=this.byteLength(),N=g||Math.max(1,_);G(_<=N,"byte array longer than desired length"),G(N>0,"Requested array length <= 0"),this.strip();var x=k==="le",B=new j(N),y,w,p=this.clone();if(x){for(w=0;!p.isZero();w++)y=p.andln(255),p.iushrn(8),B[w]=y;for(;w=4096&&(g+=13,k>>>=13),k>=64&&(g+=7,k>>>=7),k>=8&&(g+=4,k>>>=4),k>=2&&(g+=2,k>>>=2),g+k},U.prototype._zeroBits=function(j){if(j===0)return 26;var k=j,g=0;return(k&8191)===0&&(g+=13,k>>>=13),(k&127)===0&&(g+=7,k>>>=7),(k&15)===0&&(g+=4,k>>>=4),(k&3)===0&&(g+=2,k>>>=2),(k&1)===0&&g++,g},U.prototype.bitLength=function(){var j=this.words[this.length-1],k=this._countBits(j);return(this.length-1)*26+k};function H(j){for(var k=new Array(j.bitLength()),g=0;g>>N}return k}U.prototype.zeroBits=function(){if(this.isZero())return 0;for(var j=0,k=0;kj.length?this.clone().ior(j):j.clone().ior(this)},U.prototype.uor=function(j){return this.length>j.length?this.clone().iuor(j):j.clone().iuor(this)},U.prototype.iuand=function(j){var k;this.length>j.length?k=j:k=this;for(var g=0;gj.length?this.clone().iand(j):j.clone().iand(this)},U.prototype.uand=function(j){return this.length>j.length?this.clone().iuand(j):j.clone().iuand(this)},U.prototype.iuxor=function(j){var k,g;this.length>j.length?(k=this,g=j):(k=j,g=this);for(var _=0;_j.length?this.clone().ixor(j):j.clone().ixor(this)},U.prototype.uxor=function(j){return this.length>j.length?this.clone().iuxor(j):j.clone().iuxor(this)},U.prototype.inotn=function(j){G(typeof j=="number"&&j>=0);var k=Math.ceil(j/26)|0,g=j%26;this._expand(k),g>0&&k--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-g),this.strip()},U.prototype.notn=function(j){return this.clone().inotn(j)},U.prototype.setn=function(j,k){G(typeof j=="number"&&j>=0);var g=j/26|0,_=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<<_:this.words[g]=this.words[g]&~(1<<_),this.strip()},U.prototype.iadd=function(j){var k;if(this.negative!==0&&j.negative===0)return this.negative=0,k=this.isub(j),this.negative^=1,this._normSign();if(this.negative===0&&j.negative!==0)return j.negative=0,k=this.isub(j),j.negative=1,k._normSign();var g,_;this.length>j.length?(g=this,_=j):(g=j,_=this);for(var N=0,x=0;x<_.length;x++)k=(g.words[x]|0)+(_.words[x]|0)+N,this.words[x]=k&67108863,N=k>>>26;for(;N!==0&&x>>26;if(this.length=g.length,N!==0)this.words[this.length]=N,this.length++;else if(g!==this)for(;xj.length?this.clone().iadd(j):j.clone().iadd(this)},U.prototype.isub=function(j){if(j.negative!==0){j.negative=0;var k=this.iadd(j);return j.negative=1,k._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(j),this.negative=1,this._normSign();var g=this.cmp(j);if(g===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,N;g>0?(_=this,N=j):(_=j,N=this);for(var x=0,B=0;B>26,this.words[B]=k&67108863;for(;x!==0&&B<_.length;B++)k=(_.words[B]|0)+x,x=k>>26,this.words[B]=k&67108863;if(x===0&&B<_.length&&_!==this)for(;B<_.length;B++)this.words[B]=_.words[B];return this.length=Math.max(this.length,B),_!==this&&(this.negative=1),this.strip()},U.prototype.sub=function(j){return this.clone().isub(j)};function W(j,k,g){g.negative=k.negative^j.negative;var _=j.length+k.length|0;g.length=_,_=_-1|0;var N=j.words[0]|0,x=k.words[0]|0,B=N*x,y=B&67108863,w=B/67108864|0;g.words[0]=y;for(var p=1;p<_;p++){for(var f=w>>>26,c=w&67108863,h=Math.min(p,k.length-1),d=Math.max(0,p-j.length+1);d<=h;d++){var b=p-d|0;N=j.words[b]|0,x=k.words[d]|0,B=N*x+c,f+=B/67108864|0,c=B&67108863}g.words[p]=c|0,w=f|0}return w!==0?g.words[p]=w|0:g.length--,g.strip()}var E=function(j,k,g){var _=j.words,N=k.words,x=g.words,B=0,y,w,p,f=_[0]|0,c=f&8191,h=f>>>13,d=_[1]|0,b=d&8191,l=d>>>13,o=_[2]|0,u=o&8191,n=o>>>13,s=_[3]|0,t=s&8191,m=s>>>13,a=_[4]|0,e=a&8191,r=a>>>13,i=_[5]|0,$0=i&8191,Q0=i>>>13,Y0=_[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=_[7]|0,U0=V0&8191,X0=V0>>>13,K0=_[8]|0,I0=K0&8191,O0=K0>>>13,J0=_[9]|0,F0=J0&8191,A0=J0>>>13,H0=N[0]|0,W0=H0&8191,E0=H0>>>13,T0=N[1]|0,D0=T0&8191,C0=T0>>>13,L0=N[2]|0,R0=L0&8191,P0=L0>>>13,z0=N[3]|0,M0=z0&8191,S0=z0>>>13,v0=N[4]|0,q0=v0&8191,j0=v0>>>13,k0=N[5]|0,g0=k0&8191,_0=k0>>>13,N0=N[6]|0,x0=N0&8191,B0=N0>>>13,y0=N[7]|0,w0=y0&8191,p0=y0>>>13,f0=N[8]|0,c0=f0&8191,h0=f0>>>13,d0=N[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,W0),w=Math.imul(c,E0),w=w+Math.imul(h,W0)|0,p=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,W0),w=Math.imul(b,E0),w=w+Math.imul(l,W0)|0,p=Math.imul(l,E0),y=y+Math.imul(c,D0)|0,w=w+Math.imul(c,C0)|0,w=w+Math.imul(h,D0)|0,p=p+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,W0),w=Math.imul(u,E0),w=w+Math.imul(n,W0)|0,p=Math.imul(n,E0),y=y+Math.imul(b,D0)|0,w=w+Math.imul(b,C0)|0,w=w+Math.imul(l,D0)|0,p=p+Math.imul(l,C0)|0,y=y+Math.imul(c,R0)|0,w=w+Math.imul(c,P0)|0,w=w+Math.imul(h,R0)|0,p=p+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,W0),w=Math.imul(t,E0),w=w+Math.imul(m,W0)|0,p=Math.imul(m,E0),y=y+Math.imul(u,D0)|0,w=w+Math.imul(u,C0)|0,w=w+Math.imul(n,D0)|0,p=p+Math.imul(n,C0)|0,y=y+Math.imul(b,R0)|0,w=w+Math.imul(b,P0)|0,w=w+Math.imul(l,R0)|0,p=p+Math.imul(l,P0)|0,y=y+Math.imul(c,M0)|0,w=w+Math.imul(c,S0)|0,w=w+Math.imul(h,M0)|0,p=p+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(e,W0),w=Math.imul(e,E0),w=w+Math.imul(r,W0)|0,p=Math.imul(r,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,p=p+Math.imul(m,C0)|0,y=y+Math.imul(u,R0)|0,w=w+Math.imul(u,P0)|0,w=w+Math.imul(n,R0)|0,p=p+Math.imul(n,P0)|0,y=y+Math.imul(b,M0)|0,w=w+Math.imul(b,S0)|0,w=w+Math.imul(l,M0)|0,p=p+Math.imul(l,S0)|0,y=y+Math.imul(c,q0)|0,w=w+Math.imul(c,j0)|0,w=w+Math.imul(h,q0)|0,p=p+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,W0),w=Math.imul($0,E0),w=w+Math.imul(Q0,W0)|0,p=Math.imul(Q0,E0),y=y+Math.imul(e,D0)|0,w=w+Math.imul(e,C0)|0,w=w+Math.imul(r,D0)|0,p=p+Math.imul(r,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,p=p+Math.imul(m,P0)|0,y=y+Math.imul(u,M0)|0,w=w+Math.imul(u,S0)|0,w=w+Math.imul(n,M0)|0,p=p+Math.imul(n,S0)|0,y=y+Math.imul(b,q0)|0,w=w+Math.imul(b,j0)|0,w=w+Math.imul(l,q0)|0,p=p+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,_0)|0,w=w+Math.imul(h,g0)|0,p=p+Math.imul(h,_0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,W0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,W0)|0,p=Math.imul(G0,E0),y=y+Math.imul($0,D0)|0,w=w+Math.imul($0,C0)|0,w=w+Math.imul(Q0,D0)|0,p=p+Math.imul(Q0,C0)|0,y=y+Math.imul(e,R0)|0,w=w+Math.imul(e,P0)|0,w=w+Math.imul(r,R0)|0,p=p+Math.imul(r,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,p=p+Math.imul(m,S0)|0,y=y+Math.imul(u,q0)|0,w=w+Math.imul(u,j0)|0,w=w+Math.imul(n,q0)|0,p=p+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,_0)|0,w=w+Math.imul(l,g0)|0,p=p+Math.imul(l,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,x0)|0,p=p+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,W0),w=Math.imul(U0,E0),w=w+Math.imul(X0,W0)|0,p=Math.imul(X0,E0),y=y+Math.imul(Z0,D0)|0,w=w+Math.imul(Z0,C0)|0,w=w+Math.imul(G0,D0)|0,p=p+Math.imul(G0,C0)|0,y=y+Math.imul($0,R0)|0,w=w+Math.imul($0,P0)|0,w=w+Math.imul(Q0,R0)|0,p=p+Math.imul(Q0,P0)|0,y=y+Math.imul(e,M0)|0,w=w+Math.imul(e,S0)|0,w=w+Math.imul(r,M0)|0,p=p+Math.imul(r,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,p=p+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,_0)|0,w=w+Math.imul(n,g0)|0,p=p+Math.imul(n,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,x0)|0,p=p+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,p0)|0,w=w+Math.imul(h,w0)|0,p=p+Math.imul(h,p0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(I0,W0),w=Math.imul(I0,E0),w=w+Math.imul(O0,W0)|0,p=Math.imul(O0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,p=p+Math.imul(X0,C0)|0,y=y+Math.imul(Z0,R0)|0,w=w+Math.imul(Z0,P0)|0,w=w+Math.imul(G0,R0)|0,p=p+Math.imul(G0,P0)|0,y=y+Math.imul($0,M0)|0,w=w+Math.imul($0,S0)|0,w=w+Math.imul(Q0,M0)|0,p=p+Math.imul(Q0,S0)|0,y=y+Math.imul(e,q0)|0,w=w+Math.imul(e,j0)|0,w=w+Math.imul(r,q0)|0,p=p+Math.imul(r,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,_0)|0,w=w+Math.imul(m,g0)|0,p=p+Math.imul(m,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,x0)|0,p=p+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,p0)|0,w=w+Math.imul(l,w0)|0,p=p+Math.imul(l,p0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,p=p+Math.imul(h,h0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(F0,W0),w=Math.imul(F0,E0),w=w+Math.imul(A0,W0)|0,p=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(O0,D0)|0,p=p+Math.imul(O0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,p=p+Math.imul(X0,P0)|0,y=y+Math.imul(Z0,M0)|0,w=w+Math.imul(Z0,S0)|0,w=w+Math.imul(G0,M0)|0,p=p+Math.imul(G0,S0)|0,y=y+Math.imul($0,q0)|0,w=w+Math.imul($0,j0)|0,w=w+Math.imul(Q0,q0)|0,p=p+Math.imul(Q0,j0)|0,y=y+Math.imul(e,g0)|0,w=w+Math.imul(e,_0)|0,w=w+Math.imul(r,g0)|0,p=p+Math.imul(r,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,x0)|0,p=p+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,p0)|0,w=w+Math.imul(n,w0)|0,p=p+Math.imul(n,p0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,p=p+Math.imul(l,h0)|0,y=y+Math.imul(c,b0)|0,w=w+Math.imul(c,l0)|0,w=w+Math.imul(h,b0)|0,p=p+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(i0>>>26)|0,i0&=67108863,y=Math.imul(F0,D0),w=Math.imul(F0,C0),w=w+Math.imul(A0,D0)|0,p=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(O0,R0)|0,p=p+Math.imul(O0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,p=p+Math.imul(X0,S0)|0,y=y+Math.imul(Z0,q0)|0,w=w+Math.imul(Z0,j0)|0,w=w+Math.imul(G0,q0)|0,p=p+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,_0)|0,w=w+Math.imul(Q0,g0)|0,p=p+Math.imul(Q0,_0)|0,y=y+Math.imul(e,x0)|0,w=w+Math.imul(e,B0)|0,w=w+Math.imul(r,x0)|0,p=p+Math.imul(r,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,p0)|0,w=w+Math.imul(m,w0)|0,p=p+Math.imul(m,p0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,p=p+Math.imul(n,h0)|0,y=y+Math.imul(b,b0)|0,w=w+Math.imul(b,l0)|0,w=w+Math.imul(l,b0)|0,p=p+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,p=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(O0,M0)|0,p=p+Math.imul(O0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,p=p+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,_0)|0,w=w+Math.imul(G0,g0)|0,p=p+Math.imul(G0,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,x0)|0,p=p+Math.imul(Q0,B0)|0,y=y+Math.imul(e,w0)|0,w=w+Math.imul(e,p0)|0,w=w+Math.imul(r,w0)|0,p=p+Math.imul(r,p0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,p=p+Math.imul(m,h0)|0,y=y+Math.imul(u,b0)|0,w=w+Math.imul(u,l0)|0,w=w+Math.imul(n,b0)|0,p=p+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,y=Math.imul(F0,M0),w=Math.imul(F0,S0),w=w+Math.imul(A0,M0)|0,p=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(O0,q0)|0,p=p+Math.imul(O0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,_0)|0,w=w+Math.imul(X0,g0)|0,p=p+Math.imul(X0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,x0)|0,p=p+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,p0)|0,w=w+Math.imul(Q0,w0)|0,p=p+Math.imul(Q0,p0)|0,y=y+Math.imul(e,c0)|0,w=w+Math.imul(e,h0)|0,w=w+Math.imul(r,c0)|0,p=p+Math.imul(r,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,p=p+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,y=Math.imul(F0,q0),w=Math.imul(F0,j0),w=w+Math.imul(A0,q0)|0,p=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,_0)|0,w=w+Math.imul(O0,g0)|0,p=p+Math.imul(O0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,x0)|0,p=p+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,p0)|0,w=w+Math.imul(G0,w0)|0,p=p+Math.imul(G0,p0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,p=p+Math.imul(Q0,h0)|0,y=y+Math.imul(e,b0)|0,w=w+Math.imul(e,l0)|0,w=w+Math.imul(r,b0)|0,p=p+Math.imul(r,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,_0),w=w+Math.imul(A0,g0)|0,p=Math.imul(A0,_0),y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(O0,x0)|0,p=p+Math.imul(O0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,p0)|0,w=w+Math.imul(X0,w0)|0,p=p+Math.imul(X0,p0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,p=p+Math.imul(G0,h0)|0,y=y+Math.imul($0,b0)|0,w=w+Math.imul($0,l0)|0,w=w+Math.imul(Q0,b0)|0,p=p+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,x0),w=Math.imul(F0,B0),w=w+Math.imul(A0,x0)|0,p=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,p0)|0,w=w+Math.imul(O0,w0)|0,p=p+Math.imul(O0,p0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,p=p+Math.imul(X0,h0)|0,y=y+Math.imul(Z0,b0)|0,w=w+Math.imul(Z0,l0)|0,w=w+Math.imul(G0,b0)|0,p=p+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,p0),w=w+Math.imul(A0,w0)|0,p=Math.imul(A0,p0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(O0,c0)|0,p=p+Math.imul(O0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,p=p+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(U$>>>26)|0,U$&=67108863,y=Math.imul(F0,c0),w=Math.imul(F0,h0),w=w+Math.imul(A0,c0)|0,p=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(O0,b0)|0,p=p+Math.imul(O0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(X$>>>26)|0,X$&=67108863,y=Math.imul(F0,b0),w=Math.imul(F0,l0),w=w+Math.imul(A0,b0)|0,p=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(p+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,x[0]=o0,x[1]=u0,x[2]=n0,x[3]=s0,x[4]=t0,x[5]=m0,x[6]=a0,x[7]=e0,x[8]=r0,x[9]=i0,x[10]=$$,x[11]=Q$,x[12]=Y$,x[13]=Z$,x[14]=G$,x[15]=V$,x[16]=U$,x[17]=X$,x[18]=K$,B!==0&&(x[19]=B,g.length++),g};Math.imul||(E=W);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var _=0,N=0,x=0;x>>26)|0,N+=B>>>26,B&=67108863}g.words[x]=y,_=B,B=N}return _!==0?g.words[x]=_:g.length--,g.strip()}function D(j,k,g){var _=new C;return _.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,_=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):_<63?g=W(this,j,k):_<1024?g=T(this,j,k):g=D(this,j,k),g};function C(j,k){this.x=j,this.y=k}C.prototype.makeRBT=function(j){for(var k=new Array(j),g=U.prototype._countBits(j)-1,_=0;_>=1;return _},C.prototype.permute=function(j,k,g,_,N,x){for(var B=0;B>>1)N++;return 1<>>13,g[2*x+1]=N&8191,N=N>>>13;for(x=2*k;x<_;++x)g[x]=0;G(N===0),G((N&-8192)===0)},C.prototype.stub=function(j){for(var k=new Array(j),g=0;g>=26,k+=_/67108864|0,k+=N>>>26,this.words[g]=N&67108863}return k!==0&&(this.words[g]=k,this.length++),this},U.prototype.muln=function(j){return this.clone().imuln(j)},U.prototype.sqr=function(){return this.mul(this)},U.prototype.isqr=function(){return this.imul(this.clone())},U.prototype.pow=function(j){var k=H(j);if(k.length===0)return new U(1);for(var g=this,_=0;_=0);var k=j%26,g=(j-k)/26,_=67108863>>>26-k<<26-k,N;if(k!==0){var x=0;for(N=0;N>>26-k}x&&(this.words[N]=x,this.length++)}if(g!==0){for(N=this.length-1;N>=0;N--)this.words[N+g]=this.words[N];for(N=0;N=0);var _;k?_=(k-k%26)/26:_=0;var N=j%26,x=Math.min((j-N)/26,this.length),B=67108863^67108863>>>N<x)for(this.length-=x,w=0;w=0&&(p!==0||w>=_);w--){var f=this.words[w]|0;this.words[w]=p<<26-N|f>>>N,p=f&B}return y&&p!==0&&(y.words[y.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},U.prototype.ishrn=function(j,k,g){return G(this.negative===0),this.iushrn(j,k,g)},U.prototype.shln=function(j){return this.clone().ishln(j)},U.prototype.ushln=function(j){return this.clone().iushln(j)},U.prototype.shrn=function(j){return this.clone().ishrn(j)},U.prototype.ushrn=function(j){return this.clone().iushrn(j)},U.prototype.testn=function(j){G(typeof j=="number"&&j>=0);var k=j%26,g=(j-k)/26,_=1<=0);var k=j%26,g=(j-k)/26;if(G(this.negative===0,"imaskn works only with positive numbers"),this.length<=g)return this;if(k!==0&&g++,this.length=Math.min(g,this.length),k!==0){var _=67108863^67108863>>>k<=67108864;k++)this.words[k]-=67108864,k===this.length-1?this.words[k+1]=1:this.words[k+1]++;return this.length=Math.max(this.length,k+1),this},U.prototype.isubn=function(j){if(G(typeof j=="number"),G(j<67108864),j<0)return this.iaddn(-j);if(this.negative!==0)return this.negative=0,this.iaddn(j),this.negative=1,this;if(this.words[0]-=j,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var k=0;k>26)-(y/67108864|0),this.words[N+g]=x&67108863}for(;N>26,this.words[N+g]=x&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,_=this.clone(),N=j,x=N.words[N.length-1]|0,B=this._countBits(x);g=26-B,g!==0&&(N=N.ushln(g),_.iushln(g),x=N.words[N.length-1]|0);var y=_.length-N.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var p=0;p=0;c--){var h=(_.words[N.length+c]|0)*67108864+(_.words[N.length+c-1]|0);for(h=Math.min(h/x|0,67108863),_._ishlnsubmul(N,h,c);_.negative!==0;)h--,_.negative=0,_._ishlnsubmul(N,1,c),_.isZero()||(_.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),_.strip(),k!=="div"&&g!==0&&_.iushrn(g),{div:w||null,mod:_}},U.prototype.divmod=function(j,k,g){if(G(!j.isZero()),this.isZero())return{div:new U(0),mod:new U(0)};var _,N,x;return this.negative!==0&&j.negative===0?(x=this.neg().divmod(j,k),k!=="mod"&&(_=x.div.neg()),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.iadd(j)),{div:_,mod:N}):this.negative===0&&j.negative!==0?(x=this.divmod(j.neg(),k),k!=="mod"&&(_=x.div.neg()),{div:_,mod:x.mod}):(this.negative&j.negative)!==0?(x=this.neg().divmod(j.neg(),k),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.isub(j)),{div:x.div,mod:N}):j.length>this.length||this.cmp(j)<0?{div:new U(0),mod:this}:j.length===1?k==="div"?{div:this.divn(j.words[0]),mod:null}:k==="mod"?{div:null,mod:new U(this.modn(j.words[0]))}:{div:this.divn(j.words[0]),mod:new U(this.modn(j.words[0]))}:this._wordDiv(j,k)},U.prototype.div=function(j){return this.divmod(j,"div",!1).div},U.prototype.mod=function(j){return this.divmod(j,"mod",!1).mod},U.prototype.umod=function(j){return this.divmod(j,"mod",!0).mod},U.prototype.divRound=function(j){var k=this.divmod(j);if(k.mod.isZero())return k.div;var g=k.div.negative!==0?k.mod.isub(j):k.mod,_=j.ushrn(1),N=j.andln(1),x=g.cmp(_);return x<0||N===1&&x===0?k.div:k.div.negative!==0?k.div.isubn(1):k.div.iaddn(1)},U.prototype.modn=function(j){G(j<=67108863);for(var k=(1<<26)%j,g=0,_=this.length-1;_>=0;_--)g=(k*g+(this.words[_]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var _=(this.words[g]|0)+k*67108864;this.words[g]=_/j|0,k=_%j}return this.strip()},U.prototype.divn=function(j){return this.clone().idivn(j)},U.prototype.egcd=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=new U(0),B=new U(1),y=0;k.isEven()&&g.isEven();)k.iushrn(1),g.iushrn(1),++y;for(var w=g.clone(),p=k.clone();!k.isZero();){for(var f=0,c=1;(k.words[0]&c)===0&&f<26;++f,c<<=1);if(f>0)for(k.iushrn(f);f-- >0;)(_.isOdd()||N.isOdd())&&(_.iadd(w),N.isub(p)),_.iushrn(1),N.iushrn(1);for(var h=0,d=1;(g.words[0]&d)===0&&h<26;++h,d<<=1);if(h>0)for(g.iushrn(h);h-- >0;)(x.isOdd()||B.isOdd())&&(x.iadd(w),B.isub(p)),x.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(x),N.isub(B)):(g.isub(k),x.isub(_),B.isub(N))}return{a:x,b:B,gcd:g.iushln(y)}},U.prototype._invmp=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=g.clone();k.cmpn(1)>0&&g.cmpn(1)>0;){for(var B=0,y=1;(k.words[0]&y)===0&&B<26;++B,y<<=1);if(B>0)for(k.iushrn(B);B-- >0;)_.isOdd()&&_.iadd(x),_.iushrn(1);for(var w=0,p=1;(g.words[0]&p)===0&&w<26;++w,p<<=1);if(w>0)for(g.iushrn(w);w-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(N)):(g.isub(k),N.isub(_))}var f;return k.cmpn(1)===0?f=_:f=N,f.cmpn(0)<0&&f.iadd(j),f},U.prototype.gcd=function(j){if(this.isZero())return j.abs();if(j.isZero())return this.abs();var k=this.clone(),g=j.clone();k.negative=0,g.negative=0;for(var _=0;k.isEven()&&g.isEven();_++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var N=k.cmp(g);if(N<0){var x=k;k=g,g=x}else if(N===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(_)},U.prototype.invm=function(j){return this.egcd(j).a.umod(j)},U.prototype.isEven=function(){return(this.words[0]&1)===0},U.prototype.isOdd=function(){return(this.words[0]&1)===1},U.prototype.andln=function(j){return this.words[0]&j},U.prototype.bincn=function(j){G(typeof j=="number");var k=j%26,g=(j-k)/26,_=1<>>26,B&=67108863,this.words[x]=B}return N!==0&&(this.words[x]=N,this.length++),this},U.prototype.isZero=function(){return this.length===1&&this.words[0]===0},U.prototype.cmpn=function(j){var k=j<0;if(this.negative!==0&&!k)return-1;if(this.negative===0&&k)return 1;this.strip();var g;if(this.length>1)g=1;else{k&&(j=-j),G(j<=67108863,"Number is too big");var _=this.words[0]|0;g=_===j?0:_j.length)return 1;if(this.length=0;g--){var _=this.words[g]|0,N=j.words[g]|0;if(_!==N){_N&&(k=1);break}}return k},U.prototype.gtn=function(j){return this.cmpn(j)===1},U.prototype.gt=function(j){return this.cmp(j)===1},U.prototype.gten=function(j){return this.cmpn(j)>=0},U.prototype.gte=function(j){return this.cmp(j)>=0},U.prototype.ltn=function(j){return this.cmpn(j)===-1},U.prototype.lt=function(j){return this.cmp(j)===-1},U.prototype.lten=function(j){return this.cmpn(j)<=0},U.prototype.lte=function(j){return this.cmp(j)<=0},U.prototype.eqn=function(j){return this.cmpn(j)===0},U.prototype.eq=function(j){return this.cmp(j)===0},U.red=function(j){return new v(j)},U.prototype.toRed=function(j){return G(!this.red,"Already a number in reduction context"),G(this.negative===0,"red works only with positives"),j.convertTo(this)._forceRed(j)},U.prototype.fromRed=function(){return G(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},U.prototype._forceRed=function(j){return this.red=j,this},U.prototype.forceRed=function(j){return G(!this.red,"Already a number in reduction context"),this._forceRed(j)},U.prototype.redAdd=function(j){return G(this.red,"redAdd works only with red numbers"),this.red.add(this,j)},U.prototype.redIAdd=function(j){return G(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,j)},U.prototype.redSub=function(j){return G(this.red,"redSub works only with red numbers"),this.red.sub(this,j)},U.prototype.redISub=function(j){return G(this.red,"redISub works only with red numbers"),this.red.isub(this,j)},U.prototype.redShl=function(j){return G(this.red,"redShl works only with red numbers"),this.red.shl(this,j)},U.prototype.redMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.mul(this,j)},U.prototype.redIMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.imul(this,j)},U.prototype.redSqr=function(){return G(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},U.prototype.redISqr=function(){return G(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},U.prototype.redSqrt=function(){return G(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},U.prototype.redInvm=function(){return G(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},U.prototype.redNeg=function(){return G(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},U.prototype.redPow=function(j){return G(this.red&&!j.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,j)};var L={k256:null,p224:null,p192:null,p25519:null};function R(j,k){this.name=j,this.p=new U(k,16),this.n=this.p.bitLength(),this.k=new U(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}R.prototype._tmp=function(){var j=new U(null);return j.words=new Array(Math.ceil(this.n/13)),j},R.prototype.ireduce=function(j){var k=j,g;do this.split(k,this.tmp),k=this.imulK(k),k=k.iadd(this.tmp),g=k.bitLength();while(g>this.n);var _=g0?k.isub(this.p):k.strip!==void 0?k.strip():k._strip(),k},R.prototype.split=function(j,k){j.iushrn(this.n,0,k)},R.prototype.imulK=function(j){return j.imul(this.k)};function P(){R.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}V(P,R),P.prototype.split=function(j,k){for(var g=4194303,_=Math.min(j.length,9),N=0;N<_;N++)k.words[N]=j.words[N];if(k.length=_,j.length<=9){j.words[0]=0,j.length=1;return}var x=j.words[9];for(k.words[k.length++]=x&g,N=10;N>>22,x=B}x>>>=22,j.words[N-10]=x,x===0&&j.length>10?j.length-=10:j.length-=9},P.prototype.imulK=function(j){j.words[j.length]=0,j.words[j.length+1]=0,j.length+=2;for(var k=0,g=0;g>>=26,j.words[g]=N,k=_}return k!==0&&(j.words[j.length++]=k),j},U._prime=function(j){if(L[j])return L[j];var k;if(j==="k256")k=new P;else if(j==="p224")k=new z;else if(j==="p192")k=new M;else if(j==="p25519")k=new S;else throw new Error("Unknown prime "+j);return L[j]=k,k};function v(j){if(typeof j=="string"){var k=U._prime(j);this.m=k.p,this.prime=k}else G(j.gtn(1),"modulus must be greater than 1"),this.m=j,this.prime=null}v.prototype._verify1=function(j){G(j.negative===0,"red works only with positives"),G(j.red,"red works only with red numbers")},v.prototype._verify2=function(j,k){G((j.negative|k.negative)===0,"red works only with positives"),G(j.red&&j.red===k.red,"red works only with red numbers")},v.prototype.imod=function(j){return this.prime?this.prime.ireduce(j)._forceRed(this):j.umod(this.m)._forceRed(this)},v.prototype.neg=function(j){return j.isZero()?j.clone():this.m.sub(j)._forceRed(this)},v.prototype.add=function(j,k){this._verify2(j,k);var g=j.add(k);return g.cmp(this.m)>=0&&g.isub(this.m),g._forceRed(this)},v.prototype.iadd=function(j,k){this._verify2(j,k);var g=j.iadd(k);return g.cmp(this.m)>=0&&g.isub(this.m),g},v.prototype.sub=function(j,k){this._verify2(j,k);var g=j.sub(k);return g.cmpn(0)<0&&g.iadd(this.m),g._forceRed(this)},v.prototype.isub=function(j,k){this._verify2(j,k);var g=j.isub(k);return g.cmpn(0)<0&&g.iadd(this.m),g},v.prototype.shl=function(j,k){return this._verify1(j),this.imod(j.ushln(k))},v.prototype.imul=function(j,k){return this._verify2(j,k),this.imod(j.imul(k))},v.prototype.mul=function(j,k){return this._verify2(j,k),this.imod(j.mul(k))},v.prototype.isqr=function(j){return this.imul(j,j.clone())},v.prototype.sqr=function(j){return this.mul(j,j)},v.prototype.sqrt=function(j){if(j.isZero())return j.clone();var k=this.m.andln(3);if(G(k%2===1),k===3){var g=this.m.add(new U(1)).iushrn(2);return this.pow(j,g)}for(var _=this.m.subn(1),N=0;!_.isZero()&&_.andln(1)===0;)N++,_.iushrn(1);G(!_.isZero());var x=new U(1).toRed(this),B=x.redNeg(),y=this.m.subn(1).iushrn(1),w=this.m.bitLength();for(w=new U(2*w*w).toRed(this);this.pow(w,y).cmp(B)!==0;)w.redIAdd(B);for(var p=this.pow(w,_),f=this.pow(j,_.addn(1).iushrn(1)),c=this.pow(j,_),h=N;c.cmp(x)!==0;){for(var d=c,b=0;d.cmp(x)!==0;b++)d=d.redSqr();G(b=0;N--){for(var p=k.words[N],f=w-1;f>=0;f--){var c=p>>f&1;if(x!==_[0]&&(x=this.sqr(x)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(N!==0||f!==0))&&(x=this.mul(x,_[B]),y=0,B=0)}w=26}return x},v.prototype.convertTo=function(j){var k=j.umod(this.m);return k===j?k.clone():k},v.prototype.convertFrom=function(j){var k=j.clone();return k.red=null,k},U.mont=function(j){return new q(j)};function q(j){v.call(this,j),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new U(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}V(q,v),q.prototype.convertTo=function(j){return this.imod(j.ushln(this.shift))},q.prototype.convertFrom=function(j){var k=this.imod(j.mul(this.rinv));return k.red=null,k},q.prototype.imul=function(j,k){if(j.isZero()||k.isZero())return j.words[0]=0,j.length=1,j;var g=j.imul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.invm=function(j){var k=this.imod(j._invmp(this.m).mul(this.r2));return k._forceRed(this)}})(typeof Q>"u"||Q,$)}}),CY=q$({"node_modules/safer-buffer/safer.js"($,Q){var Y=M$,Z=F$,G={},V;for(V in Y)!Y.hasOwnProperty(V)||V==="SlowBuffer"||V==="Buffer"||(G[V]=Y[V]);var U=G.Buffer={};for(V in Z)!Z.hasOwnProperty(V)||V==="allocUnsafe"||V==="allocUnsafeSlow"||(U[V]=Z[V]);if(G.Buffer.prototype=Z.prototype,(!U.from||U.from===Uint8Array.from)&&(U.from=function(X,K,I){if(typeof X=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof X);if(X&&typeof X.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof X);return Z(X,K,I)}),U.alloc||(U.alloc=function(X,K,I){if(typeof X!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof X);if(X<0||X>=2*(1<<30))throw new RangeError('The value "'+X+'" is invalid for option "size"');var O=Z(X);return!K||K.length===0?O.fill(0):typeof I=="string"?O.fill(K,I):O.fill(K),O}),!G.kStringMaxLength)try{G.kStringMaxLength=S$}catch{}G.constants||(G.constants={MAX_LENGTH:G.kMaxLength},G.kStringMaxLength&&(G.constants.MAX_STRING_LENGTH=G.kStringMaxLength)),Q.exports=G}}),LY=q$({"node_modules/asn1.js/lib/asn1/base/reporter.js"($){var Q=_$();function Y(G){this._reporterState={obj:null,path:[],options:G||{},errors:[]}}$.Reporter=Y,Y.prototype.isError=function(G){return G instanceof Z},Y.prototype.save=function(){let G=this._reporterState;return{obj:G.obj,pathLen:G.path.length}},Y.prototype.restore=function(G){let V=this._reporterState;V.obj=G.obj,V.path=V.path.slice(0,G.pathLen)},Y.prototype.enterKey=function(G){return this._reporterState.path.push(G)},Y.prototype.exitKey=function(G){let V=this._reporterState;V.path=V.path.slice(0,G-1)},Y.prototype.leaveKey=function(G,V,U){let X=this._reporterState;this.exitKey(G),X.obj!==null&&(X.obj[V]=U)},Y.prototype.path=function(){return this._reporterState.path.join("/")},Y.prototype.enterObject=function(){let G=this._reporterState,V=G.obj;return G.obj={},V},Y.prototype.leaveObject=function(G){let V=this._reporterState,U=V.obj;return V.obj=G,U},Y.prototype.error=function(G){let V,U=this._reporterState,X=G instanceof Z;if(X?V=G:V=new Z(U.path.map(function(K){return"["+JSON.stringify(K)+"]"}).join(""),G.message||G,G.stack),!U.options.partial)throw V;return X||U.errors.push(V),V},Y.prototype.wrapResult=function(G){let V=this._reporterState;return V.options.partial?{result:this.isError(G)?null:G,errors:V.errors}:G};function Z(G,V){this.path=G,this.rethrow(V)}Q(Z,Error),Z.prototype.rethrow=function(G){if(this.message=G+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,Z),!this.stack)try{throw new Error(this.message)}catch(V){this.stack=V.stack}return this}}}),E$=q$({"node_modules/asn1.js/lib/asn1/base/buffer.js"($){var Q=_$(),Y=LY().Reporter,Z=CY().Buffer;function G(U,X){if(Y.call(this,X),!Z.isBuffer(U)){this.error("Input not Buffer");return}this.base=U,this.offset=0,this.length=U.length}Q(G,Y),$.DecoderBuffer=G,G.isDecoderBuffer=function(U){return U instanceof G?!0:typeof U=="object"&&Z.isBuffer(U.base)&&U.constructor.name==="DecoderBuffer"&&typeof U.offset=="number"&&typeof U.length=="number"&&typeof U.save=="function"&&typeof U.restore=="function"&&typeof U.isEmpty=="function"&&typeof U.readUInt8=="function"&&typeof U.skip=="function"&&typeof U.raw=="function"},G.prototype.save=function(){return{offset:this.offset,reporter:Y.prototype.save.call(this)}},G.prototype.restore=function(U){let X=new G(this.base);return X.offset=U.offset,X.length=this.offset,this.offset=U.offset,Y.prototype.restore.call(this,U.reporter),X},G.prototype.isEmpty=function(){return this.offset===this.length},G.prototype.readUInt8=function(U){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(U||"DecoderBuffer overrun")},G.prototype.skip=function(U,X){if(!(this.offset+U<=this.length))return this.error(X||"DecoderBuffer overrun");let K=new G(this.base);return K._reporterState=this._reporterState,K.offset=this.offset,K.length=this.offset+U,this.offset+=U,K},G.prototype.raw=function(U){return this.base.slice(U?U.offset:this.offset,this.length)};function V(U,X){if(Array.isArray(U))this.length=0,this.value=U.map(function(K){return V.isEncoderBuffer(K)||(K=new V(K,X)),this.length+=K.length,K},this);else if(typeof U=="number"){if(!(0<=U&&U<=255))return X.error("non-byte EncoderBuffer value");this.value=U,this.length=1}else if(typeof U=="string")this.value=U,this.length=Z.byteLength(U);else if(Z.isBuffer(U))this.value=U,this.length=U.length;else return X.error("Unsupported type: "+typeof U)}$.EncoderBuffer=V,V.isEncoderBuffer=function(U){return U instanceof V?!0:typeof U=="object"&&U.constructor.name==="EncoderBuffer"&&typeof U.length=="number"&&typeof U.join=="function"},V.prototype.join=function(U,X){return U||(U=Z.alloc(this.length)),X||(X=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(K){K.join(U,X),X+=K.length}):(typeof this.value=="number"?U[X]=this.value:typeof this.value=="string"?U.write(this.value,X):Z.isBuffer(this.value)&&this.value.copy(U,X),X+=this.length)),U}}}),RY=q$({"node_modules/asn1.js/lib/asn1/base/node.js"($,Q){var Y=LY().Reporter,Z=E$().EncoderBuffer,G=E$().DecoderBuffer,V=ZQ(),U=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],X=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(U),K=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function I(J,F,A){let H={};this._baseState=H,H.name=A,H.enc=J,H.parent=F||null,H.children=null,H.tag=null,H.args=null,H.reverseArgs=null,H.choice=null,H.optional=!1,H.any=!1,H.obj=!1,H.use=null,H.useDecoder=null,H.key=null,H.default=null,H.explicit=null,H.implicit=null,H.contains=null,H.parent||(H.children=[],this._wrap())}Q.exports=I;var O=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];I.prototype.clone=function(){let J=this._baseState,F={};O.forEach(function(H){F[H]=J[H]});let A=new this.constructor(F.parent);return A._baseState=F,A},I.prototype._wrap=function(){let J=this._baseState;X.forEach(function(F){this[F]=function(){let A=new this.constructor(this);return J.children.push(A),A[F].apply(A,arguments)}},this)},I.prototype._init=function(J){let F=this._baseState;V(F.parent===null),J.call(this),F.children=F.children.filter(function(A){return A._baseState.parent===this},this),V.equal(F.children.length,1,"Root node can have only one child")},I.prototype._useArgs=function(J){let F=this._baseState,A=J.filter(function(H){return H instanceof this.constructor},this);J=J.filter(function(H){return!(H instanceof this.constructor)},this),A.length!==0&&(V(F.children===null),F.children=A,A.forEach(function(H){H._baseState.parent=this},this)),J.length!==0&&(V(F.args===null),F.args=J,F.reverseArgs=J.map(function(H){if(typeof H!="object"||H.constructor!==Object)return H;let W={};return Object.keys(H).forEach(function(E){E==(E|0)&&(E|=0);let T=H[E];W[T]=E}),W}))},K.forEach(function(J){I.prototype[J]=function(){let F=this._baseState;throw new Error(J+" not implemented for encoding: "+F.enc)}}),U.forEach(function(J){I.prototype[J]=function(){let F=this._baseState,A=Array.prototype.slice.call(arguments);return V(F.tag===null),F.tag=J,this._useArgs(A),this}}),I.prototype.use=function(J){V(J);let F=this._baseState;return V(F.use===null),F.use=J,this},I.prototype.optional=function(){let J=this._baseState;return J.optional=!0,this},I.prototype.def=function(J){let F=this._baseState;return V(F.default===null),F.default=J,F.optional=!0,this},I.prototype.explicit=function(J){let F=this._baseState;return V(F.explicit===null&&F.implicit===null),F.explicit=J,this},I.prototype.implicit=function(J){let F=this._baseState;return V(F.explicit===null&&F.implicit===null),F.implicit=J,this},I.prototype.obj=function(){let J=this._baseState,F=Array.prototype.slice.call(arguments);return J.obj=!0,F.length!==0&&this._useArgs(F),this},I.prototype.key=function(J){let F=this._baseState;return V(F.key===null),F.key=J,this},I.prototype.any=function(){let J=this._baseState;return J.any=!0,this},I.prototype.choice=function(J){let F=this._baseState;return V(F.choice===null),F.choice=J,this._useArgs(Object.keys(J).map(function(A){return J[A]})),this},I.prototype.contains=function(J){let F=this._baseState;return V(F.use===null),F.contains=J,this},I.prototype._decode=function(J,F){let A=this._baseState;if(A.parent===null)return J.wrapResult(A.children[0]._decode(J,F));let H=A.default,W=!0,E=null;if(A.key!==null&&(E=J.enterKey(A.key)),A.optional){let D=null;if(A.explicit!==null?D=A.explicit:A.implicit!==null?D=A.implicit:A.tag!==null&&(D=A.tag),D===null&&!A.any){let C=J.save();try{A.choice===null?this._decodeGeneric(A.tag,J,F):this._decodeChoice(J,F),W=!0}catch{W=!1}J.restore(C)}else if(W=this._peekTag(J,D,A.any),J.isError(W))return W}let T;if(A.obj&&W&&(T=J.enterObject()),W){if(A.explicit!==null){let C=this._decodeTag(J,A.explicit);if(J.isError(C))return C;J=C}let D=J.offset;if(A.use===null&&A.choice===null){let C;A.any&&(C=J.save());let L=this._decodeTag(J,A.implicit!==null?A.implicit:A.tag,A.any);if(J.isError(L))return L;A.any?H=J.raw(C):J=L}if(F&&F.track&&A.tag!==null&&F.track(J.path(),D,J.length,"tagged"),F&&F.track&&A.tag!==null&&F.track(J.path(),J.offset,J.length,"content"),A.any||(A.choice===null?H=this._decodeGeneric(A.tag,J,F):H=this._decodeChoice(J,F)),J.isError(H))return H;if(!A.any&&A.choice===null&&A.children!==null&&A.children.forEach(function(C){C._decode(J,F)}),A.contains&&(A.tag==="octstr"||A.tag==="bitstr")){let C=new G(H);H=this._getUse(A.contains,J._reporterState.obj)._decode(C,F)}}return A.obj&&W&&(H=J.leaveObject(T)),A.key!==null&&(H!==null||W===!0)?J.leaveKey(E,A.key,H):E!==null&&J.exitKey(E),H},I.prototype._decodeGeneric=function(J,F,A){let H=this._baseState;return J==="seq"||J==="set"?null:J==="seqof"||J==="setof"?this._decodeList(F,J,H.args[0],A):/str$/.test(J)?this._decodeStr(F,J,A):J==="objid"&&H.args?this._decodeObjid(F,H.args[0],H.args[1],A):J==="objid"?this._decodeObjid(F,null,null,A):J==="gentime"||J==="utctime"?this._decodeTime(F,J,A):J==="null_"?this._decodeNull(F,A):J==="bool"?this._decodeBool(F,A):J==="objDesc"?this._decodeStr(F,J,A):J==="int"||J==="enum"?this._decodeInt(F,H.args&&H.args[0],A):H.use!==null?this._getUse(H.use,F._reporterState.obj)._decode(F,A):F.error("unknown tag: "+J)},I.prototype._getUse=function(J,F){let A=this._baseState;return A.useDecoder=this._use(J,F),V(A.useDecoder._baseState.parent===null),A.useDecoder=A.useDecoder._baseState.children[0],A.implicit!==A.useDecoder._baseState.implicit&&(A.useDecoder=A.useDecoder.clone(),A.useDecoder._baseState.implicit=A.implicit),A.useDecoder},I.prototype._decodeChoice=function(J,F){let A=this._baseState,H=null,W=!1;return Object.keys(A.choice).some(function(E){let T=J.save(),D=A.choice[E];try{let C=D._decode(J,F);if(J.isError(C))return!1;H={type:E,value:C},W=!0}catch{return J.restore(T),!1}return!0},this),W?H:J.error("Choice not matched")},I.prototype._createEncoderBuffer=function(J){return new Z(J,this.reporter)},I.prototype._encode=function(J,F,A){let H=this._baseState;if(H.default!==null&&H.default===J)return;let W=this._encodeValue(J,F,A);if(W!==void 0&&!this._skipDefault(W,F,A))return W},I.prototype._encodeValue=function(J,F,A){let H=this._baseState;if(H.parent===null)return H.children[0]._encode(J,F||new Y);let W=null;if(this.reporter=F,H.optional&&J===void 0)if(H.default!==null)J=H.default;else return;let E=null,T=!1;if(H.any)W=this._createEncoderBuffer(J);else if(H.choice)W=this._encodeChoice(J,F);else if(H.contains)E=this._getUse(H.contains,A)._encode(J,F),T=!0;else if(H.children)E=H.children.map(function(D){if(D._baseState.tag==="null_")return D._encode(null,F,J);if(D._baseState.key===null)return F.error("Child should have a key");let C=F.enterKey(D._baseState.key);if(typeof J!="object")return F.error("Child expected, but input is not object");let L=D._encode(J[D._baseState.key],F,J);return F.leaveKey(C),L},this).filter(function(D){return D}),E=this._createEncoderBuffer(E);else if(H.tag==="seqof"||H.tag==="setof"){if(!(H.args&&H.args.length===1))return F.error("Too many args for : "+H.tag);if(!Array.isArray(J))return F.error("seqof/setof, but data is not Array");let D=this.clone();D._baseState.implicit=null,E=this._createEncoderBuffer(J.map(function(C){let L=this._baseState;return this._getUse(L.args[0],J)._encode(C,F)},D))}else H.use!==null?W=this._getUse(H.use,A)._encode(J,F):(E=this._encodePrimitive(H.tag,J),T=!0);if(!H.any&&H.choice===null){let D=H.implicit!==null?H.implicit:H.tag,C=H.implicit===null?"universal":"context";D===null?H.use===null&&F.error("Tag could be omitted only for .use()"):H.use===null&&(W=this._encodeComposite(D,T,C,E))}return H.explicit!==null&&(W=this._encodeComposite(H.explicit,!1,"context",W)),W},I.prototype._encodeChoice=function(J,F){let A=this._baseState,H=A.choice[J.type];return H||V(!1,J.type+" not found in "+JSON.stringify(Object.keys(A.choice))),H._encode(J.value,F)},I.prototype._encodePrimitive=function(J,F){let A=this._baseState;if(/str$/.test(J))return this._encodeStr(F,J);if(J==="objid"&&A.args)return this._encodeObjid(F,A.reverseArgs[0],A.args[1]);if(J==="objid")return this._encodeObjid(F,null,null);if(J==="gentime"||J==="utctime")return this._encodeTime(F,J);if(J==="null_")return this._encodeNull();if(J==="int"||J==="enum")return this._encodeInt(F,A.args&&A.reverseArgs[0]);if(J==="bool")return this._encodeBool(F);if(J==="objDesc")return this._encodeStr(F,J);throw new Error("Unsupported tag: "+J)},I.prototype._isNumstr=function(J){return/^[0-9 ]*$/.test(J)},I.prototype._isPrintstr=function(J){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(J)}}}),PY=q$({"node_modules/asn1.js/lib/asn1/constants/der.js"($){function Q(Y){let Z={};return Object.keys(Y).forEach(function(G){(G|0)==G&&(G=G|0);let V=Y[G];Z[V]=G}),Z}$.tagClass={0:"universal",1:"application",2:"context",3:"private"},$.tagClassByName=Q($.tagClass),$.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},$.tagByName=Q($.tag)}}),zY=q$({"node_modules/asn1.js/lib/asn1/encoders/der.js"($,Q){var Y=_$(),Z=CY().Buffer,G=RY(),V=PY();function U(O){this.enc="der",this.name=O.name,this.entity=O,this.tree=new X,this.tree._init(O.body)}Q.exports=U,U.prototype.encode=function(O,J){return this.tree._encode(O,J).join()};function X(O){G.call(this,"der",O)}Y(X,G),X.prototype._encodeComposite=function(O,J,F,A){let H=I(O,J,F,this.reporter);if(A.length<128){let T=Z.alloc(2);return T[0]=H,T[1]=A.length,this._createEncoderBuffer([T,A])}let W=1;for(let T=A.length;T>=256;T>>=8)W++;let E=Z.alloc(2+W);E[0]=H,E[1]=128|W;for(let T=1+W,D=A.length;D>0;T--,D>>=8)E[T]=D&255;return this._createEncoderBuffer([E,A])},X.prototype._encodeStr=function(O,J){if(J==="bitstr")return this._createEncoderBuffer([O.unused|0,O.data]);if(J==="bmpstr"){let F=Z.alloc(O.length*2);for(let A=0;A=40)return this.reporter.error("Second objid identifier OOB");O.splice(0,2,O[0]*40+O[1])}let A=0;for(let E=0;E=128;T>>=7)A++}let H=Z.alloc(A),W=H.length-1;for(let E=O.length-1;E>=0;E--){let T=O[E];for(H[W--]=T&127;(T>>=7)>0;)H[W--]=128|T&127}return this._createEncoderBuffer(H)};function K(O){return O<10?"0"+O:O}X.prototype._encodeTime=function(O,J){let F,A=new Date(O);return J==="gentime"?F=[K(A.getUTCFullYear()),K(A.getUTCMonth()+1),K(A.getUTCDate()),K(A.getUTCHours()),K(A.getUTCMinutes()),K(A.getUTCSeconds()),"Z"].join(""):J==="utctime"?F=[K(A.getUTCFullYear()%100),K(A.getUTCMonth()+1),K(A.getUTCDate()),K(A.getUTCHours()),K(A.getUTCMinutes()),K(A.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+J+" time is not supported yet"),this._encodeStr(F,"octstr")},X.prototype._encodeNull=function(){return this._createEncoderBuffer("")},X.prototype._encodeInt=function(O,J){if(typeof O=="string"){if(!J)return this.reporter.error("String int or enum given, but no values map");if(!J.hasOwnProperty(O))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(O));O=J[O]}if(typeof O!="number"&&!Z.isBuffer(O)){let H=O.toArray();!O.sign&&H[0]&128&&H.unshift(0),O=Z.from(H)}if(Z.isBuffer(O)){let H=O.length;O.length===0&&H++;let W=Z.alloc(H);return O.copy(W),O.length===0&&(W[0]=0),this._createEncoderBuffer(W)}if(O<128)return this._createEncoderBuffer(O);if(O<256)return this._createEncoderBuffer([0,O]);let F=1;for(let H=O;H>=256;H>>=8)F++;let A=new Array(F);for(let H=A.length-1;H>=0;H--)A[H]=O&255,O>>=8;return A[0]&128&&A.unshift(0),this._createEncoderBuffer(Z.from(A))},X.prototype._encodeBool=function(O){return this._createEncoderBuffer(O?255:0)},X.prototype._use=function(O,J){return typeof O=="function"&&(O=O(J)),O._getEncoder("der").tree},X.prototype._skipDefault=function(O,J,F){let A=this._baseState,H;if(A.default===null)return!1;let W=O.join();if(A.defaultBuffer===void 0&&(A.defaultBuffer=this._encodeValue(A.default,J,F).join()),W.length!==A.defaultBuffer.length)return!1;for(H=0;H=31?A.error("Multi-octet tag encoding unsupported"):(J||(H|=32),H|=V.tagClassByName[F||"universal"]<<6,H)}}}),MY=q$({"node_modules/asn1.js/lib/asn1/encoders/pem.js"($,Q){var Y=_$(),Z=zY();function G(V){Z.call(this,V),this.enc="pem"}Y(G,Z),Q.exports=G,G.prototype.encode=function(V,U){let X=Z.prototype.encode.call(this,V).toString("base64"),K=["-----BEGIN "+U.label+"-----"];for(let I=0;I>6],W=(A&32)===0;if((A&31)===31){let T=A;for(A=0;(T&128)===128;){if(T=J.readUInt8(F),J.isError(T))return T;A<<=7,A|=T&127}}else A&=31;let E=U.tag[A];return{cls:H,primitive:W,tag:A,tagStr:E}}function O(J,F,A){let H=J.readUInt8(A);if(J.isError(H))return H;if(!F&&H===128)return null;if((H&128)===0)return H;let W=H&127;if(W>4)return J.error("length octect is too long");H=0;for(let E=0;E0&&L.ishrn(R),L}function W(D,C){D=H(D,C),D=D.mod(C);var L=Y.from(D.toArray());if(L.length=F)throw new Error("invalid sig")}Q.exports=X}}),dY=q$({"node_modules/browserify-sign/browser/index.js"($,Q){var Y=k$().Buffer,Z=o$(),G=_$(),V=cY(),U=hY(),X=t$();Object.keys(X).forEach(function(F){X[F].id=Y.from(X[F].id,"hex"),X[F.toLowerCase()]=X[F]});function K(F){A$.Writable.call(this);var A=X[F];if(!A)throw new Error("Unknown message digest");this._hashType=A.hash,this._hash=Z(A.hash),this._tag=A.id,this._signType=A.sign}G(K,A$.Writable),K.prototype._write=function(F,A,H){this._hash.update(F),H()},K.prototype.update=function(F,A){return typeof F=="string"&&(F=Y.from(F,A)),this._hash.update(F),this},K.prototype.sign=function(F,A){this.end();var H=this._hash.digest(),W=V(H,F,this._hashType,this._signType,this._tag);return A?W.toString(A):W};function I(F){A$.Writable.call(this);var A=X[F];if(!A)throw new Error("Unknown message digest");this._hash=Z(A.hash),this._tag=A.id,this._signType=A.sign}G(I,A$.Writable),I.prototype._write=function(F,A,H){this._hash.update(F),H()},I.prototype.update=function(F,A){return typeof F=="string"&&(F=Y.from(F,A)),this._hash.update(F),this},I.prototype.verify=function(F,A,H){typeof A=="string"&&(A=Y.from(A,H)),this.end();var W=this._hash.digest();return U(A,W,F,this._signType,this._tag)};function O(F){return new K(F)}function J(F){return new I(F)}Q.exports={Sign:O,Verify:J,createSign:O,createVerify:J}}}),bY=q$({"node_modules/create-ecdh/node_modules/bn.js/lib/bn.js"($,Q){(function(Y,Z){function G(j,k){if(!j)throw new Error(k||"Assertion failed")}function V(j,k){j.super_=k;var g=function(){};g.prototype=k.prototype,j.prototype=new g,j.prototype.constructor=j}function U(j,k,g){if(U.isBN(j))return j;this.negative=0,this.words=null,this.length=0,this.red=null,j!==null&&((k==="le"||k==="be")&&(g=k,k=10),this._init(j||0,k||10,g||"be"))}typeof Y=="object"?Y.exports=U:Z.BN=U,U.BN=U,U.wordSize=26;var X=F$;U.isBN=function(j){return j instanceof U?!0:j!==null&&typeof j=="object"&&j.constructor.wordSize===U.wordSize&&Array.isArray(j.words)},U.max=function(j,k){return j.cmp(k)>0?j:k},U.min=function(j,k){return j.cmp(k)<0?j:k},U.prototype._init=function(j,k,g){if(typeof j=="number")return this._initNumber(j,k,g);if(typeof j=="object")return this._initArray(j,k,g);k==="hex"&&(k=16),G(k===(k|0)&&k>=2&&k<=36),j=j.toString().replace(/\s+/g,"");var _=0;j[0]==="-"&&(_++,this.negative=1),_=0;_-=3)x=j[_]|j[_-1]<<8|j[_-2]<<16,this.words[N]|=x<>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);else if(g==="le")for(_=0,N=0;_>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);return this.strip()};function K(j,k){var g=j.charCodeAt(k);return g>=65&&g<=70?g-55:g>=97&&g<=102?g-87:g-48&15}function I(j,k,g){var _=K(j,g);return g-1>=k&&(_|=K(j,g-1)<<4),_}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var _=0;_=k;_-=2)B=I(j,k,_)<=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8;else{var y=j.length-k;for(_=y%2===0?k+1:k;_=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8}this.strip()};function O(j,k,g,_){for(var N=0,x=Math.min(j.length,g),B=k;B=49?N+=y-49+10:y>=17?N+=y-17+10:N+=y}return N}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var _=0,N=1;N<=67108863;N*=k)_++;_--,N=N/k|0;for(var x=j.length-g,B=x%_,y=Math.min(x,x-B)+g,w=0,p=g;p1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},U.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},U.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],F=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],A=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];U.prototype.toString=function(j,k){j=j||10,k=k|0||1;var g;if(j===16||j==="hex"){g="";for(var _=0,N=0,x=0;x>>24-_&16777215,N!==0||x!==this.length-1?g=J[6-y.length]+y+g:g=y+g,_+=2,_>=26&&(_-=26,x--)}for(N!==0&&(g=N.toString(16)+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}if(j===(j|0)&&j>=2&&j<=36){var w=F[j],p=A[j];g="";var f=this.clone();for(f.negative=0;!f.isZero();){var c=f.modn(p).toString(j);f=f.idivn(p),f.isZero()?g=c+g:g=J[w-c.length]+c+g}for(this.isZero()&&(g="0"+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}G(!1,"Base should be between 2 and 36")},U.prototype.toNumber=function(){var j=this.words[0];return this.length===2?j+=this.words[1]*67108864:this.length===3&&this.words[2]===1?j+=4503599627370496+this.words[1]*67108864:this.length>2&&G(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-j:j},U.prototype.toJSON=function(){return this.toString(16)},U.prototype.toBuffer=function(j,k){return G(typeof X<"u"),this.toArrayLike(X,j,k)},U.prototype.toArray=function(j,k){return this.toArrayLike(Array,j,k)},U.prototype.toArrayLike=function(j,k,g){var _=this.byteLength(),N=g||Math.max(1,_);G(_<=N,"byte array longer than desired length"),G(N>0,"Requested array length <= 0"),this.strip();var x=k==="le",B=new j(N),y,w,p=this.clone();if(x){for(w=0;!p.isZero();w++)y=p.andln(255),p.iushrn(8),B[w]=y;for(;w=4096&&(g+=13,k>>>=13),k>=64&&(g+=7,k>>>=7),k>=8&&(g+=4,k>>>=4),k>=2&&(g+=2,k>>>=2),g+k},U.prototype._zeroBits=function(j){if(j===0)return 26;var k=j,g=0;return(k&8191)===0&&(g+=13,k>>>=13),(k&127)===0&&(g+=7,k>>>=7),(k&15)===0&&(g+=4,k>>>=4),(k&3)===0&&(g+=2,k>>>=2),(k&1)===0&&g++,g},U.prototype.bitLength=function(){var j=this.words[this.length-1],k=this._countBits(j);return(this.length-1)*26+k};function H(j){for(var k=new Array(j.bitLength()),g=0;g>>N}return k}U.prototype.zeroBits=function(){if(this.isZero())return 0;for(var j=0,k=0;kj.length?this.clone().ior(j):j.clone().ior(this)},U.prototype.uor=function(j){return this.length>j.length?this.clone().iuor(j):j.clone().iuor(this)},U.prototype.iuand=function(j){var k;this.length>j.length?k=j:k=this;for(var g=0;gj.length?this.clone().iand(j):j.clone().iand(this)},U.prototype.uand=function(j){return this.length>j.length?this.clone().iuand(j):j.clone().iuand(this)},U.prototype.iuxor=function(j){var k,g;this.length>j.length?(k=this,g=j):(k=j,g=this);for(var _=0;_j.length?this.clone().ixor(j):j.clone().ixor(this)},U.prototype.uxor=function(j){return this.length>j.length?this.clone().iuxor(j):j.clone().iuxor(this)},U.prototype.inotn=function(j){G(typeof j=="number"&&j>=0);var k=Math.ceil(j/26)|0,g=j%26;this._expand(k),g>0&&k--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-g),this.strip()},U.prototype.notn=function(j){return this.clone().inotn(j)},U.prototype.setn=function(j,k){G(typeof j=="number"&&j>=0);var g=j/26|0,_=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<<_:this.words[g]=this.words[g]&~(1<<_),this.strip()},U.prototype.iadd=function(j){var k;if(this.negative!==0&&j.negative===0)return this.negative=0,k=this.isub(j),this.negative^=1,this._normSign();if(this.negative===0&&j.negative!==0)return j.negative=0,k=this.isub(j),j.negative=1,k._normSign();var g,_;this.length>j.length?(g=this,_=j):(g=j,_=this);for(var N=0,x=0;x<_.length;x++)k=(g.words[x]|0)+(_.words[x]|0)+N,this.words[x]=k&67108863,N=k>>>26;for(;N!==0&&x>>26;if(this.length=g.length,N!==0)this.words[this.length]=N,this.length++;else if(g!==this)for(;xj.length?this.clone().iadd(j):j.clone().iadd(this)},U.prototype.isub=function(j){if(j.negative!==0){j.negative=0;var k=this.iadd(j);return j.negative=1,k._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(j),this.negative=1,this._normSign();var g=this.cmp(j);if(g===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,N;g>0?(_=this,N=j):(_=j,N=this);for(var x=0,B=0;B>26,this.words[B]=k&67108863;for(;x!==0&&B<_.length;B++)k=(_.words[B]|0)+x,x=k>>26,this.words[B]=k&67108863;if(x===0&&B<_.length&&_!==this)for(;B<_.length;B++)this.words[B]=_.words[B];return this.length=Math.max(this.length,B),_!==this&&(this.negative=1),this.strip()},U.prototype.sub=function(j){return this.clone().isub(j)};function W(j,k,g){g.negative=k.negative^j.negative;var _=j.length+k.length|0;g.length=_,_=_-1|0;var N=j.words[0]|0,x=k.words[0]|0,B=N*x,y=B&67108863,w=B/67108864|0;g.words[0]=y;for(var p=1;p<_;p++){for(var f=w>>>26,c=w&67108863,h=Math.min(p,k.length-1),d=Math.max(0,p-j.length+1);d<=h;d++){var b=p-d|0;N=j.words[b]|0,x=k.words[d]|0,B=N*x+c,f+=B/67108864|0,c=B&67108863}g.words[p]=c|0,w=f|0}return w!==0?g.words[p]=w|0:g.length--,g.strip()}var E=function(j,k,g){var _=j.words,N=k.words,x=g.words,B=0,y,w,p,f=_[0]|0,c=f&8191,h=f>>>13,d=_[1]|0,b=d&8191,l=d>>>13,o=_[2]|0,u=o&8191,n=o>>>13,s=_[3]|0,t=s&8191,m=s>>>13,a=_[4]|0,e=a&8191,r=a>>>13,i=_[5]|0,$0=i&8191,Q0=i>>>13,Y0=_[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=_[7]|0,U0=V0&8191,X0=V0>>>13,K0=_[8]|0,I0=K0&8191,O0=K0>>>13,J0=_[9]|0,F0=J0&8191,A0=J0>>>13,H0=N[0]|0,W0=H0&8191,E0=H0>>>13,T0=N[1]|0,D0=T0&8191,C0=T0>>>13,L0=N[2]|0,R0=L0&8191,P0=L0>>>13,z0=N[3]|0,M0=z0&8191,S0=z0>>>13,v0=N[4]|0,q0=v0&8191,j0=v0>>>13,k0=N[5]|0,g0=k0&8191,_0=k0>>>13,N0=N[6]|0,x0=N0&8191,B0=N0>>>13,y0=N[7]|0,w0=y0&8191,p0=y0>>>13,f0=N[8]|0,c0=f0&8191,h0=f0>>>13,d0=N[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,W0),w=Math.imul(c,E0),w=w+Math.imul(h,W0)|0,p=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,W0),w=Math.imul(b,E0),w=w+Math.imul(l,W0)|0,p=Math.imul(l,E0),y=y+Math.imul(c,D0)|0,w=w+Math.imul(c,C0)|0,w=w+Math.imul(h,D0)|0,p=p+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,W0),w=Math.imul(u,E0),w=w+Math.imul(n,W0)|0,p=Math.imul(n,E0),y=y+Math.imul(b,D0)|0,w=w+Math.imul(b,C0)|0,w=w+Math.imul(l,D0)|0,p=p+Math.imul(l,C0)|0,y=y+Math.imul(c,R0)|0,w=w+Math.imul(c,P0)|0,w=w+Math.imul(h,R0)|0,p=p+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,W0),w=Math.imul(t,E0),w=w+Math.imul(m,W0)|0,p=Math.imul(m,E0),y=y+Math.imul(u,D0)|0,w=w+Math.imul(u,C0)|0,w=w+Math.imul(n,D0)|0,p=p+Math.imul(n,C0)|0,y=y+Math.imul(b,R0)|0,w=w+Math.imul(b,P0)|0,w=w+Math.imul(l,R0)|0,p=p+Math.imul(l,P0)|0,y=y+Math.imul(c,M0)|0,w=w+Math.imul(c,S0)|0,w=w+Math.imul(h,M0)|0,p=p+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(e,W0),w=Math.imul(e,E0),w=w+Math.imul(r,W0)|0,p=Math.imul(r,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,p=p+Math.imul(m,C0)|0,y=y+Math.imul(u,R0)|0,w=w+Math.imul(u,P0)|0,w=w+Math.imul(n,R0)|0,p=p+Math.imul(n,P0)|0,y=y+Math.imul(b,M0)|0,w=w+Math.imul(b,S0)|0,w=w+Math.imul(l,M0)|0,p=p+Math.imul(l,S0)|0,y=y+Math.imul(c,q0)|0,w=w+Math.imul(c,j0)|0,w=w+Math.imul(h,q0)|0,p=p+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,W0),w=Math.imul($0,E0),w=w+Math.imul(Q0,W0)|0,p=Math.imul(Q0,E0),y=y+Math.imul(e,D0)|0,w=w+Math.imul(e,C0)|0,w=w+Math.imul(r,D0)|0,p=p+Math.imul(r,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,p=p+Math.imul(m,P0)|0,y=y+Math.imul(u,M0)|0,w=w+Math.imul(u,S0)|0,w=w+Math.imul(n,M0)|0,p=p+Math.imul(n,S0)|0,y=y+Math.imul(b,q0)|0,w=w+Math.imul(b,j0)|0,w=w+Math.imul(l,q0)|0,p=p+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,_0)|0,w=w+Math.imul(h,g0)|0,p=p+Math.imul(h,_0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,W0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,W0)|0,p=Math.imul(G0,E0),y=y+Math.imul($0,D0)|0,w=w+Math.imul($0,C0)|0,w=w+Math.imul(Q0,D0)|0,p=p+Math.imul(Q0,C0)|0,y=y+Math.imul(e,R0)|0,w=w+Math.imul(e,P0)|0,w=w+Math.imul(r,R0)|0,p=p+Math.imul(r,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,p=p+Math.imul(m,S0)|0,y=y+Math.imul(u,q0)|0,w=w+Math.imul(u,j0)|0,w=w+Math.imul(n,q0)|0,p=p+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,_0)|0,w=w+Math.imul(l,g0)|0,p=p+Math.imul(l,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,x0)|0,p=p+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,W0),w=Math.imul(U0,E0),w=w+Math.imul(X0,W0)|0,p=Math.imul(X0,E0),y=y+Math.imul(Z0,D0)|0,w=w+Math.imul(Z0,C0)|0,w=w+Math.imul(G0,D0)|0,p=p+Math.imul(G0,C0)|0,y=y+Math.imul($0,R0)|0,w=w+Math.imul($0,P0)|0,w=w+Math.imul(Q0,R0)|0,p=p+Math.imul(Q0,P0)|0,y=y+Math.imul(e,M0)|0,w=w+Math.imul(e,S0)|0,w=w+Math.imul(r,M0)|0,p=p+Math.imul(r,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,p=p+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,_0)|0,w=w+Math.imul(n,g0)|0,p=p+Math.imul(n,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,x0)|0,p=p+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,p0)|0,w=w+Math.imul(h,w0)|0,p=p+Math.imul(h,p0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(I0,W0),w=Math.imul(I0,E0),w=w+Math.imul(O0,W0)|0,p=Math.imul(O0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,p=p+Math.imul(X0,C0)|0,y=y+Math.imul(Z0,R0)|0,w=w+Math.imul(Z0,P0)|0,w=w+Math.imul(G0,R0)|0,p=p+Math.imul(G0,P0)|0,y=y+Math.imul($0,M0)|0,w=w+Math.imul($0,S0)|0,w=w+Math.imul(Q0,M0)|0,p=p+Math.imul(Q0,S0)|0,y=y+Math.imul(e,q0)|0,w=w+Math.imul(e,j0)|0,w=w+Math.imul(r,q0)|0,p=p+Math.imul(r,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,_0)|0,w=w+Math.imul(m,g0)|0,p=p+Math.imul(m,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,x0)|0,p=p+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,p0)|0,w=w+Math.imul(l,w0)|0,p=p+Math.imul(l,p0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,p=p+Math.imul(h,h0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(F0,W0),w=Math.imul(F0,E0),w=w+Math.imul(A0,W0)|0,p=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(O0,D0)|0,p=p+Math.imul(O0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,p=p+Math.imul(X0,P0)|0,y=y+Math.imul(Z0,M0)|0,w=w+Math.imul(Z0,S0)|0,w=w+Math.imul(G0,M0)|0,p=p+Math.imul(G0,S0)|0,y=y+Math.imul($0,q0)|0,w=w+Math.imul($0,j0)|0,w=w+Math.imul(Q0,q0)|0,p=p+Math.imul(Q0,j0)|0,y=y+Math.imul(e,g0)|0,w=w+Math.imul(e,_0)|0,w=w+Math.imul(r,g0)|0,p=p+Math.imul(r,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,x0)|0,p=p+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,p0)|0,w=w+Math.imul(n,w0)|0,p=p+Math.imul(n,p0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,p=p+Math.imul(l,h0)|0,y=y+Math.imul(c,b0)|0,w=w+Math.imul(c,l0)|0,w=w+Math.imul(h,b0)|0,p=p+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(i0>>>26)|0,i0&=67108863,y=Math.imul(F0,D0),w=Math.imul(F0,C0),w=w+Math.imul(A0,D0)|0,p=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(O0,R0)|0,p=p+Math.imul(O0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,p=p+Math.imul(X0,S0)|0,y=y+Math.imul(Z0,q0)|0,w=w+Math.imul(Z0,j0)|0,w=w+Math.imul(G0,q0)|0,p=p+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,_0)|0,w=w+Math.imul(Q0,g0)|0,p=p+Math.imul(Q0,_0)|0,y=y+Math.imul(e,x0)|0,w=w+Math.imul(e,B0)|0,w=w+Math.imul(r,x0)|0,p=p+Math.imul(r,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,p0)|0,w=w+Math.imul(m,w0)|0,p=p+Math.imul(m,p0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,p=p+Math.imul(n,h0)|0,y=y+Math.imul(b,b0)|0,w=w+Math.imul(b,l0)|0,w=w+Math.imul(l,b0)|0,p=p+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,p=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(O0,M0)|0,p=p+Math.imul(O0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,p=p+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,_0)|0,w=w+Math.imul(G0,g0)|0,p=p+Math.imul(G0,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,x0)|0,p=p+Math.imul(Q0,B0)|0,y=y+Math.imul(e,w0)|0,w=w+Math.imul(e,p0)|0,w=w+Math.imul(r,w0)|0,p=p+Math.imul(r,p0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,p=p+Math.imul(m,h0)|0,y=y+Math.imul(u,b0)|0,w=w+Math.imul(u,l0)|0,w=w+Math.imul(n,b0)|0,p=p+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,y=Math.imul(F0,M0),w=Math.imul(F0,S0),w=w+Math.imul(A0,M0)|0,p=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(O0,q0)|0,p=p+Math.imul(O0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,_0)|0,w=w+Math.imul(X0,g0)|0,p=p+Math.imul(X0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,x0)|0,p=p+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,p0)|0,w=w+Math.imul(Q0,w0)|0,p=p+Math.imul(Q0,p0)|0,y=y+Math.imul(e,c0)|0,w=w+Math.imul(e,h0)|0,w=w+Math.imul(r,c0)|0,p=p+Math.imul(r,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,p=p+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,y=Math.imul(F0,q0),w=Math.imul(F0,j0),w=w+Math.imul(A0,q0)|0,p=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,_0)|0,w=w+Math.imul(O0,g0)|0,p=p+Math.imul(O0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,x0)|0,p=p+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,p0)|0,w=w+Math.imul(G0,w0)|0,p=p+Math.imul(G0,p0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,p=p+Math.imul(Q0,h0)|0,y=y+Math.imul(e,b0)|0,w=w+Math.imul(e,l0)|0,w=w+Math.imul(r,b0)|0,p=p+Math.imul(r,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,_0),w=w+Math.imul(A0,g0)|0,p=Math.imul(A0,_0),y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(O0,x0)|0,p=p+Math.imul(O0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,p0)|0,w=w+Math.imul(X0,w0)|0,p=p+Math.imul(X0,p0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,p=p+Math.imul(G0,h0)|0,y=y+Math.imul($0,b0)|0,w=w+Math.imul($0,l0)|0,w=w+Math.imul(Q0,b0)|0,p=p+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,x0),w=Math.imul(F0,B0),w=w+Math.imul(A0,x0)|0,p=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,p0)|0,w=w+Math.imul(O0,w0)|0,p=p+Math.imul(O0,p0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,p=p+Math.imul(X0,h0)|0,y=y+Math.imul(Z0,b0)|0,w=w+Math.imul(Z0,l0)|0,w=w+Math.imul(G0,b0)|0,p=p+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,p0),w=w+Math.imul(A0,w0)|0,p=Math.imul(A0,p0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(O0,c0)|0,p=p+Math.imul(O0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,p=p+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(U$>>>26)|0,U$&=67108863,y=Math.imul(F0,c0),w=Math.imul(F0,h0),w=w+Math.imul(A0,c0)|0,p=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(O0,b0)|0,p=p+Math.imul(O0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(X$>>>26)|0,X$&=67108863,y=Math.imul(F0,b0),w=Math.imul(F0,l0),w=w+Math.imul(A0,b0)|0,p=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(p+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,x[0]=o0,x[1]=u0,x[2]=n0,x[3]=s0,x[4]=t0,x[5]=m0,x[6]=a0,x[7]=e0,x[8]=r0,x[9]=i0,x[10]=$$,x[11]=Q$,x[12]=Y$,x[13]=Z$,x[14]=G$,x[15]=V$,x[16]=U$,x[17]=X$,x[18]=K$,B!==0&&(x[19]=B,g.length++),g};Math.imul||(E=W);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var _=0,N=0,x=0;x>>26)|0,N+=B>>>26,B&=67108863}g.words[x]=y,_=B,B=N}return _!==0?g.words[x]=_:g.length--,g.strip()}function D(j,k,g){var _=new C;return _.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,_=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):_<63?g=W(this,j,k):_<1024?g=T(this,j,k):g=D(this,j,k),g};function C(j,k){this.x=j,this.y=k}C.prototype.makeRBT=function(j){for(var k=new Array(j),g=U.prototype._countBits(j)-1,_=0;_>=1;return _},C.prototype.permute=function(j,k,g,_,N,x){for(var B=0;B>>1)N++;return 1<>>13,g[2*x+1]=N&8191,N=N>>>13;for(x=2*k;x<_;++x)g[x]=0;G(N===0),G((N&-8192)===0)},C.prototype.stub=function(j){for(var k=new Array(j),g=0;g>=26,k+=_/67108864|0,k+=N>>>26,this.words[g]=N&67108863}return k!==0&&(this.words[g]=k,this.length++),this},U.prototype.muln=function(j){return this.clone().imuln(j)},U.prototype.sqr=function(){return this.mul(this)},U.prototype.isqr=function(){return this.imul(this.clone())},U.prototype.pow=function(j){var k=H(j);if(k.length===0)return new U(1);for(var g=this,_=0;_=0);var k=j%26,g=(j-k)/26,_=67108863>>>26-k<<26-k,N;if(k!==0){var x=0;for(N=0;N>>26-k}x&&(this.words[N]=x,this.length++)}if(g!==0){for(N=this.length-1;N>=0;N--)this.words[N+g]=this.words[N];for(N=0;N=0);var _;k?_=(k-k%26)/26:_=0;var N=j%26,x=Math.min((j-N)/26,this.length),B=67108863^67108863>>>N<x)for(this.length-=x,w=0;w=0&&(p!==0||w>=_);w--){var f=this.words[w]|0;this.words[w]=p<<26-N|f>>>N,p=f&B}return y&&p!==0&&(y.words[y.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},U.prototype.ishrn=function(j,k,g){return G(this.negative===0),this.iushrn(j,k,g)},U.prototype.shln=function(j){return this.clone().ishln(j)},U.prototype.ushln=function(j){return this.clone().iushln(j)},U.prototype.shrn=function(j){return this.clone().ishrn(j)},U.prototype.ushrn=function(j){return this.clone().iushrn(j)},U.prototype.testn=function(j){G(typeof j=="number"&&j>=0);var k=j%26,g=(j-k)/26,_=1<=0);var k=j%26,g=(j-k)/26;if(G(this.negative===0,"imaskn works only with positive numbers"),this.length<=g)return this;if(k!==0&&g++,this.length=Math.min(g,this.length),k!==0){var _=67108863^67108863>>>k<=67108864;k++)this.words[k]-=67108864,k===this.length-1?this.words[k+1]=1:this.words[k+1]++;return this.length=Math.max(this.length,k+1),this},U.prototype.isubn=function(j){if(G(typeof j=="number"),G(j<67108864),j<0)return this.iaddn(-j);if(this.negative!==0)return this.negative=0,this.iaddn(j),this.negative=1,this;if(this.words[0]-=j,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var k=0;k>26)-(y/67108864|0),this.words[N+g]=x&67108863}for(;N>26,this.words[N+g]=x&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,_=this.clone(),N=j,x=N.words[N.length-1]|0,B=this._countBits(x);g=26-B,g!==0&&(N=N.ushln(g),_.iushln(g),x=N.words[N.length-1]|0);var y=_.length-N.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var p=0;p=0;c--){var h=(_.words[N.length+c]|0)*67108864+(_.words[N.length+c-1]|0);for(h=Math.min(h/x|0,67108863),_._ishlnsubmul(N,h,c);_.negative!==0;)h--,_.negative=0,_._ishlnsubmul(N,1,c),_.isZero()||(_.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),_.strip(),k!=="div"&&g!==0&&_.iushrn(g),{div:w||null,mod:_}},U.prototype.divmod=function(j,k,g){if(G(!j.isZero()),this.isZero())return{div:new U(0),mod:new U(0)};var _,N,x;return this.negative!==0&&j.negative===0?(x=this.neg().divmod(j,k),k!=="mod"&&(_=x.div.neg()),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.iadd(j)),{div:_,mod:N}):this.negative===0&&j.negative!==0?(x=this.divmod(j.neg(),k),k!=="mod"&&(_=x.div.neg()),{div:_,mod:x.mod}):(this.negative&j.negative)!==0?(x=this.neg().divmod(j.neg(),k),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.isub(j)),{div:x.div,mod:N}):j.length>this.length||this.cmp(j)<0?{div:new U(0),mod:this}:j.length===1?k==="div"?{div:this.divn(j.words[0]),mod:null}:k==="mod"?{div:null,mod:new U(this.modn(j.words[0]))}:{div:this.divn(j.words[0]),mod:new U(this.modn(j.words[0]))}:this._wordDiv(j,k)},U.prototype.div=function(j){return this.divmod(j,"div",!1).div},U.prototype.mod=function(j){return this.divmod(j,"mod",!1).mod},U.prototype.umod=function(j){return this.divmod(j,"mod",!0).mod},U.prototype.divRound=function(j){var k=this.divmod(j);if(k.mod.isZero())return k.div;var g=k.div.negative!==0?k.mod.isub(j):k.mod,_=j.ushrn(1),N=j.andln(1),x=g.cmp(_);return x<0||N===1&&x===0?k.div:k.div.negative!==0?k.div.isubn(1):k.div.iaddn(1)},U.prototype.modn=function(j){G(j<=67108863);for(var k=(1<<26)%j,g=0,_=this.length-1;_>=0;_--)g=(k*g+(this.words[_]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var _=(this.words[g]|0)+k*67108864;this.words[g]=_/j|0,k=_%j}return this.strip()},U.prototype.divn=function(j){return this.clone().idivn(j)},U.prototype.egcd=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=new U(0),B=new U(1),y=0;k.isEven()&&g.isEven();)k.iushrn(1),g.iushrn(1),++y;for(var w=g.clone(),p=k.clone();!k.isZero();){for(var f=0,c=1;(k.words[0]&c)===0&&f<26;++f,c<<=1);if(f>0)for(k.iushrn(f);f-- >0;)(_.isOdd()||N.isOdd())&&(_.iadd(w),N.isub(p)),_.iushrn(1),N.iushrn(1);for(var h=0,d=1;(g.words[0]&d)===0&&h<26;++h,d<<=1);if(h>0)for(g.iushrn(h);h-- >0;)(x.isOdd()||B.isOdd())&&(x.iadd(w),B.isub(p)),x.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(x),N.isub(B)):(g.isub(k),x.isub(_),B.isub(N))}return{a:x,b:B,gcd:g.iushln(y)}},U.prototype._invmp=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=g.clone();k.cmpn(1)>0&&g.cmpn(1)>0;){for(var B=0,y=1;(k.words[0]&y)===0&&B<26;++B,y<<=1);if(B>0)for(k.iushrn(B);B-- >0;)_.isOdd()&&_.iadd(x),_.iushrn(1);for(var w=0,p=1;(g.words[0]&p)===0&&w<26;++w,p<<=1);if(w>0)for(g.iushrn(w);w-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(N)):(g.isub(k),N.isub(_))}var f;return k.cmpn(1)===0?f=_:f=N,f.cmpn(0)<0&&f.iadd(j),f},U.prototype.gcd=function(j){if(this.isZero())return j.abs();if(j.isZero())return this.abs();var k=this.clone(),g=j.clone();k.negative=0,g.negative=0;for(var _=0;k.isEven()&&g.isEven();_++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var N=k.cmp(g);if(N<0){var x=k;k=g,g=x}else if(N===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(_)},U.prototype.invm=function(j){return this.egcd(j).a.umod(j)},U.prototype.isEven=function(){return(this.words[0]&1)===0},U.prototype.isOdd=function(){return(this.words[0]&1)===1},U.prototype.andln=function(j){return this.words[0]&j},U.prototype.bincn=function(j){G(typeof j=="number");var k=j%26,g=(j-k)/26,_=1<>>26,B&=67108863,this.words[x]=B}return N!==0&&(this.words[x]=N,this.length++),this},U.prototype.isZero=function(){return this.length===1&&this.words[0]===0},U.prototype.cmpn=function(j){var k=j<0;if(this.negative!==0&&!k)return-1;if(this.negative===0&&k)return 1;this.strip();var g;if(this.length>1)g=1;else{k&&(j=-j),G(j<=67108863,"Number is too big");var _=this.words[0]|0;g=_===j?0:_j.length)return 1;if(this.length=0;g--){var _=this.words[g]|0,N=j.words[g]|0;if(_!==N){_N&&(k=1);break}}return k},U.prototype.gtn=function(j){return this.cmpn(j)===1},U.prototype.gt=function(j){return this.cmp(j)===1},U.prototype.gten=function(j){return this.cmpn(j)>=0},U.prototype.gte=function(j){return this.cmp(j)>=0},U.prototype.ltn=function(j){return this.cmpn(j)===-1},U.prototype.lt=function(j){return this.cmp(j)===-1},U.prototype.lten=function(j){return this.cmpn(j)<=0},U.prototype.lte=function(j){return this.cmp(j)<=0},U.prototype.eqn=function(j){return this.cmpn(j)===0},U.prototype.eq=function(j){return this.cmp(j)===0},U.red=function(j){return new v(j)},U.prototype.toRed=function(j){return G(!this.red,"Already a number in reduction context"),G(this.negative===0,"red works only with positives"),j.convertTo(this)._forceRed(j)},U.prototype.fromRed=function(){return G(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},U.prototype._forceRed=function(j){return this.red=j,this},U.prototype.forceRed=function(j){return G(!this.red,"Already a number in reduction context"),this._forceRed(j)},U.prototype.redAdd=function(j){return G(this.red,"redAdd works only with red numbers"),this.red.add(this,j)},U.prototype.redIAdd=function(j){return G(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,j)},U.prototype.redSub=function(j){return G(this.red,"redSub works only with red numbers"),this.red.sub(this,j)},U.prototype.redISub=function(j){return G(this.red,"redISub works only with red numbers"),this.red.isub(this,j)},U.prototype.redShl=function(j){return G(this.red,"redShl works only with red numbers"),this.red.shl(this,j)},U.prototype.redMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.mul(this,j)},U.prototype.redIMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.imul(this,j)},U.prototype.redSqr=function(){return G(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},U.prototype.redISqr=function(){return G(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},U.prototype.redSqrt=function(){return G(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},U.prototype.redInvm=function(){return G(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},U.prototype.redNeg=function(){return G(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},U.prototype.redPow=function(j){return G(this.red&&!j.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,j)};var L={k256:null,p224:null,p192:null,p25519:null};function R(j,k){this.name=j,this.p=new U(k,16),this.n=this.p.bitLength(),this.k=new U(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}R.prototype._tmp=function(){var j=new U(null);return j.words=new Array(Math.ceil(this.n/13)),j},R.prototype.ireduce=function(j){var k=j,g;do this.split(k,this.tmp),k=this.imulK(k),k=k.iadd(this.tmp),g=k.bitLength();while(g>this.n);var _=g0?k.isub(this.p):k.strip!==void 0?k.strip():k._strip(),k},R.prototype.split=function(j,k){j.iushrn(this.n,0,k)},R.prototype.imulK=function(j){return j.imul(this.k)};function P(){R.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}V(P,R),P.prototype.split=function(j,k){for(var g=4194303,_=Math.min(j.length,9),N=0;N<_;N++)k.words[N]=j.words[N];if(k.length=_,j.length<=9){j.words[0]=0,j.length=1;return}var x=j.words[9];for(k.words[k.length++]=x&g,N=10;N>>22,x=B}x>>>=22,j.words[N-10]=x,x===0&&j.length>10?j.length-=10:j.length-=9},P.prototype.imulK=function(j){j.words[j.length]=0,j.words[j.length+1]=0,j.length+=2;for(var k=0,g=0;g>>=26,j.words[g]=N,k=_}return k!==0&&(j.words[j.length++]=k),j},U._prime=function(j){if(L[j])return L[j];var k;if(j==="k256")k=new P;else if(j==="p224")k=new z;else if(j==="p192")k=new M;else if(j==="p25519")k=new S;else throw new Error("Unknown prime "+j);return L[j]=k,k};function v(j){if(typeof j=="string"){var k=U._prime(j);this.m=k.p,this.prime=k}else G(j.gtn(1),"modulus must be greater than 1"),this.m=j,this.prime=null}v.prototype._verify1=function(j){G(j.negative===0,"red works only with positives"),G(j.red,"red works only with red numbers")},v.prototype._verify2=function(j,k){G((j.negative|k.negative)===0,"red works only with positives"),G(j.red&&j.red===k.red,"red works only with red numbers")},v.prototype.imod=function(j){return this.prime?this.prime.ireduce(j)._forceRed(this):j.umod(this.m)._forceRed(this)},v.prototype.neg=function(j){return j.isZero()?j.clone():this.m.sub(j)._forceRed(this)},v.prototype.add=function(j,k){this._verify2(j,k);var g=j.add(k);return g.cmp(this.m)>=0&&g.isub(this.m),g._forceRed(this)},v.prototype.iadd=function(j,k){this._verify2(j,k);var g=j.iadd(k);return g.cmp(this.m)>=0&&g.isub(this.m),g},v.prototype.sub=function(j,k){this._verify2(j,k);var g=j.sub(k);return g.cmpn(0)<0&&g.iadd(this.m),g._forceRed(this)},v.prototype.isub=function(j,k){this._verify2(j,k);var g=j.isub(k);return g.cmpn(0)<0&&g.iadd(this.m),g},v.prototype.shl=function(j,k){return this._verify1(j),this.imod(j.ushln(k))},v.prototype.imul=function(j,k){return this._verify2(j,k),this.imod(j.imul(k))},v.prototype.mul=function(j,k){return this._verify2(j,k),this.imod(j.mul(k))},v.prototype.isqr=function(j){return this.imul(j,j.clone())},v.prototype.sqr=function(j){return this.mul(j,j)},v.prototype.sqrt=function(j){if(j.isZero())return j.clone();var k=this.m.andln(3);if(G(k%2===1),k===3){var g=this.m.add(new U(1)).iushrn(2);return this.pow(j,g)}for(var _=this.m.subn(1),N=0;!_.isZero()&&_.andln(1)===0;)N++,_.iushrn(1);G(!_.isZero());var x=new U(1).toRed(this),B=x.redNeg(),y=this.m.subn(1).iushrn(1),w=this.m.bitLength();for(w=new U(2*w*w).toRed(this);this.pow(w,y).cmp(B)!==0;)w.redIAdd(B);for(var p=this.pow(w,_),f=this.pow(j,_.addn(1).iushrn(1)),c=this.pow(j,_),h=N;c.cmp(x)!==0;){for(var d=c,b=0;d.cmp(x)!==0;b++)d=d.redSqr();G(b=0;N--){for(var p=k.words[N],f=w-1;f>=0;f--){var c=p>>f&1;if(x!==_[0]&&(x=this.sqr(x)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(N!==0||f!==0))&&(x=this.mul(x,_[B]),y=0,B=0)}w=26}return x},v.prototype.convertTo=function(j){var k=j.umod(this.m);return k===j?k.clone():k},v.prototype.convertFrom=function(j){var k=j.clone();return k.red=null,k},U.mont=function(j){return new q(j)};function q(j){v.call(this,j),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new U(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}V(q,v),q.prototype.convertTo=function(j){return this.imod(j.ushln(this.shift))},q.prototype.convertFrom=function(j){var k=this.imod(j.mul(this.rinv));return k.red=null,k},q.prototype.imul=function(j,k){if(j.isZero()||k.isZero())return j.words[0]=0,j.length=1,j;var g=j.imul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.invm=function(j){var k=this.imod(j._invmp(this.m).mul(this.r2));return k._forceRed(this)}})(typeof Q>"u"||Q,$)}}),lY=q$({"node_modules/create-ecdh/browser.js"($,Q){var Y=TY(),Z=bY();Q.exports=function(X){return new V(X)};var G={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};G.p224=G.secp224r1,G.p256=G.secp256r1=G.prime256v1,G.p192=G.secp192r1=G.prime192v1,G.p384=G.secp384r1,G.p521=G.secp521r1;function V(X){this.curveType=G[X],this.curveType||(this.curveType={name:X}),this.curve=new Y.ec(this.curveType.name),this.keys=void 0}V.prototype.generateKeys=function(X,K){return this.keys=this.curve.genKeyPair(),this.getPublicKey(X,K)},V.prototype.computeSecret=function(X,K,I){K=K||"utf8",F$.isBuffer(X)||(X=new F$(X,K));var O=this.curve.keyFromPublic(X).getPublic(),J=O.mul(this.keys.getPrivate()).getX();return U(J,I,this.curveType.byteLength)},V.prototype.getPublicKey=function(X,K){var I=this.keys.getPublic(K==="compressed",!0);return K==="hybrid"&&(I[I.length-1]%2?I[0]=7:I[0]=6),U(I,X)},V.prototype.getPrivateKey=function(X){return U(this.keys.getPrivate(),X)},V.prototype.setPublicKey=function(X,K){return K=K||"utf8",F$.isBuffer(X)||(X=new F$(X,K)),this.keys._importPublic(X),this},V.prototype.setPrivateKey=function(X,K){K=K||"utf8",F$.isBuffer(X)||(X=new F$(X,K));var I=new Z(X);return I=I.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(I),this};function U(X,K,I){Array.isArray(X)||(X=X.toArray());var O=new F$(X);if(I&&O.length0?j:k},U.min=function(j,k){return j.cmp(k)<0?j:k},U.prototype._init=function(j,k,g){if(typeof j=="number")return this._initNumber(j,k,g);if(typeof j=="object")return this._initArray(j,k,g);k==="hex"&&(k=16),G(k===(k|0)&&k>=2&&k<=36),j=j.toString().replace(/\s+/g,"");var _=0;j[0]==="-"&&(_++,this.negative=1),_=0;_-=3)x=j[_]|j[_-1]<<8|j[_-2]<<16,this.words[N]|=x<>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);else if(g==="le")for(_=0,N=0;_>>26-B&67108863,B+=24,B>=26&&(B-=26,N++);return this.strip()};function K(j,k){var g=j.charCodeAt(k);return g>=65&&g<=70?g-55:g>=97&&g<=102?g-87:g-48&15}function I(j,k,g){var _=K(j,g);return g-1>=k&&(_|=K(j,g-1)<<4),_}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var _=0;_=k;_-=2)B=I(j,k,_)<=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8;else{var y=j.length-k;for(_=y%2===0?k+1:k;_=18?(N-=18,x+=1,this.words[x]|=B>>>26):N+=8}this.strip()};function O(j,k,g,_){for(var N=0,x=Math.min(j.length,g),B=k;B=49?N+=y-49+10:y>=17?N+=y-17+10:N+=y}return N}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var _=0,N=1;N<=67108863;N*=k)_++;_--,N=N/k|0;for(var x=j.length-g,B=x%_,y=Math.min(x,x-B)+g,w=0,p=g;p1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},U.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},U.prototype.inspect=function(){return(this.red?""};var J=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],F=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],A=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];U.prototype.toString=function(j,k){j=j||10,k=k|0||1;var g;if(j===16||j==="hex"){g="";for(var _=0,N=0,x=0;x>>24-_&16777215,N!==0||x!==this.length-1?g=J[6-y.length]+y+g:g=y+g,_+=2,_>=26&&(_-=26,x--)}for(N!==0&&(g=N.toString(16)+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}if(j===(j|0)&&j>=2&&j<=36){var w=F[j],p=A[j];g="";var f=this.clone();for(f.negative=0;!f.isZero();){var c=f.modn(p).toString(j);f=f.idivn(p),f.isZero()?g=c+g:g=J[w-c.length]+c+g}for(this.isZero()&&(g="0"+g);g.length%k!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}G(!1,"Base should be between 2 and 36")},U.prototype.toNumber=function(){var j=this.words[0];return this.length===2?j+=this.words[1]*67108864:this.length===3&&this.words[2]===1?j+=4503599627370496+this.words[1]*67108864:this.length>2&&G(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-j:j},U.prototype.toJSON=function(){return this.toString(16)},U.prototype.toBuffer=function(j,k){return G(typeof X<"u"),this.toArrayLike(X,j,k)},U.prototype.toArray=function(j,k){return this.toArrayLike(Array,j,k)},U.prototype.toArrayLike=function(j,k,g){var _=this.byteLength(),N=g||Math.max(1,_);G(_<=N,"byte array longer than desired length"),G(N>0,"Requested array length <= 0"),this.strip();var x=k==="le",B=new j(N),y,w,p=this.clone();if(x){for(w=0;!p.isZero();w++)y=p.andln(255),p.iushrn(8),B[w]=y;for(;w=4096&&(g+=13,k>>>=13),k>=64&&(g+=7,k>>>=7),k>=8&&(g+=4,k>>>=4),k>=2&&(g+=2,k>>>=2),g+k},U.prototype._zeroBits=function(j){if(j===0)return 26;var k=j,g=0;return(k&8191)===0&&(g+=13,k>>>=13),(k&127)===0&&(g+=7,k>>>=7),(k&15)===0&&(g+=4,k>>>=4),(k&3)===0&&(g+=2,k>>>=2),(k&1)===0&&g++,g},U.prototype.bitLength=function(){var j=this.words[this.length-1],k=this._countBits(j);return(this.length-1)*26+k};function H(j){for(var k=new Array(j.bitLength()),g=0;g>>N}return k}U.prototype.zeroBits=function(){if(this.isZero())return 0;for(var j=0,k=0;kj.length?this.clone().ior(j):j.clone().ior(this)},U.prototype.uor=function(j){return this.length>j.length?this.clone().iuor(j):j.clone().iuor(this)},U.prototype.iuand=function(j){var k;this.length>j.length?k=j:k=this;for(var g=0;gj.length?this.clone().iand(j):j.clone().iand(this)},U.prototype.uand=function(j){return this.length>j.length?this.clone().iuand(j):j.clone().iuand(this)},U.prototype.iuxor=function(j){var k,g;this.length>j.length?(k=this,g=j):(k=j,g=this);for(var _=0;_j.length?this.clone().ixor(j):j.clone().ixor(this)},U.prototype.uxor=function(j){return this.length>j.length?this.clone().iuxor(j):j.clone().iuxor(this)},U.prototype.inotn=function(j){G(typeof j=="number"&&j>=0);var k=Math.ceil(j/26)|0,g=j%26;this._expand(k),g>0&&k--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-g),this.strip()},U.prototype.notn=function(j){return this.clone().inotn(j)},U.prototype.setn=function(j,k){G(typeof j=="number"&&j>=0);var g=j/26|0,_=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<<_:this.words[g]=this.words[g]&~(1<<_),this.strip()},U.prototype.iadd=function(j){var k;if(this.negative!==0&&j.negative===0)return this.negative=0,k=this.isub(j),this.negative^=1,this._normSign();if(this.negative===0&&j.negative!==0)return j.negative=0,k=this.isub(j),j.negative=1,k._normSign();var g,_;this.length>j.length?(g=this,_=j):(g=j,_=this);for(var N=0,x=0;x<_.length;x++)k=(g.words[x]|0)+(_.words[x]|0)+N,this.words[x]=k&67108863,N=k>>>26;for(;N!==0&&x>>26;if(this.length=g.length,N!==0)this.words[this.length]=N,this.length++;else if(g!==this)for(;xj.length?this.clone().iadd(j):j.clone().iadd(this)},U.prototype.isub=function(j){if(j.negative!==0){j.negative=0;var k=this.iadd(j);return j.negative=1,k._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(j),this.negative=1,this._normSign();var g=this.cmp(j);if(g===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,N;g>0?(_=this,N=j):(_=j,N=this);for(var x=0,B=0;B>26,this.words[B]=k&67108863;for(;x!==0&&B<_.length;B++)k=(_.words[B]|0)+x,x=k>>26,this.words[B]=k&67108863;if(x===0&&B<_.length&&_!==this)for(;B<_.length;B++)this.words[B]=_.words[B];return this.length=Math.max(this.length,B),_!==this&&(this.negative=1),this.strip()},U.prototype.sub=function(j){return this.clone().isub(j)};function W(j,k,g){g.negative=k.negative^j.negative;var _=j.length+k.length|0;g.length=_,_=_-1|0;var N=j.words[0]|0,x=k.words[0]|0,B=N*x,y=B&67108863,w=B/67108864|0;g.words[0]=y;for(var p=1;p<_;p++){for(var f=w>>>26,c=w&67108863,h=Math.min(p,k.length-1),d=Math.max(0,p-j.length+1);d<=h;d++){var b=p-d|0;N=j.words[b]|0,x=k.words[d]|0,B=N*x+c,f+=B/67108864|0,c=B&67108863}g.words[p]=c|0,w=f|0}return w!==0?g.words[p]=w|0:g.length--,g.strip()}var E=function(j,k,g){var _=j.words,N=k.words,x=g.words,B=0,y,w,p,f=_[0]|0,c=f&8191,h=f>>>13,d=_[1]|0,b=d&8191,l=d>>>13,o=_[2]|0,u=o&8191,n=o>>>13,s=_[3]|0,t=s&8191,m=s>>>13,a=_[4]|0,e=a&8191,r=a>>>13,i=_[5]|0,$0=i&8191,Q0=i>>>13,Y0=_[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=_[7]|0,U0=V0&8191,X0=V0>>>13,K0=_[8]|0,I0=K0&8191,O0=K0>>>13,J0=_[9]|0,F0=J0&8191,A0=J0>>>13,H0=N[0]|0,W0=H0&8191,E0=H0>>>13,T0=N[1]|0,D0=T0&8191,C0=T0>>>13,L0=N[2]|0,R0=L0&8191,P0=L0>>>13,z0=N[3]|0,M0=z0&8191,S0=z0>>>13,v0=N[4]|0,q0=v0&8191,j0=v0>>>13,k0=N[5]|0,g0=k0&8191,_0=k0>>>13,N0=N[6]|0,x0=N0&8191,B0=N0>>>13,y0=N[7]|0,w0=y0&8191,p0=y0>>>13,f0=N[8]|0,c0=f0&8191,h0=f0>>>13,d0=N[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,W0),w=Math.imul(c,E0),w=w+Math.imul(h,W0)|0,p=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,W0),w=Math.imul(b,E0),w=w+Math.imul(l,W0)|0,p=Math.imul(l,E0),y=y+Math.imul(c,D0)|0,w=w+Math.imul(c,C0)|0,w=w+Math.imul(h,D0)|0,p=p+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,W0),w=Math.imul(u,E0),w=w+Math.imul(n,W0)|0,p=Math.imul(n,E0),y=y+Math.imul(b,D0)|0,w=w+Math.imul(b,C0)|0,w=w+Math.imul(l,D0)|0,p=p+Math.imul(l,C0)|0,y=y+Math.imul(c,R0)|0,w=w+Math.imul(c,P0)|0,w=w+Math.imul(h,R0)|0,p=p+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,W0),w=Math.imul(t,E0),w=w+Math.imul(m,W0)|0,p=Math.imul(m,E0),y=y+Math.imul(u,D0)|0,w=w+Math.imul(u,C0)|0,w=w+Math.imul(n,D0)|0,p=p+Math.imul(n,C0)|0,y=y+Math.imul(b,R0)|0,w=w+Math.imul(b,P0)|0,w=w+Math.imul(l,R0)|0,p=p+Math.imul(l,P0)|0,y=y+Math.imul(c,M0)|0,w=w+Math.imul(c,S0)|0,w=w+Math.imul(h,M0)|0,p=p+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(e,W0),w=Math.imul(e,E0),w=w+Math.imul(r,W0)|0,p=Math.imul(r,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,p=p+Math.imul(m,C0)|0,y=y+Math.imul(u,R0)|0,w=w+Math.imul(u,P0)|0,w=w+Math.imul(n,R0)|0,p=p+Math.imul(n,P0)|0,y=y+Math.imul(b,M0)|0,w=w+Math.imul(b,S0)|0,w=w+Math.imul(l,M0)|0,p=p+Math.imul(l,S0)|0,y=y+Math.imul(c,q0)|0,w=w+Math.imul(c,j0)|0,w=w+Math.imul(h,q0)|0,p=p+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,W0),w=Math.imul($0,E0),w=w+Math.imul(Q0,W0)|0,p=Math.imul(Q0,E0),y=y+Math.imul(e,D0)|0,w=w+Math.imul(e,C0)|0,w=w+Math.imul(r,D0)|0,p=p+Math.imul(r,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,p=p+Math.imul(m,P0)|0,y=y+Math.imul(u,M0)|0,w=w+Math.imul(u,S0)|0,w=w+Math.imul(n,M0)|0,p=p+Math.imul(n,S0)|0,y=y+Math.imul(b,q0)|0,w=w+Math.imul(b,j0)|0,w=w+Math.imul(l,q0)|0,p=p+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,_0)|0,w=w+Math.imul(h,g0)|0,p=p+Math.imul(h,_0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,W0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,W0)|0,p=Math.imul(G0,E0),y=y+Math.imul($0,D0)|0,w=w+Math.imul($0,C0)|0,w=w+Math.imul(Q0,D0)|0,p=p+Math.imul(Q0,C0)|0,y=y+Math.imul(e,R0)|0,w=w+Math.imul(e,P0)|0,w=w+Math.imul(r,R0)|0,p=p+Math.imul(r,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,p=p+Math.imul(m,S0)|0,y=y+Math.imul(u,q0)|0,w=w+Math.imul(u,j0)|0,w=w+Math.imul(n,q0)|0,p=p+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,_0)|0,w=w+Math.imul(l,g0)|0,p=p+Math.imul(l,_0)|0,y=y+Math.imul(c,x0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,x0)|0,p=p+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,W0),w=Math.imul(U0,E0),w=w+Math.imul(X0,W0)|0,p=Math.imul(X0,E0),y=y+Math.imul(Z0,D0)|0,w=w+Math.imul(Z0,C0)|0,w=w+Math.imul(G0,D0)|0,p=p+Math.imul(G0,C0)|0,y=y+Math.imul($0,R0)|0,w=w+Math.imul($0,P0)|0,w=w+Math.imul(Q0,R0)|0,p=p+Math.imul(Q0,P0)|0,y=y+Math.imul(e,M0)|0,w=w+Math.imul(e,S0)|0,w=w+Math.imul(r,M0)|0,p=p+Math.imul(r,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,p=p+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,_0)|0,w=w+Math.imul(n,g0)|0,p=p+Math.imul(n,_0)|0,y=y+Math.imul(b,x0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,x0)|0,p=p+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,p0)|0,w=w+Math.imul(h,w0)|0,p=p+Math.imul(h,p0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(I0,W0),w=Math.imul(I0,E0),w=w+Math.imul(O0,W0)|0,p=Math.imul(O0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,p=p+Math.imul(X0,C0)|0,y=y+Math.imul(Z0,R0)|0,w=w+Math.imul(Z0,P0)|0,w=w+Math.imul(G0,R0)|0,p=p+Math.imul(G0,P0)|0,y=y+Math.imul($0,M0)|0,w=w+Math.imul($0,S0)|0,w=w+Math.imul(Q0,M0)|0,p=p+Math.imul(Q0,S0)|0,y=y+Math.imul(e,q0)|0,w=w+Math.imul(e,j0)|0,w=w+Math.imul(r,q0)|0,p=p+Math.imul(r,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,_0)|0,w=w+Math.imul(m,g0)|0,p=p+Math.imul(m,_0)|0,y=y+Math.imul(u,x0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,x0)|0,p=p+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,p0)|0,w=w+Math.imul(l,w0)|0,p=p+Math.imul(l,p0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,p=p+Math.imul(h,h0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(F0,W0),w=Math.imul(F0,E0),w=w+Math.imul(A0,W0)|0,p=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(O0,D0)|0,p=p+Math.imul(O0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,p=p+Math.imul(X0,P0)|0,y=y+Math.imul(Z0,M0)|0,w=w+Math.imul(Z0,S0)|0,w=w+Math.imul(G0,M0)|0,p=p+Math.imul(G0,S0)|0,y=y+Math.imul($0,q0)|0,w=w+Math.imul($0,j0)|0,w=w+Math.imul(Q0,q0)|0,p=p+Math.imul(Q0,j0)|0,y=y+Math.imul(e,g0)|0,w=w+Math.imul(e,_0)|0,w=w+Math.imul(r,g0)|0,p=p+Math.imul(r,_0)|0,y=y+Math.imul(t,x0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,x0)|0,p=p+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,p0)|0,w=w+Math.imul(n,w0)|0,p=p+Math.imul(n,p0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,p=p+Math.imul(l,h0)|0,y=y+Math.imul(c,b0)|0,w=w+Math.imul(c,l0)|0,w=w+Math.imul(h,b0)|0,p=p+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(i0>>>26)|0,i0&=67108863,y=Math.imul(F0,D0),w=Math.imul(F0,C0),w=w+Math.imul(A0,D0)|0,p=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(O0,R0)|0,p=p+Math.imul(O0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,p=p+Math.imul(X0,S0)|0,y=y+Math.imul(Z0,q0)|0,w=w+Math.imul(Z0,j0)|0,w=w+Math.imul(G0,q0)|0,p=p+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,_0)|0,w=w+Math.imul(Q0,g0)|0,p=p+Math.imul(Q0,_0)|0,y=y+Math.imul(e,x0)|0,w=w+Math.imul(e,B0)|0,w=w+Math.imul(r,x0)|0,p=p+Math.imul(r,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,p0)|0,w=w+Math.imul(m,w0)|0,p=p+Math.imul(m,p0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,p=p+Math.imul(n,h0)|0,y=y+Math.imul(b,b0)|0,w=w+Math.imul(b,l0)|0,w=w+Math.imul(l,b0)|0,p=p+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,p=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(O0,M0)|0,p=p+Math.imul(O0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,p=p+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,_0)|0,w=w+Math.imul(G0,g0)|0,p=p+Math.imul(G0,_0)|0,y=y+Math.imul($0,x0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,x0)|0,p=p+Math.imul(Q0,B0)|0,y=y+Math.imul(e,w0)|0,w=w+Math.imul(e,p0)|0,w=w+Math.imul(r,w0)|0,p=p+Math.imul(r,p0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,p=p+Math.imul(m,h0)|0,y=y+Math.imul(u,b0)|0,w=w+Math.imul(u,l0)|0,w=w+Math.imul(n,b0)|0,p=p+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,y=Math.imul(F0,M0),w=Math.imul(F0,S0),w=w+Math.imul(A0,M0)|0,p=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(O0,q0)|0,p=p+Math.imul(O0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,_0)|0,w=w+Math.imul(X0,g0)|0,p=p+Math.imul(X0,_0)|0,y=y+Math.imul(Z0,x0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,x0)|0,p=p+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,p0)|0,w=w+Math.imul(Q0,w0)|0,p=p+Math.imul(Q0,p0)|0,y=y+Math.imul(e,c0)|0,w=w+Math.imul(e,h0)|0,w=w+Math.imul(r,c0)|0,p=p+Math.imul(r,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,p=p+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,y=Math.imul(F0,q0),w=Math.imul(F0,j0),w=w+Math.imul(A0,q0)|0,p=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,_0)|0,w=w+Math.imul(O0,g0)|0,p=p+Math.imul(O0,_0)|0,y=y+Math.imul(U0,x0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,x0)|0,p=p+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,p0)|0,w=w+Math.imul(G0,w0)|0,p=p+Math.imul(G0,p0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,p=p+Math.imul(Q0,h0)|0,y=y+Math.imul(e,b0)|0,w=w+Math.imul(e,l0)|0,w=w+Math.imul(r,b0)|0,p=p+Math.imul(r,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,_0),w=w+Math.imul(A0,g0)|0,p=Math.imul(A0,_0),y=y+Math.imul(I0,x0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(O0,x0)|0,p=p+Math.imul(O0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,p0)|0,w=w+Math.imul(X0,w0)|0,p=p+Math.imul(X0,p0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,p=p+Math.imul(G0,h0)|0,y=y+Math.imul($0,b0)|0,w=w+Math.imul($0,l0)|0,w=w+Math.imul(Q0,b0)|0,p=p+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,x0),w=Math.imul(F0,B0),w=w+Math.imul(A0,x0)|0,p=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,p0)|0,w=w+Math.imul(O0,w0)|0,p=p+Math.imul(O0,p0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,p=p+Math.imul(X0,h0)|0,y=y+Math.imul(Z0,b0)|0,w=w+Math.imul(Z0,l0)|0,w=w+Math.imul(G0,b0)|0,p=p+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,p0),w=w+Math.imul(A0,w0)|0,p=Math.imul(A0,p0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(O0,c0)|0,p=p+Math.imul(O0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,p=p+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(U$>>>26)|0,U$&=67108863,y=Math.imul(F0,c0),w=Math.imul(F0,h0),w=w+Math.imul(A0,c0)|0,p=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(O0,b0)|0,p=p+Math.imul(O0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(p+(w>>>13)|0)+(X$>>>26)|0,X$&=67108863,y=Math.imul(F0,b0),w=Math.imul(F0,l0),w=w+Math.imul(A0,b0)|0,p=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(p+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,x[0]=o0,x[1]=u0,x[2]=n0,x[3]=s0,x[4]=t0,x[5]=m0,x[6]=a0,x[7]=e0,x[8]=r0,x[9]=i0,x[10]=$$,x[11]=Q$,x[12]=Y$,x[13]=Z$,x[14]=G$,x[15]=V$,x[16]=U$,x[17]=X$,x[18]=K$,B!==0&&(x[19]=B,g.length++),g};Math.imul||(E=W);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var _=0,N=0,x=0;x>>26)|0,N+=B>>>26,B&=67108863}g.words[x]=y,_=B,B=N}return _!==0?g.words[x]=_:g.length--,g.strip()}function D(j,k,g){var _=new C;return _.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,_=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):_<63?g=W(this,j,k):_<1024?g=T(this,j,k):g=D(this,j,k),g};function C(j,k){this.x=j,this.y=k}C.prototype.makeRBT=function(j){for(var k=new Array(j),g=U.prototype._countBits(j)-1,_=0;_>=1;return _},C.prototype.permute=function(j,k,g,_,N,x){for(var B=0;B>>1)N++;return 1<>>13,g[2*x+1]=N&8191,N=N>>>13;for(x=2*k;x<_;++x)g[x]=0;G(N===0),G((N&-8192)===0)},C.prototype.stub=function(j){for(var k=new Array(j),g=0;g>=26,k+=_/67108864|0,k+=N>>>26,this.words[g]=N&67108863}return k!==0&&(this.words[g]=k,this.length++),this},U.prototype.muln=function(j){return this.clone().imuln(j)},U.prototype.sqr=function(){return this.mul(this)},U.prototype.isqr=function(){return this.imul(this.clone())},U.prototype.pow=function(j){var k=H(j);if(k.length===0)return new U(1);for(var g=this,_=0;_=0);var k=j%26,g=(j-k)/26,_=67108863>>>26-k<<26-k,N;if(k!==0){var x=0;for(N=0;N>>26-k}x&&(this.words[N]=x,this.length++)}if(g!==0){for(N=this.length-1;N>=0;N--)this.words[N+g]=this.words[N];for(N=0;N=0);var _;k?_=(k-k%26)/26:_=0;var N=j%26,x=Math.min((j-N)/26,this.length),B=67108863^67108863>>>N<x)for(this.length-=x,w=0;w=0&&(p!==0||w>=_);w--){var f=this.words[w]|0;this.words[w]=p<<26-N|f>>>N,p=f&B}return y&&p!==0&&(y.words[y.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},U.prototype.ishrn=function(j,k,g){return G(this.negative===0),this.iushrn(j,k,g)},U.prototype.shln=function(j){return this.clone().ishln(j)},U.prototype.ushln=function(j){return this.clone().iushln(j)},U.prototype.shrn=function(j){return this.clone().ishrn(j)},U.prototype.ushrn=function(j){return this.clone().iushrn(j)},U.prototype.testn=function(j){G(typeof j=="number"&&j>=0);var k=j%26,g=(j-k)/26,_=1<=0);var k=j%26,g=(j-k)/26;if(G(this.negative===0,"imaskn works only with positive numbers"),this.length<=g)return this;if(k!==0&&g++,this.length=Math.min(g,this.length),k!==0){var _=67108863^67108863>>>k<=67108864;k++)this.words[k]-=67108864,k===this.length-1?this.words[k+1]=1:this.words[k+1]++;return this.length=Math.max(this.length,k+1),this},U.prototype.isubn=function(j){if(G(typeof j=="number"),G(j<67108864),j<0)return this.iaddn(-j);if(this.negative!==0)return this.negative=0,this.iaddn(j),this.negative=1,this;if(this.words[0]-=j,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var k=0;k>26)-(y/67108864|0),this.words[N+g]=x&67108863}for(;N>26,this.words[N+g]=x&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,N=0;N>26,this.words[N]=x&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,_=this.clone(),N=j,x=N.words[N.length-1]|0,B=this._countBits(x);g=26-B,g!==0&&(N=N.ushln(g),_.iushln(g),x=N.words[N.length-1]|0);var y=_.length-N.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var p=0;p=0;c--){var h=(_.words[N.length+c]|0)*67108864+(_.words[N.length+c-1]|0);for(h=Math.min(h/x|0,67108863),_._ishlnsubmul(N,h,c);_.negative!==0;)h--,_.negative=0,_._ishlnsubmul(N,1,c),_.isZero()||(_.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),_.strip(),k!=="div"&&g!==0&&_.iushrn(g),{div:w||null,mod:_}},U.prototype.divmod=function(j,k,g){if(G(!j.isZero()),this.isZero())return{div:new U(0),mod:new U(0)};var _,N,x;return this.negative!==0&&j.negative===0?(x=this.neg().divmod(j,k),k!=="mod"&&(_=x.div.neg()),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.iadd(j)),{div:_,mod:N}):this.negative===0&&j.negative!==0?(x=this.divmod(j.neg(),k),k!=="mod"&&(_=x.div.neg()),{div:_,mod:x.mod}):(this.negative&j.negative)!==0?(x=this.neg().divmod(j.neg(),k),k!=="div"&&(N=x.mod.neg(),g&&N.negative!==0&&N.isub(j)),{div:x.div,mod:N}):j.length>this.length||this.cmp(j)<0?{div:new U(0),mod:this}:j.length===1?k==="div"?{div:this.divn(j.words[0]),mod:null}:k==="mod"?{div:null,mod:new U(this.modn(j.words[0]))}:{div:this.divn(j.words[0]),mod:new U(this.modn(j.words[0]))}:this._wordDiv(j,k)},U.prototype.div=function(j){return this.divmod(j,"div",!1).div},U.prototype.mod=function(j){return this.divmod(j,"mod",!1).mod},U.prototype.umod=function(j){return this.divmod(j,"mod",!0).mod},U.prototype.divRound=function(j){var k=this.divmod(j);if(k.mod.isZero())return k.div;var g=k.div.negative!==0?k.mod.isub(j):k.mod,_=j.ushrn(1),N=j.andln(1),x=g.cmp(_);return x<0||N===1&&x===0?k.div:k.div.negative!==0?k.div.isubn(1):k.div.iaddn(1)},U.prototype.modn=function(j){G(j<=67108863);for(var k=(1<<26)%j,g=0,_=this.length-1;_>=0;_--)g=(k*g+(this.words[_]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var _=(this.words[g]|0)+k*67108864;this.words[g]=_/j|0,k=_%j}return this.strip()},U.prototype.divn=function(j){return this.clone().idivn(j)},U.prototype.egcd=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=new U(0),B=new U(1),y=0;k.isEven()&&g.isEven();)k.iushrn(1),g.iushrn(1),++y;for(var w=g.clone(),p=k.clone();!k.isZero();){for(var f=0,c=1;(k.words[0]&c)===0&&f<26;++f,c<<=1);if(f>0)for(k.iushrn(f);f-- >0;)(_.isOdd()||N.isOdd())&&(_.iadd(w),N.isub(p)),_.iushrn(1),N.iushrn(1);for(var h=0,d=1;(g.words[0]&d)===0&&h<26;++h,d<<=1);if(h>0)for(g.iushrn(h);h-- >0;)(x.isOdd()||B.isOdd())&&(x.iadd(w),B.isub(p)),x.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(x),N.isub(B)):(g.isub(k),x.isub(_),B.isub(N))}return{a:x,b:B,gcd:g.iushln(y)}},U.prototype._invmp=function(j){G(j.negative===0),G(!j.isZero());var k=this,g=j.clone();k.negative!==0?k=k.umod(j):k=k.clone();for(var _=new U(1),N=new U(0),x=g.clone();k.cmpn(1)>0&&g.cmpn(1)>0;){for(var B=0,y=1;(k.words[0]&y)===0&&B<26;++B,y<<=1);if(B>0)for(k.iushrn(B);B-- >0;)_.isOdd()&&_.iadd(x),_.iushrn(1);for(var w=0,p=1;(g.words[0]&p)===0&&w<26;++w,p<<=1);if(w>0)for(g.iushrn(w);w-- >0;)N.isOdd()&&N.iadd(x),N.iushrn(1);k.cmp(g)>=0?(k.isub(g),_.isub(N)):(g.isub(k),N.isub(_))}var f;return k.cmpn(1)===0?f=_:f=N,f.cmpn(0)<0&&f.iadd(j),f},U.prototype.gcd=function(j){if(this.isZero())return j.abs();if(j.isZero())return this.abs();var k=this.clone(),g=j.clone();k.negative=0,g.negative=0;for(var _=0;k.isEven()&&g.isEven();_++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var N=k.cmp(g);if(N<0){var x=k;k=g,g=x}else if(N===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(_)},U.prototype.invm=function(j){return this.egcd(j).a.umod(j)},U.prototype.isEven=function(){return(this.words[0]&1)===0},U.prototype.isOdd=function(){return(this.words[0]&1)===1},U.prototype.andln=function(j){return this.words[0]&j},U.prototype.bincn=function(j){G(typeof j=="number");var k=j%26,g=(j-k)/26,_=1<>>26,B&=67108863,this.words[x]=B}return N!==0&&(this.words[x]=N,this.length++),this},U.prototype.isZero=function(){return this.length===1&&this.words[0]===0},U.prototype.cmpn=function(j){var k=j<0;if(this.negative!==0&&!k)return-1;if(this.negative===0&&k)return 1;this.strip();var g;if(this.length>1)g=1;else{k&&(j=-j),G(j<=67108863,"Number is too big");var _=this.words[0]|0;g=_===j?0:_j.length)return 1;if(this.length=0;g--){var _=this.words[g]|0,N=j.words[g]|0;if(_!==N){_N&&(k=1);break}}return k},U.prototype.gtn=function(j){return this.cmpn(j)===1},U.prototype.gt=function(j){return this.cmp(j)===1},U.prototype.gten=function(j){return this.cmpn(j)>=0},U.prototype.gte=function(j){return this.cmp(j)>=0},U.prototype.ltn=function(j){return this.cmpn(j)===-1},U.prototype.lt=function(j){return this.cmp(j)===-1},U.prototype.lten=function(j){return this.cmpn(j)<=0},U.prototype.lte=function(j){return this.cmp(j)<=0},U.prototype.eqn=function(j){return this.cmpn(j)===0},U.prototype.eq=function(j){return this.cmp(j)===0},U.red=function(j){return new v(j)},U.prototype.toRed=function(j){return G(!this.red,"Already a number in reduction context"),G(this.negative===0,"red works only with positives"),j.convertTo(this)._forceRed(j)},U.prototype.fromRed=function(){return G(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},U.prototype._forceRed=function(j){return this.red=j,this},U.prototype.forceRed=function(j){return G(!this.red,"Already a number in reduction context"),this._forceRed(j)},U.prototype.redAdd=function(j){return G(this.red,"redAdd works only with red numbers"),this.red.add(this,j)},U.prototype.redIAdd=function(j){return G(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,j)},U.prototype.redSub=function(j){return G(this.red,"redSub works only with red numbers"),this.red.sub(this,j)},U.prototype.redISub=function(j){return G(this.red,"redISub works only with red numbers"),this.red.isub(this,j)},U.prototype.redShl=function(j){return G(this.red,"redShl works only with red numbers"),this.red.shl(this,j)},U.prototype.redMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.mul(this,j)},U.prototype.redIMul=function(j){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,j),this.red.imul(this,j)},U.prototype.redSqr=function(){return G(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},U.prototype.redISqr=function(){return G(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},U.prototype.redSqrt=function(){return G(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},U.prototype.redInvm=function(){return G(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},U.prototype.redNeg=function(){return G(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},U.prototype.redPow=function(j){return G(this.red&&!j.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,j)};var L={k256:null,p224:null,p192:null,p25519:null};function R(j,k){this.name=j,this.p=new U(k,16),this.n=this.p.bitLength(),this.k=new U(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}R.prototype._tmp=function(){var j=new U(null);return j.words=new Array(Math.ceil(this.n/13)),j},R.prototype.ireduce=function(j){var k=j,g;do this.split(k,this.tmp),k=this.imulK(k),k=k.iadd(this.tmp),g=k.bitLength();while(g>this.n);var _=g0?k.isub(this.p):k.strip!==void 0?k.strip():k._strip(),k},R.prototype.split=function(j,k){j.iushrn(this.n,0,k)},R.prototype.imulK=function(j){return j.imul(this.k)};function P(){R.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}V(P,R),P.prototype.split=function(j,k){for(var g=4194303,_=Math.min(j.length,9),N=0;N<_;N++)k.words[N]=j.words[N];if(k.length=_,j.length<=9){j.words[0]=0,j.length=1;return}var x=j.words[9];for(k.words[k.length++]=x&g,N=10;N>>22,x=B}x>>>=22,j.words[N-10]=x,x===0&&j.length>10?j.length-=10:j.length-=9},P.prototype.imulK=function(j){j.words[j.length]=0,j.words[j.length+1]=0,j.length+=2;for(var k=0,g=0;g>>=26,j.words[g]=N,k=_}return k!==0&&(j.words[j.length++]=k),j},U._prime=function(j){if(L[j])return L[j];var k;if(j==="k256")k=new P;else if(j==="p224")k=new z;else if(j==="p192")k=new M;else if(j==="p25519")k=new S;else throw new Error("Unknown prime "+j);return L[j]=k,k};function v(j){if(typeof j=="string"){var k=U._prime(j);this.m=k.p,this.prime=k}else G(j.gtn(1),"modulus must be greater than 1"),this.m=j,this.prime=null}v.prototype._verify1=function(j){G(j.negative===0,"red works only with positives"),G(j.red,"red works only with red numbers")},v.prototype._verify2=function(j,k){G((j.negative|k.negative)===0,"red works only with positives"),G(j.red&&j.red===k.red,"red works only with red numbers")},v.prototype.imod=function(j){return this.prime?this.prime.ireduce(j)._forceRed(this):j.umod(this.m)._forceRed(this)},v.prototype.neg=function(j){return j.isZero()?j.clone():this.m.sub(j)._forceRed(this)},v.prototype.add=function(j,k){this._verify2(j,k);var g=j.add(k);return g.cmp(this.m)>=0&&g.isub(this.m),g._forceRed(this)},v.prototype.iadd=function(j,k){this._verify2(j,k);var g=j.iadd(k);return g.cmp(this.m)>=0&&g.isub(this.m),g},v.prototype.sub=function(j,k){this._verify2(j,k);var g=j.sub(k);return g.cmpn(0)<0&&g.iadd(this.m),g._forceRed(this)},v.prototype.isub=function(j,k){this._verify2(j,k);var g=j.isub(k);return g.cmpn(0)<0&&g.iadd(this.m),g},v.prototype.shl=function(j,k){return this._verify1(j),this.imod(j.ushln(k))},v.prototype.imul=function(j,k){return this._verify2(j,k),this.imod(j.imul(k))},v.prototype.mul=function(j,k){return this._verify2(j,k),this.imod(j.mul(k))},v.prototype.isqr=function(j){return this.imul(j,j.clone())},v.prototype.sqr=function(j){return this.mul(j,j)},v.prototype.sqrt=function(j){if(j.isZero())return j.clone();var k=this.m.andln(3);if(G(k%2===1),k===3){var g=this.m.add(new U(1)).iushrn(2);return this.pow(j,g)}for(var _=this.m.subn(1),N=0;!_.isZero()&&_.andln(1)===0;)N++,_.iushrn(1);G(!_.isZero());var x=new U(1).toRed(this),B=x.redNeg(),y=this.m.subn(1).iushrn(1),w=this.m.bitLength();for(w=new U(2*w*w).toRed(this);this.pow(w,y).cmp(B)!==0;)w.redIAdd(B);for(var p=this.pow(w,_),f=this.pow(j,_.addn(1).iushrn(1)),c=this.pow(j,_),h=N;c.cmp(x)!==0;){for(var d=c,b=0;d.cmp(x)!==0;b++)d=d.redSqr();G(b=0;N--){for(var p=k.words[N],f=w-1;f>=0;f--){var c=p>>f&1;if(x!==_[0]&&(x=this.sqr(x)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(N!==0||f!==0))&&(x=this.mul(x,_[B]),y=0,B=0)}w=26}return x},v.prototype.convertTo=function(j){var k=j.umod(this.m);return k===j?k.clone():k},v.prototype.convertFrom=function(j){var k=j.clone();return k.red=null,k},U.mont=function(j){return new q(j)};function q(j){v.call(this,j),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new U(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}V(q,v),q.prototype.convertTo=function(j){return this.imod(j.ushln(this.shift))},q.prototype.convertFrom=function(j){var k=this.imod(j.mul(this.rinv));return k.red=null,k},q.prototype.imul=function(j,k){if(j.isZero()||k.isZero())return j.words[0]=0,j.length=1,j;var g=j.imul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=g.isub(_).iushrn(this.shift),x=N;return N.cmp(this.m)>=0?x=N.isub(this.m):N.cmpn(0)<0&&(x=N.iadd(this.m)),x._forceRed(this)},q.prototype.invm=function(j){var k=this.imod(j._invmp(this.m).mul(this.r2));return k._forceRed(this)}})(typeof Q>"u"||Q,$)}}),{CryptoHasher:sY}=globalThis.Bun,tY=q$({"node_modules/public-encrypt/withPublic.js"($,Q){var Y=nY(),Z=k$().Buffer;function G(V,U){return Z.from(V.toRed(Y.mont(U.modulus)).redPow(new Y(U.publicExponent)).fromRed().toArray())}Q.exports=G}}),mY=q$({"node_modules/public-encrypt/publicEncrypt.js"($,Q){var Y=pY(),Z=g$(),G=o$(),V=oY(),U=uY(),X=nY(),K=tY(),I=hQ(),O=k$().Buffer;Q.exports=function(H,W,E){var T;H.padding?T=H.padding:E?T=1:T=4;var D=Y(H),C;if(T===4)C=J(D,W);else if(T===1)C=F(D,W,E);else if(T===3){if(C=new X(W),C.cmp(D.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return E?I(C,D):K(C,D)};function J(H,W){var E=H.modulus.byteLength(),T=W.length,D=G("sha1").update(O.alloc(0)).digest(),C=D.length,L=2*C;if(T>E-L-2)throw new Error("message too long");var R=O.alloc(E-T-L-2),P=E-C-1,z=Z(C),M=U(O.concat([D,R,O.alloc(1,1),W],P),V(z,P)),S=U(z,V(M,C));return new X(O.concat([O.alloc(1),S,M],E))}function F(H,W,E){var T=W.length,D=H.modulus.byteLength();if(T>D-11)throw new Error("message too long");var C;return E?C=O.alloc(D-T-3,255):C=A(D-T-3),new X(O.concat([O.from([0,E?1:2]),C,O.alloc(1),W],D))}function A(H){for(var W=O.allocUnsafe(H),E=0,T=Z(H*2),D=0,C;ED||new V(H).cmp(T.modulus)>=0)throw new Error("decryption error");var C;W?C=K(new V(H),T):C=U(H,T);var L=I.alloc(D-C.length);if(C=I.concat([L,C],D),E===4)return O(T,C);if(E===1)return J(T,C,W);if(E===3)return C;throw new Error("unknown padding")};function O(A,H){var W=A.modulus.byteLength(),E=X("sha1").update(I.alloc(0)).digest(),T=E.length;if(H[0]!==0)throw new Error("decryption error");var D=H.slice(1,T+1),C=H.slice(T+1),L=G(D,Z(C,T)),R=G(C,Z(L,W-T-1));if(F(E,R.slice(0,T)))throw new Error("decryption error");for(var P=T;R[P]===0;)P++;if(R[P++]!==1)throw new Error("decryption error");return R.slice(P)}function J(A,H,W){for(var E=H.slice(0,2),T=2,D=0;H[T++]!==0;)if(T>=H.length){D++;break}var C=H.slice(2,T-1);if((E.toString("hex")!=="0002"&&!W||E.toString("hex")!=="0001"&&W)&&D++,C.length<8&&D++,D)throw new Error("decryption error");return H.slice(T)}function F(A,H){A=I.from(A),H=I.from(H);var W=0,E=A.length;A.length!==H.length&&(W++,E=Math.min(A.length,H.length));for(var T=-1;++TV||J<0)throw new TypeError("offset must be a uint32");if(J>G||J>F)throw new RangeError("offset out of range")}function X(J,F,A){if(typeof J!="number"||J!==J)throw new TypeError("size must be a number");if(J>V||J<0)throw new TypeError("size must be a uint32");if(J+F>A||J>G)throw new RangeError("buffer too small")}$.randomFill=K,$.randomFillSync=O;function K(J,F,A,H){if(!Z.isBuffer(J)&&!(J instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof F=="function")H=F,F=0,A=J.length;else if(typeof A=="function")H=A,A=J.length-F;else if(typeof H!="function")throw new TypeError('"cb" argument must be a function');return U(F,J.length),X(A,F,J.length),I(J,F,A,H)}function I(J,F,A,H){if(H){Y(A,function(E,T){if(E)return H(E);T.copy(J,F),H(null,J)});return}var W=Y(A);return W.copy(J,F),J}function O(J,F,A){if(typeof F>"u"&&(F=0),!Z.isBuffer(J)&&!(J instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return U(F,J.length),A===void 0&&(A=J.length-F),X(A,F,J.length),I(J,F,A)}}}),iY=q$({"node_modules/crypto-browserify/index.js"($){$.randomBytes=$.rng=$.pseudoRandomBytes=$.prng=g$(),$.createHash=o$(),$.Hash=$.createHash.Hash,$.createHmac=$.Hmac=s$();var Q=m$(),Y=Object.keys(Q),Z=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Y);$.getHashes=function(){return Z};var G=QQ();$.pbkdf2=G.pbkdf2,$.pbkdf2Sync=G.pbkdf2Sync;var V=kQ();$.Cipher=V.Cipher,$.createCipher=V.createCipher,$.Cipheriv=V.Cipheriv,$.createCipheriv=V.createCipheriv,$.Decipher=V.Decipher,$.createDecipher=V.createDecipher,$.Decipheriv=V.Decipheriv,$.createDecipheriv=V.createDecipheriv,$.getCiphers=V.getCiphers,$.listCiphers=V.listCiphers;var U=fQ();$.DiffieHellmanGroup=U.DiffieHellmanGroup,$.createDiffieHellmanGroup=U.createDiffieHellmanGroup,$.getDiffieHellman=U.getDiffieHellman,$.createDiffieHellman=U.createDiffieHellman,$.DiffieHellman=U.DiffieHellman;var X=dY();$.createSign=X.createSign,$.Sign=X.Sign,$.createVerify=X.createVerify,$.Verify=X.Verify,$.createECDH=lY();var K=eY();$.publicEncrypt=K.publicEncrypt,$.privateEncrypt=K.privateEncrypt,$.publicDecrypt=K.publicDecrypt,$.privateDecrypt=K.privateDecrypt,$.getRandomValues=(O)=>H$.getRandomValues(O);var I=rY();$.randomFill=I.randomFill,$.randomFillSync=I.randomFillSync,$.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(` +`))},$.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}}}),$Z={...iY(),[Symbol.for("CommonJS")]:0},T$="buffer",QZ=($)=>H$.getRandomValues($),YZ=()=>H$.randomUUID(),D$="timingSafeEqual"in H$?($,Q)=>{let{byteLength:Y}=$,{byteLength:Z}=Q;if(typeof Y!="number"||typeof Z!="number")throw new TypeError("Input must be an array buffer view");if(Y!==Z)throw new RangeError("Input buffers must have the same length");return H$.timingSafeEqual($,Q)}:void 0,ZZ="scryptSync"in H$?($,Q,Y,Z)=>{let G=H$.scryptSync($,Q,Y,Z);return T$!=="buffer"?new F$(G).toString(T$):new F$(G)}:void 0,GZ="scryptSync"in H$?function($,Q,Y,Z,G){if(typeof Z=="function"&&(G=Z,Z=void 0),typeof G!="function"){var V=new TypeError("callback must be a function");throw V.code="ERR_INVALID_CALLBACK",V}try{let U=H$.scryptSync($,Q,Y,Z);process.nextTick(G,null,T$!=="buffer"?new F$(U).toString(T$):new F$(U))}catch(U){throw U}}:void 0;D$&&(Object.defineProperty(D$,"name",{value:"::bunternal::"}),Object.defineProperty(GZ,"name",{value:"::bunternal::"}),Object.defineProperty(ZZ,"name",{value:"::bunternal::"}));var C$=H$;j$($Z,{DEFAULT_ENCODING:()=>T$,getRandomValues:()=>QZ,randomUUID:()=>YZ,scrypt:()=>GZ,scryptSync:()=>ZZ,timingSafeEqual:()=>D$,webcrypto:()=>C$,subtle:()=>C$.subtle});var{randomBytes:VZ,rng:UZ,pseudoRandomBytes:XZ,prng:KZ,Hash:IZ,createHash:OZ,createHmac:JZ,Hmac:FZ,getHashes:AZ,pbkdf2:HZ,pbkdf2Sync:WZ,Cipher:EZ,createCipher:TZ,Cipheriv:DZ,createCipheriv:CZ,Decipher:LZ,createDecipher:RZ,Decipheriv:PZ,createDecipheriv:zZ,getCiphers:MZ,listCiphers:SZ,DiffieHellmanGroup:vZ,createDiffieHellmanGroup:qZ,getDiffieHellman:jZ,createDiffieHellman:kZ,DiffieHellman:gZ,createSign:_Z,Sign:NZ,createVerify:xZ,Verify:BZ,createECDH:yZ,publicEncrypt:wZ,privateEncrypt:pZ,publicDecrypt:fZ,privateDecrypt:cZ,randomFill:hZ,randomFillSync:dZ,createCredentials:bZ,constants:lZ}=$Z;var uZ=$Z;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{C$ as webcrypto,D$ as timingSafeEqual,ZZ as scryptSync,GZ as scrypt,UZ as rng,YZ as randomUUID,dZ as randomFillSync,hZ as randomFill,VZ as randomBytes,wZ as publicEncrypt,fZ as publicDecrypt,XZ as pseudoRandomBytes,KZ as prng,pZ as privateEncrypt,cZ as privateDecrypt,WZ as pbkdf2Sync,HZ as pbkdf2,SZ as listCiphers,QZ as getRandomValues,AZ as getHashes,jZ as getDiffieHellman,MZ as getCiphers,uZ as default,xZ as createVerify,_Z as createSign,JZ as createHmac,OZ as createHash,yZ as createECDH,qZ as createDiffieHellmanGroup,kZ as createDiffieHellman,zZ as createDecipheriv,RZ as createDecipher,bZ as createCredentials,CZ as createCipheriv,TZ as createCipher,lZ as constants,BZ as Verify,NZ as Sign,FZ as Hmac,IZ as Hash,vZ as DiffieHellmanGroup,gZ as DiffieHellman,PZ as Decipheriv,LZ as Decipher,T$ as DEFAULT_ENCODING,DZ as Cipheriv,EZ as Cipher}; diff --git a/src/js/out/modules/node/dns.promises.js b/src/js/out/modules/node/dns.promises.js index f239935d5..cbb58c4b7 100644 --- a/src/js/out/modules/node/dns.promises.js +++ b/src/js/out/modules/node/dns.promises.js @@ -1,4 +1,5 @@ -var { promises } = import.meta.require("node:dns"), { +import {promises} from "node:dns"; +var { lookup, lookupService, resolve, diff --git a/src/js/out/modules/node/events.js b/src/js/out/modules/node/events.js index 5991aba52..cd087f5d1 100644 --- a/src/js/out/modules/node/events.js +++ b/src/js/out/modules/node/events.js @@ -123,7 +123,7 @@ var EventEmitter = function(opts) { }, checkListener = function(listener) { if (typeof listener !== "function") throw new TypeError("The listener must be a function"); -}, { isPromise, Array, Object: Object2 } = import.meta.primordials, SymbolFor = Symbol.for, ObjectDefineProperty = Object2.defineProperty, kCapture = Symbol("kCapture"), kErrorMonitor = SymbolFor("events.errorMonitor"), kMaxEventTargetListeners = Symbol("events.maxEventTargetListeners"), kMaxEventTargetListenersWarned = Symbol("events.maxEventTargetListenersWarned"), kWatermarkData = SymbolFor("nodejs.watermarkData"), kRejection = SymbolFor("nodejs.rejection"), captureRejectionSymbol = SymbolFor("nodejs.rejection"), ArrayPrototypeSlice = Array.prototype.slice, defaultMaxListeners = 10, EventEmitterPrototype = EventEmitter.prototype; +}, { isPromise, Array, Object: Object2 } = globalThis[Symbol.for("Bun.lazy")]("primordials"), SymbolFor = Symbol.for, ObjectDefineProperty = Object2.defineProperty, kCapture = Symbol("kCapture"), kErrorMonitor = SymbolFor("events.errorMonitor"), kMaxEventTargetListeners = Symbol("events.maxEventTargetListeners"), kMaxEventTargetListenersWarned = Symbol("events.maxEventTargetListenersWarned"), kWatermarkData = SymbolFor("nodejs.watermarkData"), kRejection = SymbolFor("nodejs.rejection"), captureRejectionSymbol = SymbolFor("nodejs.rejection"), ArrayPrototypeSlice = Array.prototype.slice, defaultMaxListeners = 10, EventEmitterPrototype = EventEmitter.prototype; EventEmitterPrototype._events = void 0; EventEmitterPrototype._eventsCount = 0; EventEmitterPrototype._maxListeners = void 0; @@ -318,7 +318,6 @@ Object2.defineProperties(EventEmitter, { }); EventEmitter.init = EventEmitter; EventEmitter[Symbol.for("CommonJS")] = 0; -var events_default = EventEmitter; class AbortError extends Error { constructor(message = "The operation was aborted", options = void 0) { @@ -334,8 +333,17 @@ class EventEmitterAsyncResource extends EventEmitter { throwNotImplemented("EventEmitterAsyncResource", 1832); } } -EventEmitter.EventEmitterAsyncResource = EventEmitterAsyncResource; +var usingDomains = !1; +Object2.assign(EventEmitter, { once, on, getEventListeners, setMaxListeners, listenerCount, EventEmitterAsyncResource }); +var events_default = EventEmitter; export { + usingDomains, + setMaxListeners, + once, + on, + listenerCount, + getEventListeners, events_default as default, - EventEmitterAsyncResource + captureRejectionSymbol, + EventEmitter }; diff --git a/src/js/out/modules/node/fs.js b/src/js/out/modules/node/fs.js index cc3763cfc..6c8269d59 100644 --- a/src/js/out/modules/node/fs.js +++ b/src/js/out/modules/node/fs.js @@ -1,4 +1,7 @@ -var {EventEmitter } = import.meta.require("node:stream"); +import {EventEmitter} from "node:events"; +import {default as default2} from "node:fs/promises"; +import promises2 from "node:fs/promises"; +import * as Stream from "node:stream"; var callbackify = function(fsFunction, args) { try { const result = fsFunction.apply(fs, args.slice(0, args.length - 1)), callback = args[args.length - 1]; @@ -16,7 +19,8 @@ function createReadStream(path, options) { function createWriteStream(path, options) { return new WriteStream(path, options); } -var { direct, isPromise, isCallable } = import.meta.primordials, promises = import.meta.require("node:fs/promises"), { Readable, NativeWritable, _getNativeReadableStreamPrototype, eos: eos_ } = import.meta.require("node:stream"), NativeReadable = _getNativeReadableStreamPrototype(2, Readable), fs = Bun.fs(), debug = process.env.DEBUG ? console.log : () => { +import {constants} from "node:fs/promises"; +var ReadStream, WriteStream, { direct, isPromise, isCallable } = globalThis[Symbol.for("Bun.lazy")]("primordials"), fs = Bun.fs(), debug = process.env.DEBUG ? console.log : () => { }; class FSWatcher extends EventEmitter { @@ -131,7 +135,7 @@ var access = function access2(...args) { callbackify(fs.lutimesSync, args); }, accessSync = fs.accessSync.bind(fs), appendFileSync = fs.appendFileSync.bind(fs), closeSync = fs.closeSync.bind(fs), copyFileSync = fs.copyFileSync.bind(fs), existsSync = fs.existsSync.bind(fs), chownSync = fs.chownSync.bind(fs), chmodSync = fs.chmodSync.bind(fs), fchmodSync = fs.fchmodSync.bind(fs), fchownSync = fs.fchownSync.bind(fs), fstatSync = fs.fstatSync.bind(fs), fsyncSync = fs.fsyncSync.bind(fs), ftruncateSync = fs.ftruncateSync.bind(fs), futimesSync = fs.futimesSync.bind(fs), lchmodSync = fs.lchmodSync.bind(fs), lchownSync = fs.lchownSync.bind(fs), linkSync = fs.linkSync.bind(fs), lstatSync = fs.lstatSync.bind(fs), mkdirSync = fs.mkdirSync.bind(fs), mkdtempSync = fs.mkdtempSync.bind(fs), openSync = fs.openSync.bind(fs), readSync = fs.readSync.bind(fs), writeSync = fs.writeSync.bind(fs), readdirSync = fs.readdirSync.bind(fs), readFileSync = fs.readFileSync.bind(fs), writeFileSync = fs.writeFileSync.bind(fs), readlinkSync = fs.readlinkSync.bind(fs), realpathSync = fs.realpathSync.bind(fs), renameSync = fs.renameSync.bind(fs), statSync = fs.statSync.bind(fs), symlinkSync = fs.symlinkSync.bind(fs), truncateSync = fs.truncateSync.bind(fs), unlinkSync = fs.unlinkSync.bind(fs), utimesSync = fs.utimesSync.bind(fs), lutimesSync = fs.lutimesSync.bind(fs), rmSync = fs.rmSync.bind(fs), rmdirSync = fs.rmdirSync.bind(fs), Dirent = fs.Dirent, Stats = fs.Stats, watch = function watch2(path, options, listener) { return new FSWatcher(path, options, listener); -}, promises = import.meta.require("node:fs/promises"), readStreamPathFastPathSymbol = Symbol.for("Bun.Node.readStreamPathFastPath"), readStreamSymbol = Symbol.for("Bun.NodeReadStream"), readStreamPathOrFdSymbol = Symbol.for("Bun.NodeReadStreamPathOrFd"), writeStreamSymbol = Symbol.for("Bun.NodeWriteStream"), writeStreamPathFastPathSymbol = Symbol.for("Bun.NodeWriteStreamFastPath"), writeStreamPathFastPathCallSymbol = Symbol.for("Bun.NodeWriteStreamFastPathCall"), kIoDone = Symbol.for("kIoDone"), defaultReadStreamOptions = { +}, readStreamPathFastPathSymbol = Symbol.for("Bun.Node.readStreamPathFastPath"), readStreamSymbol = Symbol.for("Bun.NodeReadStream"), readStreamPathOrFdSymbol = Symbol.for("Bun.NodeReadStreamPathOrFd"), writeStreamSymbol = Symbol.for("Bun.NodeWriteStream"), writeStreamPathFastPathSymbol = Symbol.for("Bun.NodeWriteStreamFastPath"), writeStreamPathFastPathCallSymbol = Symbol.for("Bun.NodeWriteStreamFastPathCall"), kIoDone = Symbol.for("kIoDone"), defaultReadStreamOptions = { file: void 0, fd: void 0, flags: "r", @@ -158,7 +162,8 @@ var access = function access2(...args) { close }, autoDestroy: !0 -}, ReadStreamClass, ReadStream = function(InternalReadStream) { +}, ReadStreamClass; +ReadStream = function(InternalReadStream) { return ReadStreamClass = InternalReadStream, Object.defineProperty(ReadStreamClass.prototype, Symbol.toStringTag, { value: "ReadStream", enumerable: !1 @@ -169,7 +174,7 @@ var access = function access2(...args) { return instance instanceof InternalReadStream; } }); -}(class ReadStream2 extends NativeReadable { +}(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2, Stream.Readable) { constructor(pathOrFd, options = defaultReadStreamOptions) { if (typeof options !== "object" || !options) throw new TypeError("Expected options to be an object"); @@ -342,7 +347,8 @@ var access = function access2(...args) { } return this[readStreamPathFastPathSymbol] = !1, super.pipe(dest, pipeOpts); } -}), defaultWriteStreamOptions = { +}); +var defaultWriteStreamOptions = { fd: null, start: void 0, pos: void 0, @@ -355,7 +361,8 @@ var access = function access2(...args) { open, openSync } -}, WriteStreamClass, WriteStream = function(InternalWriteStream) { +}, WriteStreamClass; +WriteStream = function(InternalWriteStream) { return WriteStreamClass = InternalWriteStream, Object.defineProperty(WriteStreamClass.prototype, Symbol.toStringTag, { value: "WritesStream", enumerable: !1 @@ -366,7 +373,7 @@ var access = function access2(...args) { return instance instanceof InternalWriteStream; } }); -}(class WriteStream2 extends NativeWritable { +}(class WriteStream2 extends Stream.NativeWritable { constructor(path, options = defaultWriteStreamOptions) { if (!options) throw new TypeError("Expected options to be an object"); @@ -563,7 +570,7 @@ var fs_default = { chownSync, close, closeSync, - constants: promises.constants, + constants: promises2.constants, copyFile, copyFileSync, createReadStream, @@ -599,7 +606,7 @@ var fs_default = { mkdtempSync, open, openSync, - promises, + promises: promises2, read, readFile, readFileSync, @@ -672,7 +679,7 @@ export { readFileSync, readFile, read, - promises, + default2 as promises, openSync, open, mkdtempSync, @@ -708,6 +715,7 @@ export { createReadStream, copyFileSync, copyFile, + constants, closeSync, close, chownSync, diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index 02e000138..e5f96de48 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -1,4 +1,9 @@ -var isValidTLSArray = function(obj) { +import {EventEmitter} from "node:events"; +import {Readable, Writable, Duplex} from "node:stream"; +import {isTypedArray} from "node:util/types"; +var isIPv6 = function(input) { + return new RegExp("^((?:(?:[0-9a-fA-F]{1,4}):){7}(?:(?:[0-9a-fA-F]{1,4})|:)|(?:(?:[0-9a-fA-F]{1,4}):){6}(?:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|:(?:[0-9a-fA-F]{1,4})|:)|(?:(?:[0-9a-fA-F]{1,4}):){5}(?::((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,2}|:)|(?:(?:[0-9a-fA-F]{1,4}):){4}(?:(:(?:[0-9a-fA-F]{1,4})){0,1}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,3}|:)|(?:(?:[0-9a-fA-F]{1,4}):){3}(?:(:(?:[0-9a-fA-F]{1,4})){0,2}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,4}|:)|(?:(?:[0-9a-fA-F]{1,4}):){2}(?:(:(?:[0-9a-fA-F]{1,4})){0,3}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,5}|:)|(?:(?:[0-9a-fA-F]{1,4}):){1}(?:(:(?:[0-9a-fA-F]{1,4})){0,4}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,6}|:)|(?::((?::(?:[0-9a-fA-F]{1,4})){0,5}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(?::(?:[0-9a-fA-F]{1,4})){1,7}|:)))(%[0-9a-zA-Z-.:]{1,})?$").test(input); +}, isValidTLSArray = function(obj) { if (typeof obj === "string" || isTypedArray(obj) || obj instanceof ArrayBuffer || obj instanceof Blob) return !0; if (Array.isArray(obj)) { @@ -92,9 +97,8 @@ function get(url, options, cb) { const req = request(url, options, cb); return req.end(), req; } -var { EventEmitter } = import.meta.require("node:events"), { isIPv6 } = import.meta.require("node:net"), { Readable, Writable, Duplex } = import.meta.require("node:stream"), { URL } = import.meta.require("node:url"), { newArrayWithSize, String, Object, Array } = import.meta.primordials, { isTypedArray } = import.meta.require("util/types"), globalReportError = globalThis.reportError, setTimeout = globalThis.setTimeout, fetch = Bun.fetch, nop = () => { -}, __DEBUG__ = process.env.__DEBUG__, debug = __DEBUG__ ? (...args) => console.log("node:http", ...args) : nop, kEmptyObject = Object.freeze(Object.create(null)), kOutHeaders = Symbol.for("kOutHeaders"), kEndCalled = Symbol.for("kEndCalled"), kAbortController = Symbol.for("kAbortController"), kClearTimeout = Symbol("kClearTimeout"), kCorked = Symbol.for("kCorked"), searchParamsSymbol = Symbol.for("query"), StringPrototypeSlice = String.prototype.slice, StringPrototypeStartsWith = String.prototype.startsWith, StringPrototypeToUpperCase = String.prototype.toUpperCase, StringPrototypeIncludes = String.prototype.includes, StringPrototypeCharCodeAt = String.prototype.charCodeAt, StringPrototypeIndexOf = String.prototype.indexOf, ArrayIsArray = Array.isArray, RegExpPrototypeExec = RegExp.prototype.exec, ObjectAssign = Object.assign, ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty, INVALID_PATH_REGEX = /[^\u0021-\u00ff]/; -var _globalAgent, _defaultHTTPSAgent, kInternalRequest = Symbol("kInternalRequest"), kInternalSocketData = Symbol.for("::bunternal::"), kEmptyBuffer = Buffer.alloc(0), FakeSocket = class Socket extends Duplex { +var { URL } = globalThis, { newArrayWithSize, String, Object, Array } = globalThis[Symbol.for("Bun.lazy")]("primordials"), globalReportError = globalThis.reportError, setTimeout = globalThis.setTimeout, fetch = Bun.fetch, nop = () => { +}, __DEBUG__ = process.env.__DEBUG__, debug = __DEBUG__ ? (...args) => console.log("node:http", ...args) : nop, kEmptyObject = Object.freeze(Object.create(null)), kOutHeaders = Symbol.for("kOutHeaders"), kEndCalled = Symbol.for("kEndCalled"), kAbortController = Symbol.for("kAbortController"), kClearTimeout = Symbol("kClearTimeout"), kCorked = Symbol.for("kCorked"), searchParamsSymbol = Symbol.for("query"), StringPrototypeSlice = String.prototype.slice, StringPrototypeStartsWith = String.prototype.startsWith, StringPrototypeToUpperCase = String.prototype.toUpperCase, StringPrototypeIncludes = String.prototype.includes, StringPrototypeCharCodeAt = String.prototype.charCodeAt, StringPrototypeIndexOf = String.prototype.indexOf, ArrayIsArray = Array.isArray, RegExpPrototypeExec = RegExp.prototype.exec, ObjectAssign = Object.assign, ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty, INVALID_PATH_REGEX = /[^\u0021-\u00ff]/, NODE_HTTP_WARNING = "WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.", _globalAgent, _defaultHTTPSAgent, kInternalRequest = Symbol("kInternalRequest"), kInternalSocketData = Symbol.for("::bunternal::"), kEmptyBuffer = Buffer.alloc(0), FakeSocket = class Socket extends Duplex { bytesRead = 0; bytesWritten = 0; connecting = !1; @@ -230,7 +234,7 @@ class Agent extends EventEmitter { return this.#totalSocketCount; } createConnection() { - return debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "WARN: Agent.createConnection is a no-op, returns fake socket"), this.#fakeSocket ??= new FakeSocket; + return debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.createConnection is a no-op, returns fake socket"), this.#fakeSocket ??= new FakeSocket; } getName(options = kEmptyObject) { let name = `http:${options.host || "localhost"}:`; @@ -245,22 +249,22 @@ class Agent extends EventEmitter { return name; } addRequest() { - debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "WARN: Agent.addRequest is a no-op"); + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.addRequest is a no-op"); } createSocket(req, options, cb) { - debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "WARN: Agent.createSocket returns fake socket"), cb(null, this.#fakeSocket ??= new FakeSocket); + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.createSocket returns fake socket"), cb(null, this.#fakeSocket ??= new FakeSocket); } removeSocket() { - debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "WARN: Agent.removeSocket is a no-op"); + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.removeSocket is a no-op"); } keepSocketAlive() { - return debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "WARN: Agent.keepSocketAlive is a no-op"), !0; + return debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.keepSocketAlive is a no-op"), !0; } reuseSocket() { - debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "WARN: Agent.reuseSocket is a no-op"); + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.reuseSocket is a no-op"); } destroy() { - debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "WARN: Agent.destroy is a no-op"); + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.destroy is a no-op"); } } @@ -968,10 +972,10 @@ class ClientRequest extends OutgoingMessage { this.setTimeout(timeout); } setSocketKeepAlive(enable = !0, initialDelay = 0) { - __DEBUG__ && debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "WARN: ClientRequest.setSocketKeepAlive is a no-op"); + __DEBUG__ && debug(`${NODE_HTTP_WARNING}\n`, "WARN: ClientRequest.setSocketKeepAlive is a no-op"); } setNoDelay(noDelay = !0) { - __DEBUG__ && debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "WARN: ClientRequest.setNoDelay is a no-op"); + __DEBUG__ && debug(`${NODE_HTTP_WARNING}\n`, "WARN: ClientRequest.setNoDelay is a no-op"); } [kClearTimeout]() { if (this.#timeoutTimer) @@ -1086,7 +1090,9 @@ var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, METHODS = [ 509: "Bandwidth Limit Exceeded", 510: "Not Extended", 511: "Network Authentication Required" -}, defaultObject = { +}; +_globalAgent ??= new Agent; +var defaultObject = { Agent, Server, METHODS, @@ -1098,10 +1104,10 @@ var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, METHODS = [ get, maxHeaderSize: 16384, setMaxIdleHTTPParsers(max) { - debug("WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\n", "setMaxIdleHTTPParsers() is a no-op"); + debug(`${NODE_HTTP_WARNING}\n`, "setMaxIdleHTTPParsers() is a no-op"); }, get globalAgent() { - return _globalAgent ??= new Agent; + return _globalAgent; }, set globalAgent(agent) { }, @@ -1109,6 +1115,7 @@ var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, METHODS = [ }, http_default = defaultObject; export { request, + _globalAgent as globalAgent, get, http_default as default, createServer, diff --git a/src/js/out/modules/node/https.js b/src/js/out/modules/node/https.js index 84d68c365..f6a4e25d0 100644 --- a/src/js/out/modules/node/https.js +++ b/src/js/out/modules/node/https.js @@ -1,5 +1,5 @@ export * from "node:http"; -var HTTP = import.meta.require("node:http"), https_default = HTTP; +import {default as default2} from "node:http"; export { - https_default as default + default2 as default }; diff --git a/src/js/out/modules/node/inspector.js b/src/js/out/modules/node/inspector.js index cc9e9c88c..3a5073efc 100644 --- a/src/js/out/modules/node/inspector.js +++ b/src/js/out/modules/node/inspector.js @@ -17,7 +17,7 @@ class NotImplementedError extends Error { } // src/js/node/inspector.ts -var EventEmitter = import.meta.require("node:events"); +import EventEmitter from "node:events"; var open = function() { throwNotImplemented("node:inspector open", 2445); }, close = function() { diff --git a/src/js/out/modules/node/net.js b/src/js/out/modules/node/net.js index 162da7754..164ec6677 100644 --- a/src/js/out/modules/node/net.js +++ b/src/js/out/modules/node/net.js @@ -1,3 +1,5 @@ +import {Duplex} from "node:stream"; +import {EventEmitter} from "node:events"; var isIPv4 = function(s) { return IPv4Reg.test(s); }, isIPv6 = function(s) { @@ -24,9 +26,7 @@ var isIPv4 = function(s) { self.emit("listening"); }, createServer = function(options, connectionListener) { return new Server(options, connectionListener); -}; -var IPv4Reg = new RegExp("^((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$"); -var IPv6Reg = new RegExp("^((?:(?:[0-9a-fA-F]{1,4}):){7}(?:(?:[0-9a-fA-F]{1,4})|:)|(?:(?:[0-9a-fA-F]{1,4}):){6}(?:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|:(?:[0-9a-fA-F]{1,4})|:)|(?:(?:[0-9a-fA-F]{1,4}):){5}(?::((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,2}|:)|(?:(?:[0-9a-fA-F]{1,4}):){4}(?:(:(?:[0-9a-fA-F]{1,4})){0,1}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,3}|:)|(?:(?:[0-9a-fA-F]{1,4}):){3}(?:(:(?:[0-9a-fA-F]{1,4})){0,2}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,4}|:)|(?:(?:[0-9a-fA-F]{1,4}):){2}(?:(:(?:[0-9a-fA-F]{1,4})){0,3}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,5}|:)|(?:(?:[0-9a-fA-F]{1,4}):){1}(?:(:(?:[0-9a-fA-F]{1,4})){0,4}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(?:[0-9a-fA-F]{1,4})){1,6}|:)|(?::((?::(?:[0-9a-fA-F]{1,4})){0,5}:((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(?::(?:[0-9a-fA-F]{1,4})){1,7}|:)))(%[0-9a-zA-Z-.:]{1,})?$"), { Bun, createFIFO, Object } = import.meta.primordials, { connect: bunConnect } = Bun, { Duplex } = import.meta.require("node:stream"), { EventEmitter } = import.meta.require("node:events"), { setTimeout } = globalThis, bunTlsSymbol = Symbol.for("::buntls::"), bunSocketServerHandlers = Symbol.for("::bunsocket_serverhandlers::"), bunSocketServerConnections = Symbol.for("::bunnetserverconnections::"), bunSocketServerOptions = Symbol.for("::bunnetserveroptions::"), SocketClass, Socket = function(InternalSocket) { +}, v4Seg = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])", v4Str = `(${v4Seg}[.]){3}${v4Seg}`, IPv4Reg = new RegExp(`^${v4Str}$`), v6Seg = "(?:[0-9a-fA-F]{1,4})", IPv6Reg = new RegExp("^(" + `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` + `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` + `(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|` + `(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|` + `(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|` + `(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` + `(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` + `(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` + ")(%[0-9a-zA-Z-.:]{1,})?$"), { Bun, createFIFO, Object } = globalThis[Symbol.for("Bun.lazy")]("primordials"), { connect: bunConnect } = Bun, { setTimeout } = globalThis, bunTlsSymbol = Symbol.for("::buntls::"), bunSocketServerHandlers = Symbol.for("::bunsocket_serverhandlers::"), bunSocketServerConnections = Symbol.for("::bunnetserverconnections::"), bunSocketServerOptions = Symbol.for("::bunnetserveroptions::"), SocketClass, Socket = function(InternalSocket) { return SocketClass = InternalSocket, Object.defineProperty(SocketClass.prototype, Symbol.toStringTag, { value: "Socket", enumerable: !1 diff --git a/src/js/out/modules/node/path.js b/src/js/out/modules/node/path.js index ad6a231a9..f8cc1ec08 100644 --- a/src/js/out/modules/node/path.js +++ b/src/js/out/modules/node/path.js @@ -1 +1 @@ -var z=function(f){var v=y({basename:f.basename.bind(f),dirname:f.dirname.bind(f),extname:f.extname.bind(f),format:f.format.bind(f),isAbsolute:f.isAbsolute.bind(f),join:f.join.bind(f),normalize:f.normalize.bind(f),parse:f.parse.bind(f),relative:f.relative.bind(f),resolve:f.resolve.bind(f),toNamespacedPath:f.toNamespacedPath.bind(f),sep:f.sep,delimiter:f.delimiter});return v.default=v,v},y=(f)=>Object.assign(Object.create(null),f),I=z(Bun._Path()),m=z(Bun._Path(!1)),J=z(Bun._Path(!0));I.win32=J;I.posix=m;var{basename:A,dirname:K,extname:B,format:g,isAbsolute:C,join:D,normalize:E,parse:L,relative:k,resolve:N,toNamespacedPath:F,sep:O,delimiter:G,__esModule:q}=I;I[Symbol.for("CommonJS")]=0;I.__esModule=!0;var H=I;export{J as win32,F as toNamespacedPath,O as sep,N as resolve,k as relative,m as posix,L as parse,E as normalize,D as join,C as isAbsolute,g as format,B as extname,K as dirname,G as delimiter,H as default,y as createModule,A as basename,q as __esModule}; +var g=function(i){var f=m({basename:i.basename.bind(i),dirname:i.dirname.bind(i),extname:i.extname.bind(i),format:i.format.bind(i),isAbsolute:i.isAbsolute.bind(i),join:i.join.bind(i),normalize:i.normalize.bind(i),parse:i.parse.bind(i),relative:i.relative.bind(i),resolve:i.resolve.bind(i),toNamespacedPath:i.toNamespacedPath.bind(i),sep:i.sep,delimiter:i.delimiter});return f.default=f,f},m=(i)=>Object.assign(Object.create(null),i),k=g(Bun._Path()),q=g(Bun._Path(!1)),v=g(Bun._Path(!0));k.win32=v;k.posix=q;var{basename:y,dirname:z,extname:A,format:B,isAbsolute:C,join:D,normalize:E,parse:F,relative:G,resolve:H,toNamespacedPath:I,sep:J,delimiter:K,__esModule:L}=k;k[Symbol.for("CommonJS")]=0;k.__esModule=!0;var O=k;export{v as win32,I as toNamespacedPath,J as sep,H as resolve,G as relative,q as posix,F as parse,E as normalize,D as join,C as isAbsolute,B as format,A as extname,z as dirname,K as delimiter,O as default,m as createModule,y as basename,L as __esModule}; diff --git a/src/js/out/modules/node/path.posix.js b/src/js/out/modules/node/path.posix.js index 8071342a9..64e8a62f5 100644 --- a/src/js/out/modules/node/path.posix.js +++ b/src/js/out/modules/node/path.posix.js @@ -1 +1 @@ -var e=function(l){return{basename:l.basename.bind(l),dirname:l.dirname.bind(l),extname:l.extname.bind(l),format:l.format.bind(l),isAbsolute:l.isAbsolute.bind(l),join:l.join.bind(l),normalize:l.normalize.bind(l),parse:l.parse.bind(l),relative:l.relative.bind(l),resolve:l.resolve.bind(l),toNamespacedPath:l.toNamespacedPath.bind(l),sep:l.sep,delimiter:l.delimiter}},r=e(Bun._Path(!1));r[Symbol.for("CommonJS")]=0;var{basename:g,dirname:s,extname:k,format:m,isAbsolute:q,join:t,normalize:v,parse:w,relative:x,resolve:i,toNamespacedPath:d,sep:c,delimiter:f}=r,z=r;export{d as toNamespacedPath,c as sep,i as resolve,x as relative,w as parse,v as normalize,t as join,q as isAbsolute,m as format,k as extname,s as dirname,f as delimiter,z as default,g as basename}; +var i=function(e){return{basename:e.basename.bind(e),dirname:e.dirname.bind(e),extname:e.extname.bind(e),format:e.format.bind(e),isAbsolute:e.isAbsolute.bind(e),join:e.join.bind(e),normalize:e.normalize.bind(e),parse:e.parse.bind(e),relative:e.relative.bind(e),resolve:e.resolve.bind(e),toNamespacedPath:e.toNamespacedPath.bind(e),sep:e.sep,delimiter:e.delimiter}},r=i(Bun._Path(!1));r[Symbol.for("CommonJS")]=0;var{basename:d,dirname:l,extname:s,format:c,isAbsolute:f,join:g,normalize:k,parse:m,relative:q,resolve:t,toNamespacedPath:v,sep:w,delimiter:x}=r,z=r;export{v as toNamespacedPath,w as sep,t as resolve,q as relative,m as parse,k as normalize,g as join,f as isAbsolute,c as format,s as extname,l as dirname,x as delimiter,z as default,d as basename}; diff --git a/src/js/out/modules/node/readline.js b/src/js/out/modules/node/readline.js index 06a7f3579..6cfac471d 100644 --- a/src/js/out/modules/node/readline.js +++ b/src/js/out/modules/node/readline.js @@ -1,3 +1,6 @@ +import {EventEmitter} from "node:events"; +import {clearTimeout, setTimeout} from "node:timers"; +import {StringDecoder} from "node:string_decoder"; var stripVTControlCharacters = function(str) { return validateString(str, "str"), RegExpPrototypeSymbolReplace.call(ansi, str, ""); }, promisify = function(original) { @@ -594,7 +597,7 @@ var commonPrefix = function(strings) { }, createInterface = function(input, output, completer, terminal) { return new Interface(input, output, completer, terminal); }; -var { Array, RegExp, String, Bun } = import.meta.primordials, EventEmitter = import.meta.require("node:events"), { clearTimeout, setTimeout } = import.meta.require("timers"), { StringDecoder } = import.meta.require("string_decoder"), isWritable, { inspect } = Bun, debug = process.env.BUN_JS_DEBUG ? console.log : () => { +var { Array, RegExp, String, Bun } = globalThis[Symbol.for("Bun.lazy")]("primordials"), isWritable, { inspect } = Bun, debug = process.env.BUN_JS_DEBUG ? console.log : () => { }, SymbolAsyncIterator = Symbol.asyncIterator, SymbolIterator = Symbol.iterator, SymbolFor = Symbol.for, SymbolReplace = Symbol.replace, ArrayFrom = Array.from, ArrayIsArray = Array.isArray, ArrayPrototypeFilter = Array.prototype.filter, ArrayPrototypeSort = Array.prototype.sort, ArrayPrototypeIndexOf = Array.prototype.indexOf, ArrayPrototypeJoin = Array.prototype.join, ArrayPrototypeMap = Array.prototype.map, ArrayPrototypePop = Array.prototype.pop, ArrayPrototypePush = Array.prototype.push, ArrayPrototypeSlice = Array.prototype.slice, ArrayPrototypeSplice = Array.prototype.splice, ArrayPrototypeReverse = Array.prototype.reverse, ArrayPrototypeShift = Array.prototype.shift, ArrayPrototypeUnshift = Array.prototype.unshift, RegExpPrototypeExec = RegExp.prototype.exec, RegExpPrototypeSymbolReplace = RegExp.prototype[SymbolReplace], StringFromCharCode = String.fromCharCode, StringPrototypeCharCodeAt = String.prototype.charCodeAt, StringPrototypeCodePointAt = String.prototype.codePointAt, StringPrototypeSlice = String.prototype.slice, StringPrototypeToLowerCase = String.prototype.toLowerCase, StringPrototypeEndsWith = String.prototype.endsWith, StringPrototypeRepeat = String.prototype.repeat, StringPrototypeStartsWith = String.prototype.startsWith, StringPrototypeTrim = String.prototype.trim, StringPrototypeNormalize = String.prototype.normalize, NumberIsNaN = Number.isNaN, NumberIsFinite = Number.isFinite, NumberIsInteger = Number.isInteger, NumberMAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, NumberMIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER, MathCeil = Math.ceil, MathFloor = Math.floor, MathMax = Math.max, MathMaxApply = Math.max.apply, DateNow = Date.now, FunctionPrototype = Function.prototype, StringPrototype = String.prototype, StringPrototypeSymbolIterator = StringPrototype[SymbolIterator], StringIteratorPrototypeNext = StringPrototypeSymbolIterator.call("").next, ObjectSetPrototypeOf = Object.setPrototypeOf, ObjectDefineProperty = Object.defineProperty, ObjectDefineProperties = Object.defineProperties, ObjectFreeze = Object.freeze; var { create: ObjectCreate, keys: ObjectKeys } = Object; var createSafeIterator = (factory, next) => { @@ -691,7 +694,6 @@ CSI.kClearToLineBeginning = kClearToLineBeginning = CSI`1K`; CSI.kClearToLineEnd = kClearToLineEnd = CSI`0K`; var KEYPRESS_DECODER = Symbol("keypress-decoder"), ESCAPE_DECODER = Symbol("escape-decoder"), ESCAPE_CODE_TIMEOUT = 500, kEmptyObject = ObjectFreeze(ObjectCreate(null)), kHistorySize = 30, kMaxUndoRedoStackSize = 2048, kMincrlfDelay = 100, lineEnding = /\r?\n|\r(?!\n)/g, kMaxLengthOfKillRing = 32, kLineObjectStream = Symbol("line object stream"), kQuestionCancel = Symbol("kQuestionCancel"), kQuestion = Symbol("kQuestion"), kAddHistory = Symbol("_addHistory"), kBeforeEdit = Symbol("_beforeEdit"), kDecoder = Symbol("_decoder"), kDeleteLeft = Symbol("_deleteLeft"), kDeleteLineLeft = Symbol("_deleteLineLeft"), kDeleteLineRight = Symbol("_deleteLineRight"), kDeleteRight = Symbol("_deleteRight"), kDeleteWordLeft = Symbol("_deleteWordLeft"), kDeleteWordRight = Symbol("_deleteWordRight"), kGetDisplayPos = Symbol("_getDisplayPos"), kHistoryNext = Symbol("_historyNext"), kHistoryPrev = Symbol("_historyPrev"), kInsertString = Symbol("_insertString"), kLine = Symbol("_line"), kLine_buffer = Symbol("_line_buffer"), kKillRing = Symbol("_killRing"), kKillRingCursor = Symbol("_killRingCursor"), kMoveCursor = Symbol("_moveCursor"), kNormalWrite = Symbol("_normalWrite"), kOldPrompt = Symbol("_oldPrompt"), kOnLine = Symbol("_onLine"), kPreviousKey = Symbol("_previousKey"), kPrompt = Symbol("_prompt"), kPushToKillRing = Symbol("_pushToKillRing"), kPushToUndoStack = Symbol("_pushToUndoStack"), kQuestionCallback = Symbol("_questionCallback"), kRedo = Symbol("_redo"), kRedoStack = Symbol("_redoStack"), kRefreshLine = Symbol("_refreshLine"), kSawKeyPress = Symbol("_sawKeyPress"), kSawReturnAt = Symbol("_sawReturnAt"), kSetRawMode = Symbol("_setRawMode"), kTabComplete = Symbol("_tabComplete"), kTabCompleter = Symbol("_tabCompleter"), kTtyWrite = Symbol("_ttyWrite"), kUndo = Symbol("_undo"), kUndoStack = Symbol("_undoStack"), kWordLeft = Symbol("_wordLeft"), kWordRight = Symbol("_wordRight"), kWriteToOutput = Symbol("_writeToOutput"), kYank = Symbol("_yank"), kYanking = Symbol("_yanking"), kYankPop = Symbol("_yankPop"), kFirstEventParam = Symbol("nodejs.kFirstEventParam"), kOnSelfCloseWithTerminal = Symbol("_onSelfCloseWithTerminal"), kOnSelfCloseWithoutTerminal = Symbol("_onSelfCloseWithoutTerminal"), kOnKeyPress = Symbol("_onKeyPress"), kOnError = Symbol("_onError"), kOnData = Symbol("_onData"), kOnEnd = Symbol("_onEnd"), kOnTermEnd = Symbol("_onTermEnd"), kOnResize = Symbol("_onResize"); ObjectSetPrototypeOf(InterfaceConstructor.prototype, EventEmitter.prototype); -ObjectSetPrototypeOf(InterfaceConstructor, EventEmitter); var _Interface = class Interface2 extends InterfaceConstructor { constructor(input, output, completer, terminal) { super(input, output, completer, terminal); diff --git a/src/js/out/modules/node/readline.promises.js b/src/js/out/modules/node/readline.promises.js index bfe5a7855..61a6d256f 100644 --- a/src/js/out/modules/node/readline.promises.js +++ b/src/js/out/modules/node/readline.promises.js @@ -1,11 +1,13 @@ -var { - promises: { Readline, Interface, createInterface } -} = import.meta.require("node:readline"), readline_promises_default = { +import {promises} from "node:readline"; +var { Readline, Interface, createInterface } = promises, readline_promises_default = { Readline, Interface, createInterface, [Symbol.for("CommonJS")]: 0 }; export { - readline_promises_default as default + readline_promises_default as default, + createInterface, + Readline, + Interface }; diff --git a/src/js/out/modules/node/stream.consumers.js b/src/js/out/modules/node/stream.consumers.js index e2cfb9cc1..20bbb7de4 100644 --- a/src/js/out/modules/node/stream.consumers.js +++ b/src/js/out/modules/node/stream.consumers.js @@ -1 +1 @@ -var{Bun:o}=import.meta.primordials,i=o.readableStreamToArrayBuffer,p=o.readableStreamToText,c=(q)=>o.readableStreamToText(q).then(JSON.parse),T=async(q)=>{return new Buffer(await i(q))},h=o.readableStreamToBlob,k={[Symbol.for("CommonJS")]:0,arrayBuffer:i,text:p,json:c,buffer:T,blob:h};export{p as text,c as json,k as default,T as buffer,h as blob,i as arrayBuffer}; +var{Bun:o}=globalThis[Symbol.for("Bun.lazy")]("primordials"),p=o.readableStreamToArrayBuffer,c=o.readableStreamToText,g=(h)=>o.readableStreamToText(h).then(JSON.parse),i=async(h)=>{return new Buffer(await p(h))},k=o.readableStreamToBlob,q={[Symbol.for("CommonJS")]:0,arrayBuffer:p,text:c,json:g,buffer:i,blob:k};export{c as text,g as json,q as default,i as buffer,k as blob,p as arrayBuffer}; diff --git a/src/js/out/modules/node/stream.js b/src/js/out/modules/node/stream.js index 100ca09fa..f96818bd6 100644 --- a/src/js/out/modules/node/stream.js +++ b/src/js/out/modules/node/stream.js @@ -1,2 +1,2 @@ -var Cq=function(q){if(!(this instanceof Cq))return new Cq(q);mq.call(this,q);const Q=q.__id;if(Q)fq(this,"__id",{value:Q,readable:!0,writable:!1,enumerable:!1})},dq=function(q){return typeof q==="object"&&q!==null&&q instanceof ReadableStream},lq=function(q,Q){if(typeof q!=="boolean")throw new nq(Q,"boolean",q)};var nq=function(q,Q,X){return new Error(`The argument '${q}' is invalid. Received '${X}' for type '${Q}'`)},oq=function(q,Q,X){return new Error(`The value '${Q}' is invalid for argument '${q}'. Reason: ${X}`)},FQ=function(q,Q){var[X,J,H,K,Z,Y,B]=globalThis[Symbol.for("Bun.lazy")](q),$=[!1],z=function(F,L,j,N){if(L>0){const P=j.subarray(0,L),E=j.subarray(L);if(P.byteLength>0)F.push(P);if(N)F.push(null);return E.byteLength>0?E:void 0}if(N)F.push(null);return j},V=function(F,L,j,N){if(L.byteLength>0)F.push(L);if(N)F.push(null);return j},U=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const W=new FinalizationRegistry((F)=>F&&Z(F)),G=512;var M=class F extends Q{#q;#Q=1;#X=!1;#J=void 0;#H;#K=!1;#Z=!U;#Y;constructor(L,j={}){super(j);if(typeof j.highWaterMark==="number")this.#H=j.highWaterMark;else this.#H=262144;this.#q=L,this.#X=!1,this.#J=void 0,this.#K=!1,this.#Y={},W.register(this,this.#q,this.#Y)}_read(L){if(Iq&&Eq("NativeReadable._read",this.__id),this.#K){Iq&&Eq("pendingRead is true",this.__id);return}var j=this.#q;if(Iq&&Eq("ptr @ NativeReadable._read",j,this.__id),j===0){this.push(null);return}if(!this.#X)Iq&&Eq("NativeReadable not constructed yet",this.__id),this.#B(j);return this.#V(this.#$(L),j)}#B(L){this.#X=!0;const j=J(L,this.#H);if(Iq&&Eq("NativeReadable internal `start` result",j,this.__id),typeof j==="number"&&j>1)this.#Z=!0,Iq&&Eq("NativeReadable resized",this.__id),this.#H=Math.min(this.#H,j);if(B){const N=B(L);if(Iq&&Eq("NativeReadable drain result",N,this.__id),(N?.byteLength??0)>0)this.push(N)}}#$(L=this.#H){var j=this.#J;if(Iq&&Eq("chunk @ #getRemainingChunk",j,this.__id),j?.byteLength??0G?L:G;this.#J=j=new Buffer(N)}return j}push(L,j){return Iq&&Eq("NativeReadable push -- result, encoding",L,j,this.__id),super.push(...arguments)}#z(L,j,N){if(Iq&&Eq("result, isClosed @ #handleResult",L,N,this.__id),typeof L==="number"){if(L>=this.#H&&!this.#Z&&!N)this.#H*=2,this.#Z=!0;return z(this,L,j,N)}else if(typeof L==="boolean")return this.push(null),j?.byteLength??0>0?j:void 0;else if(ArrayBuffer.isView(L)){if(L.byteLength>=this.#H&&!this.#Z&&!N)this.#H*=2,this.#Z=!0,Iq&&Eq("Resized",this.__id);return V(this,L,j,N)}else throw Iq&&Eq("Unknown result type",L,this.__id),new Error("Invalid result from pull")}#V(L,j){Iq&&Eq("#internalRead()",this.__id),$[0]=!1;var N=X(j,L,$);if(Oq(N))return this.#K=!0,N.then((P)=>{this.#K=!1,Iq&&Eq("pending no longerrrrrrrr (result returned from pull)",this.__id),this.#J=this.#z(P,L,$[0])},(P)=>{Iq&&Eq("error from pull",P,this.__id),errorOrDestroy(this,P)});else this.#J=this.#z(N,L,$[0])}_destroy(L,j){var N=this.#q;if(N===0){j(L);return}if(W.unregister(this.#Y),this.#q=0,Y)Y(N,!1);Iq&&Eq("NativeReadable destroyed",this.__id),H(N,L),j(L)}ref(){var L=this.#q;if(L===0)return;if(this.#Q++===0)Y(L,!0)}unref(){var L=this.#q;if(L===0)return;if(this.#Q--===1)Y(L,!1)}};if(!Y)M.prototype.ref=void 0,M.prototype.unref=void 0;return M},jQ=function(q,Q){return LQ[q]||=FQ(q,Q)},NQ=function(q,Q,X){if(!(Q&&typeof Q==="object"&&Q instanceof ReadableStream))return;const J=Sq(Q);if(!J){Eq("no native readable stream");return}const{stream:H,data:K}=J;return new(jQ(K,q))(H,X)},{isPromise:Oq,isCallable:Rq,direct:Sq,Object:xq}=import.meta.primordials;globalThis.__IDS_TO_TRACK=process.env.DEBUG_TRACK_EE?.length?process.env.DEBUG_TRACK_EE.split(","):process.env.DEBUG_STREAMS?.length?process.env.DEBUG_STREAMS.split(","):null;var gq=!!process.env.DEBUG_TRACK_EE,Iq=!!(process.env.DEBUG||process.env.DEBUG_STREAMS||gq),Eq=Iq?globalThis.__IDS_TO_TRACK?(...q)=>{const Q=q[q.length-1];if(!globalThis.__IDS_TO_TRACK.includes(Q))return;console.log(`ID: ${Q}`,...q.slice(0,-1))}:(...q)=>console.log(...q.slice(0,-1)):()=>{},kq=xq.create,fq=xq.defineProperty,yq=xq.getOwnPropertyDescriptor,hq=xq.getOwnPropertyNames,pq=xq.getPrototypeOf,uq=xq.prototype.hasOwnProperty,bq=xq.setPrototypeOf,_q=(q)=>import.meta.require(q),mq=_q("bun:events_native");bq(Cq.prototype,mq.prototype);bq(Cq,mq);Cq.prototype.emit=function(q,...Q){var X=this.__id;if(X)Eq("emit",q,...Q,X);else Eq("emit",q,...Q);return mq.prototype.emit.call(this,q,...Q)};Cq.prototype.on=function(q,Q){var X=this.__id;if(X)Eq("on",q,"added",X);else Eq("on",q,"added");return mq.prototype.on.call(this,q,Q)};Cq.prototype.addListener=function(q,Q){return this.on(q,Q)};var cq=(q,Q)=>function X(){return Q||(0,q[hq(q)[0]])((Q={exports:{}}).exports,Q),Q.exports};var Aq=process.nextTick;var iq=Array.isArray,Dq=cq({"node_modules/readable-stream/lib/ours/primordials.js"(q,Q){Q.exports={ArrayIsArray(X){return Array.isArray(X)},ArrayPrototypeIncludes(X,J){return X.includes(J)},ArrayPrototypeIndexOf(X,J){return X.indexOf(J)},ArrayPrototypeJoin(X,J){return X.join(J)},ArrayPrototypeMap(X,J){return X.map(J)},ArrayPrototypePop(X,J){return X.pop(J)},ArrayPrototypePush(X,J){return X.push(J)},ArrayPrototypeSlice(X,J,H){return X.slice(J,H)},Error,FunctionPrototypeCall(X,J,...H){return X.call(J,...H)},FunctionPrototypeSymbolHasInstance(X,J){return Function.prototype[Symbol.hasInstance].call(X,J)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(X,J){return xq.defineProperties(X,J)},ObjectDefineProperty(X,J,H){return xq.defineProperty(X,J,H)},ObjectGetOwnPropertyDescriptor(X,J){return xq.getOwnPropertyDescriptor(X,J)},ObjectKeys(X){return xq.keys(X)},ObjectSetPrototypeOf(X,J){return xq.setPrototypeOf(X,J)},Promise,PromisePrototypeCatch(X,J){return X.catch(J)},PromisePrototypeThen(X,J,H){return X.then(J,H)},PromiseReject(X){return Promise.reject(X)},ReflectApply:Reflect.apply,RegExpPrototypeTest(X,J){return X.test(J)},SafeSet:Set,String,StringPrototypeSlice(X,J,H){return X.slice(J,H)},StringPrototypeToLowerCase(X){return X.toLowerCase()},StringPrototypeToUpperCase(X){return X.toUpperCase()},StringPrototypeTrim(X){return X.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(X,J,H){return X.set(J,H)},Uint8Array}}}),wq=cq({"node_modules/readable-stream/lib/ours/util.js"(q,Q){var X=_q("buffer"),J=xq.getPrototypeOf(async function(){}).constructor,H=globalThis.Blob||X.Blob,K=typeof H!=="undefined"?function Y(B){return B instanceof H}:function Y(B){return!1},Z=class extends Error{constructor(Y){if(!Array.isArray(Y))throw new TypeError(`Expected input to be an Array, got ${typeof Y}`);let B="";for(let $=0;${Y=z,B=V}),resolve:Y,reject:B}},promisify(Y){return new Promise((B,$)=>{Y((z,...V)=>{if(z)return $(z);return B(...V)})})},debuglog(){return function(){}},format(Y,...B){return Y.replace(/%([sdifj])/g,function(...[$,z]){const V=B.shift();if(z==="f")return V.toFixed(6);else if(z==="j")return JSON.stringify(V);else if(z==="s"&&typeof V==="object")return`${V.constructor!==xq?V.constructor.name:""} {}`.trim();else return V.toString()})},inspect(Y){switch(typeof Y){case"string":if(Y.includes("'")){if(!Y.includes('"'))return`"${Y}"`;else if(!Y.includes("`")&&!Y.includes("${"))return`\`${Y}\``}return`'${Y}'`;case"number":if(isNaN(Y))return"NaN";else if(xq.is(Y,-0))return String(Y);return Y;case"bigint":return`${String(Y)}n`;case"boolean":case"undefined":return String(Y);case"object":return"{}"}},types:{isAsyncFunction(Y){return Y instanceof J},isArrayBufferView(Y){return ArrayBuffer.isView(Y)}},isBlob:K},Q.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}}),sq=cq({"node_modules/readable-stream/lib/ours/errors.js"(q,Q){var{format:X,inspect:J,AggregateError:H}=wq(),K=globalThis.AggregateError||H,Z=Symbol("kIsNodeError"),Y=["string","function","number","object","Function","Object","boolean","bigint","symbol"],B=/^([A-Z][a-z0-9]*)+$/,$="__node_internal_",z={};function V(j,N){if(!j)throw new z.ERR_INTERNAL_ASSERTION(N)}function U(j){let N="",P=j.length;const E=j[0]==="-"?1:0;for(;P>=E+4;P-=3)N=`_${j.slice(P-3,P)}${N}`;return`${j.slice(0,P)}${N}`}function W(j,N,P){if(typeof N==="function")return V(N.length<=P.length,`Code: ${j}; The provided arguments length (${P.length}) does not match the required ones (${N.length}).`),N(...P);const E=(N.match(/%[dfijoOs]/g)||[]).length;if(V(E===P.length,`Code: ${j}; The provided arguments length (${P.length}) does not match the required ones (${E}).`),P.length===0)return N;return X(N,...P)}function G(j,N,P){if(!P)P=Error;class E extends P{constructor(...I){super(W(j,N,I))}toString(){return`${this.name} [${j}]: ${this.message}`}}xq.defineProperties(E.prototype,{name:{value:P.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${j}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),E.prototype.code=j,E.prototype[Z]=!0,z[j]=E}function M(j){const N=$+j.name;return xq.defineProperty(j,"name",{value:N}),j}function F(j,N){if(j&&N&&j!==N){if(Array.isArray(N.errors))return N.errors.push(j),N;const P=new K([N,j],N.message);return P.code=N.code,P}return j||N}var L=class extends Error{constructor(j="The operation was aborted",N=void 0){if(N!==void 0&&typeof N!=="object")throw new z.ERR_INVALID_ARG_TYPE("options","Object",N);super(j,N);this.code="ABORT_ERR",this.name="AbortError"}};G("ERR_ASSERTION","%s",Error),G("ERR_INVALID_ARG_TYPE",(j,N,P)=>{if(V(typeof j==="string","'name' must be a string"),!Array.isArray(N))N=[N];let E="The ";if(j.endsWith(" argument"))E+=`${j} `;else E+=`"${j}" ${j.includes(".")?"property":"argument"} `;E+="must be ";const I=[],T=[],A=[];for(let O of N)if(V(typeof O==="string","All expected entries have to be of type string"),Y.includes(O))I.push(O.toLowerCase());else if(B.test(O))T.push(O);else V(O!=="object",'The value "object" should be written as "Object"'),A.push(O);if(T.length>0){const O=I.indexOf("object");if(O!==-1)I.splice(I,O,1),T.push("Object")}if(I.length>0){switch(I.length){case 1:E+=`of type ${I[0]}`;break;case 2:E+=`one of type ${I[0]} or ${I[1]}`;break;default:{const O=I.pop();E+=`one of type ${I.join(", ")}, or ${O}`}}if(T.length>0||A.length>0)E+=" or "}if(T.length>0){switch(T.length){case 1:E+=`an instance of ${T[0]}`;break;case 2:E+=`an instance of ${T[0]} or ${T[1]}`;break;default:{const O=T.pop();E+=`an instance of ${T.join(", ")}, or ${O}`}}if(A.length>0)E+=" or "}switch(A.length){case 0:break;case 1:if(A[0].toLowerCase()!==A[0])E+="an ";E+=`${A[0]}`;break;case 2:E+=`one of ${A[0]} or ${A[1]}`;break;default:{const O=A.pop();E+=`one of ${A.join(", ")}, or ${O}`}}if(P==null)E+=`. Received ${P}`;else if(typeof P==="function"&&P.name)E+=`. Received function ${P.name}`;else if(typeof P==="object"){var x;if((x=P.constructor)!==null&&x!==void 0&&x.name)E+=`. Received an instance of ${P.constructor.name}`;else{const O=J(P,{depth:-1});E+=`. Received ${O}`}}else{let O=J(P,{colors:!1});if(O.length>25)O=`${O.slice(0,25)}...`;E+=`. Received type ${typeof P} (${O})`}return E},TypeError),G("ERR_INVALID_ARG_VALUE",(j,N,P="is invalid")=>{let E=J(N);if(E.length>128)E=E.slice(0,128)+"...";return`The ${j.includes(".")?"property":"argument"} '${j}' ${P}. Received ${E}`},TypeError),G("ERR_INVALID_RETURN_VALUE",(j,N,P)=>{var E;const I=P!==null&&P!==void 0&&(E=P.constructor)!==null&&E!==void 0&&E.name?`instance of ${P.constructor.name}`:`type ${typeof P}`;return`Expected ${j} to be returned from the "${N}" function but got ${I}.`},TypeError),G("ERR_MISSING_ARGS",(...j)=>{V(j.length>0,"At least one arg needs to be specified");let N;const P=j.length;switch(j=(Array.isArray(j)?j:[j]).map((E)=>`"${E}"`).join(" or "),P){case 1:N+=`The ${j[0]} argument`;break;case 2:N+=`The ${j[0]} and ${j[1]} arguments`;break;default:{const E=j.pop();N+=`The ${j.join(", ")}, and ${E} arguments`}break}return`${N} must be specified`},TypeError),G("ERR_OUT_OF_RANGE",(j,N,P)=>{V(N,'Missing "range" argument');let E;if(Number.isInteger(P)&&Math.abs(P)>4294967296)E=U(String(P));else if(typeof P==="bigint"){if(E=String(P),P>2n**32n||P<-(2n**32n))E=U(E);E+="n"}else E=J(P);return`The value of "${j}" is out of range. It must be ${N}. Received ${E}`},RangeError),G("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),G("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),G("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),G("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),G("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),G("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),G("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),G("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),G("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),G("ERR_STREAM_WRITE_AFTER_END","write after end",Error),G("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),Q.exports={AbortError:L,aggregateTwoErrors:M(F),hideStackFrames:M,codes:z}}}),aq=cq({"node_modules/readable-stream/lib/internal/validators.js"(q,Q){var{ArrayIsArray:X,ArrayPrototypeIncludes:J,ArrayPrototypeJoin:H,ArrayPrototypeMap:K,NumberIsInteger:Z,NumberMAX_SAFE_INTEGER:Y,NumberMIN_SAFE_INTEGER:B,NumberParseInt:$,RegExpPrototypeTest:z,String:V,StringPrototypeToUpperCase:U,StringPrototypeTrim:W}=Dq(),{hideStackFrames:G,codes:{ERR_SOCKET_BAD_PORT:M,ERR_INVALID_ARG_TYPE:F,ERR_INVALID_ARG_VALUE:L,ERR_OUT_OF_RANGE:j,ERR_UNKNOWN_SIGNAL:N}}=sq(),{normalizeEncoding:P}=wq(),{isAsyncFunction:E,isArrayBufferView:I}=wq().types,T={};function A(i){return i===(i|0)}function x(i){return i===i>>>0}var O=/^[0-7]+$/,_="must be a 32-bit unsigned integer or an octal string";function C(i,n,o){if(typeof i==="undefined")i=o;if(typeof i==="string"){if(!z(O,i))throw new L(n,i,_);i=$(i,8)}return w(i,n,0,4294967295),i}var D=G((i,n,o=B,s=Y)=>{if(typeof i!=="number")throw new F(n,"number",i);if(!Z(i))throw new j(n,"an integer",i);if(is)throw new j(n,`>= ${o} && <= ${s}`,i)}),w=G((i,n,o=-2147483648,s=2147483647)=>{if(typeof i!=="number")throw new F(n,"number",i);if(!A(i)){if(!Z(i))throw new j(n,"an integer",i);throw new j(n,`>= ${o} && <= ${s}`,i)}if(is)throw new j(n,`>= ${o} && <= ${s}`,i)}),v=G((i,n,o)=>{if(typeof i!=="number")throw new F(n,"number",i);if(!x(i)){if(!Z(i))throw new j(n,"an integer",i);throw new j(n,`>= ${o?1:0} && < 4294967296`,i)}if(o&&i===0)throw new j(n,">= 1 && < 4294967296",i)});function R(i,n){if(typeof i!=="string")throw new F(n,"string",i)}function S(i,n){if(typeof i!=="number")throw new F(n,"number",i)}var g=G((i,n,o)=>{if(!J(o,i)){const a="must be one of: "+H(K(o,(r)=>typeof r==="string"?`'${r}'`:V(r)),", ");throw new L(n,i,a)}});function k(i,n){if(typeof i!=="boolean")throw new F(n,"boolean",i)}var f=G((i,n,o)=>{const s=o==null,a=s?!1:o.allowArray,r=s?!1:o.allowFunction;if(!(s?!1:o.nullable)&&i===null||!a&&X(i)||typeof i!=="object"&&(!r||typeof i!=="function"))throw new F(n,"Object",i)}),y=G((i,n,o=0)=>{if(!X(i))throw new F(n,"Array",i);if(i.length{if(!I(i))throw new F(n,["Buffer","TypedArray","DataView"],i)});function u(i,n){const o=P(n),s=i.length;if(o==="hex"&&s%2!==0)throw new L("encoding",n,`is invalid for data of length ${s}`)}function b(i,n="Port",o=!0){if(typeof i!=="number"&&typeof i!=="string"||typeof i==="string"&&W(i).length===0||+i!==+i>>>0||i>65535||i===0&&!o)throw new M(n,i,o);return i|0}var m=G((i,n)=>{if(i!==void 0&&(i===null||typeof i!=="object"||!("aborted"in i)))throw new F(n,"AbortSignal",i)}),c=G((i,n)=>{if(typeof i!=="function")throw new F(n,"Function",i)}),d=G((i,n)=>{if(typeof i!=="function"||E(i))throw new F(n,"Function",i)}),l=G((i,n)=>{if(i!==void 0)throw new F(n,"undefined",i)});Q.exports={isInt32:A,isUint32:x,parseFileMode:C,validateArray:y,validateBoolean:k,validateBuffer:p,validateEncoding:u,validateFunction:c,validateInt32:w,validateInteger:D,validateNumber:S,validateObject:f,validateOneOf:g,validatePlainFunction:d,validatePort:b,validateSignalName:h,validateString:R,validateUint32:v,validateUndefined:l,validateAbortSignal:m}}}),rq=cq({"node_modules/readable-stream/lib/internal/streams/utils.js"(q,Q){var{Symbol:X,SymbolAsyncIterator:J,SymbolIterator:H}=Dq(),K=X("kDestroyed"),Z=X("kIsErrored"),Y=X("kIsReadable"),B=X("kIsDisturbed");function $(v,R=!1){var S;return!!(v&&typeof v.pipe==="function"&&typeof v.on==="function"&&(!R||typeof v.pause==="function"&&typeof v.resume==="function")&&(!v._writableState||((S=v._readableState)===null||S===void 0?void 0:S.readable)!==!1)&&(!v._writableState||v._readableState))}function z(v){var R;return!!(v&&typeof v.write==="function"&&typeof v.on==="function"&&(!v._readableState||((R=v._writableState)===null||R===void 0?void 0:R.writable)!==!1))}function V(v){return!!(v&&typeof v.pipe==="function"&&v._readableState&&typeof v.on==="function"&&typeof v.write==="function")}function U(v){return v&&(v._readableState||v._writableState||typeof v.write==="function"&&typeof v.on==="function"||typeof v.pipe==="function"&&typeof v.on==="function")}function W(v,R){if(v==null)return!1;if(R===!0)return typeof v[J]==="function";if(R===!1)return typeof v[H]==="function";return typeof v[J]==="function"||typeof v[H]==="function"}function G(v){if(!U(v))return null;const{_writableState:R,_readableState:S}=v,g=R||S;return!!(v.destroyed||v[K]||g!==null&&g!==void 0&&g.destroyed)}function M(v){if(!z(v))return null;if(v.writableEnded===!0)return!0;const R=v._writableState;if(R!==null&&R!==void 0&&R.errored)return!1;if(typeof(R===null||R===void 0?void 0:R.ended)!=="boolean")return null;return R.ended}function F(v,R){if(!z(v))return null;if(v.writableFinished===!0)return!0;const S=v._writableState;if(S!==null&&S!==void 0&&S.errored)return!1;if(typeof(S===null||S===void 0?void 0:S.finished)!=="boolean")return null;return!!(S.finished||R===!1&&S.ended===!0&&S.length===0)}function L(v){if(!$(v))return null;if(v.readableEnded===!0)return!0;const R=v._readableState;if(!R||R.errored)return!1;if(typeof(R===null||R===void 0?void 0:R.ended)!=="boolean")return null;return R.ended}function j(v,R){if(!$(v))return null;const S=v._readableState;if(S!==null&&S!==void 0&&S.errored)return!1;if(typeof(S===null||S===void 0?void 0:S.endEmitted)!=="boolean")return null;return!!(S.endEmitted||R===!1&&S.ended===!0&&S.length===0)}function N(v){if(v&&v[Y]!=null)return v[Y];if(typeof(v===null||v===void 0?void 0:v.readable)!=="boolean")return null;if(G(v))return!1;return $(v)&&v.readable&&!j(v)}function P(v){if(typeof(v===null||v===void 0?void 0:v.writable)!=="boolean")return null;if(G(v))return!1;return z(v)&&v.writable&&!M(v)}function E(v,R){if(!U(v))return null;if(G(v))return!0;if((R===null||R===void 0?void 0:R.readable)!==!1&&N(v))return!1;if((R===null||R===void 0?void 0:R.writable)!==!1&&P(v))return!1;return!0}function I(v){var R,S;if(!U(v))return null;if(v.writableErrored)return v.writableErrored;return(R=(S=v._writableState)===null||S===void 0?void 0:S.errored)!==null&&R!==void 0?R:null}function T(v){var R,S;if(!U(v))return null;if(v.readableErrored)return v.readableErrored;return(R=(S=v._readableState)===null||S===void 0?void 0:S.errored)!==null&&R!==void 0?R:null}function A(v){if(!U(v))return null;if(typeof v.closed==="boolean")return v.closed;const{_writableState:R,_readableState:S}=v;if(typeof(R===null||R===void 0?void 0:R.closed)==="boolean"||typeof(S===null||S===void 0?void 0:S.closed)==="boolean")return(R===null||R===void 0?void 0:R.closed)||(S===null||S===void 0?void 0:S.closed);if(typeof v._closed==="boolean"&&x(v))return v._closed;return null}function x(v){return typeof v._closed==="boolean"&&typeof v._defaultKeepAlive==="boolean"&&typeof v._removedConnection==="boolean"&&typeof v._removedContLen==="boolean"}function O(v){return typeof v._sent100==="boolean"&&x(v)}function _(v){var R;return typeof v._consuming==="boolean"&&typeof v._dumped==="boolean"&&((R=v.req)===null||R===void 0?void 0:R.upgradeOrConnect)===void 0}function C(v){if(!U(v))return null;const{_writableState:R,_readableState:S}=v,g=R||S;return!g&&O(v)||!!(g&&g.autoDestroy&&g.emitClose&&g.closed===!1)}function D(v){var R;return!!(v&&((R=v[B])!==null&&R!==void 0?R:v.readableDidRead||v.readableAborted))}function w(v){var R,S,g,k,f,y,h,p,u,b;return!!(v&&((R=(S=(g=(k=(f=(y=v[Z])!==null&&y!==void 0?y:v.readableErrored)!==null&&f!==void 0?f:v.writableErrored)!==null&&k!==void 0?k:(h=v._readableState)===null||h===void 0?void 0:h.errorEmitted)!==null&&g!==void 0?g:(p=v._writableState)===null||p===void 0?void 0:p.errorEmitted)!==null&&S!==void 0?S:(u=v._readableState)===null||u===void 0?void 0:u.errored)!==null&&R!==void 0?R:(b=v._writableState)===null||b===void 0?void 0:b.errored))}Q.exports={kDestroyed:K,isDisturbed:D,kIsDisturbed:B,isErrored:w,kIsErrored:Z,isReadable:N,kIsReadable:Y,isClosed:A,isDestroyed:G,isDuplexNodeStream:V,isFinished:E,isIterable:W,isReadableNodeStream:$,isReadableEnded:L,isReadableFinished:j,isReadableErrored:T,isNodeStream:U,isWritable:P,isWritableNodeStream:z,isWritableEnded:M,isWritableFinished:F,isWritableErrored:I,isServerRequest:_,isServerResponse:O,willEmitClose:C}}}),tq=cq({"node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(q,Q){var{AbortError:X,codes:J}=sq(),{ERR_INVALID_ARG_TYPE:H,ERR_STREAM_PREMATURE_CLOSE:K}=J,{once:Z}=wq(),{validateAbortSignal:Y,validateFunction:B,validateObject:$}=aq(),{Promise:z}=Dq(),{isClosed:V,isReadable:U,isReadableNodeStream:W,isReadableFinished:G,isReadableErrored:M,isWritable:F,isWritableNodeStream:L,isWritableFinished:j,isWritableErrored:N,isNodeStream:P,willEmitClose:E}=rq();function I(O){return O.setHeader&&typeof O.abort==="function"}var T=()=>{};function A(O,_,C){var D,w;if(arguments.length===2)C=_,_={};else if(_==null)_={};else $(_,"options");B(C,"callback"),Y(_.signal,"options.signal"),C=Z(C);const v=(D=_.readable)!==null&&D!==void 0?D:W(O),R=(w=_.writable)!==null&&w!==void 0?w:L(O);if(!P(O))throw new H("stream","Stream",O);const{_writableState:S,_readableState:g}=O,k=()=>{if(!O.writable)h()};let f=E(O)&&W(O)===v&&L(O)===R,y=j(O,!1);const h=()=>{if(y=!0,O.destroyed)f=!1;if(f&&(!O.readable||v))return;if(!v||p)C.call(O)};let p=G(O,!1);const u=()=>{if(p=!0,O.destroyed)f=!1;if(f&&(!O.writable||R))return;if(!R||y)C.call(O)},b=(i)=>{C.call(O,i)};let m=V(O);const c=()=>{m=!0;const i=N(O)||M(O);if(i&&typeof i!=="boolean")return C.call(O,i);if(v&&!p&&W(O,!0)){if(!G(O,!1))return C.call(O,new K)}if(R&&!y){if(!j(O,!1))return C.call(O,new K)}C.call(O)},d=()=>{O.req.on("finish",h)};if(I(O)){if(O.on("complete",h),!f)O.on("abort",c);if(O.req)d();else O.on("request",d)}else if(R&&!S)O.on("end",k),O.on("close",k);if(!f&&typeof O.aborted==="boolean")O.on("aborted",c);if(O.on("end",u),O.on("finish",h),_.error!==!1)O.on("error",b);if(O.on("close",c),m)Aq(c);else if(S!==null&&S!==void 0&&S.errorEmitted||g!==null&&g!==void 0&&g.errorEmitted){if(!f)Aq(c)}else if(!v&&(!f||U(O))&&(y||F(O)===!1))Aq(c);else if(!R&&(!f||F(O))&&(p||U(O)===!1))Aq(c);else if(g&&O.req&&O.aborted)Aq(c);const l=()=>{if(C=T,O.removeListener("aborted",c),O.removeListener("complete",h),O.removeListener("abort",c),O.removeListener("request",d),O.req)O.req.removeListener("finish",h);O.removeListener("end",k),O.removeListener("close",k),O.removeListener("finish",h),O.removeListener("end",u),O.removeListener("error",b),O.removeListener("close",c)};if(_.signal&&!m){const i=()=>{const n=C;l(),n.call(O,new X(void 0,{cause:_.signal.reason}))};if(_.signal.aborted)Aq(i);else{const n=C;C=Z((...o)=>{_.signal.removeEventListener("abort",i),n.apply(O,o)}),_.signal.addEventListener("abort",i)}}return l}function x(O,_){return new z((C,D)=>{A(O,_,(w)=>{if(w)D(w);else C()})})}Q.exports=A,Q.exports.finished=x}}),eq=cq({"node_modules/readable-stream/lib/internal/streams/operators.js"(q,Q){var X=globalThis.AbortController||_q("abort-controller").AbortController,{codes:{ERR_INVALID_ARG_TYPE:J,ERR_MISSING_ARGS:H,ERR_OUT_OF_RANGE:K},AbortError:Z}=sq(),{validateAbortSignal:Y,validateInteger:B,validateObject:$}=aq(),z=Dq().Symbol("kWeak"),{finished:V}=tq(),{ArrayPrototypePush:U,MathFloor:W,Number:G,NumberIsNaN:M,Promise:F,PromiseReject:L,PromisePrototypeCatch:j,Symbol:N}=Dq(),P=N("kEmpty"),E=N("kEof");function I(f,y){if(typeof f!=="function")throw new J("fn",["Function","AsyncFunction"],f);if(y!=null)$(y,"options");if((y===null||y===void 0?void 0:y.signal)!=null)Y(y.signal,"options.signal");let h=1;if((y===null||y===void 0?void 0:y.concurrency)!=null)h=W(y.concurrency);return B(h,"concurrency",1),async function*p(){var u,b;const m=new X,c=this,d=[],l=m.signal,i={signal:l},n=()=>m.abort();if(y!==null&&y!==void 0&&(u=y.signal)!==null&&u!==void 0&&u.aborted)n();y===null||y===void 0||(b=y.signal)===null||b===void 0||b.addEventListener("abort",n);let o,s,a=!1;function r(){a=!0}async function t(){try{for await(let Qq of c){var e;if(a)return;if(l.aborted)throw new Z;try{Qq=f(Qq,i)}catch(Xq){Qq=L(Xq)}if(Qq===P)continue;if(typeof((e=Qq)===null||e===void 0?void 0:e.catch)==="function")Qq.catch(r);if(d.push(Qq),o)o(),o=null;if(!a&&d.length&&d.length>=h)await new F((Xq)=>{s=Xq})}d.push(E)}catch(Qq){const Xq=L(Qq);j(Xq,r),d.push(Xq)}finally{var qq;if(a=!0,o)o(),o=null;y===null||y===void 0||(qq=y.signal)===null||qq===void 0||qq.removeEventListener("abort",n)}}t();try{while(!0){while(d.length>0){const e=await d[0];if(e===E)return;if(l.aborted)throw new Z;if(e!==P)yield e;if(d.shift(),s)s(),s=null}await new F((e)=>{o=e})}}finally{if(m.abort(),a=!0,s)s(),s=null}}.call(this)}function T(f=void 0){if(f!=null)$(f,"options");if((f===null||f===void 0?void 0:f.signal)!=null)Y(f.signal,"options.signal");return async function*y(){let h=0;for await(let u of this){var p;if(f!==null&&f!==void 0&&(p=f.signal)!==null&&p!==void 0&&p.aborted)throw new Z({cause:f.signal.reason});yield[h++,u]}}.call(this)}async function A(f,y=void 0){for await(let h of C.call(this,f,y))return!0;return!1}async function x(f,y=void 0){if(typeof f!=="function")throw new J("fn",["Function","AsyncFunction"],f);return!await A.call(this,async(...h)=>{return!await f(...h)},y)}async function O(f,y){for await(let h of C.call(this,f,y))return h;return}async function _(f,y){if(typeof f!=="function")throw new J("fn",["Function","AsyncFunction"],f);async function h(p,u){return await f(p,u),P}for await(let p of I.call(this,h,y));}function C(f,y){if(typeof f!=="function")throw new J("fn",["Function","AsyncFunction"],f);async function h(p,u){if(await f(p,u))return p;return P}return I.call(this,h,y)}var D=class extends H{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}};async function w(f,y,h){var p;if(typeof f!=="function")throw new J("reducer",["Function","AsyncFunction"],f);if(h!=null)$(h,"options");if((h===null||h===void 0?void 0:h.signal)!=null)Y(h.signal,"options.signal");let u=arguments.length>1;if(h!==null&&h!==void 0&&(p=h.signal)!==null&&p!==void 0&&p.aborted){const l=new Z(void 0,{cause:h.signal.reason});throw this.once("error",()=>{}),await V(this.destroy(l)),l}const b=new X,m=b.signal;if(h!==null&&h!==void 0&&h.signal){const l={once:!0,[z]:this};h.signal.addEventListener("abort",()=>b.abort(),l)}let c=!1;try{for await(let l of this){var d;if(c=!0,h!==null&&h!==void 0&&(d=h.signal)!==null&&d!==void 0&&d.aborted)throw new Z;if(!u)y=l,u=!0;else y=await f(y,l,{signal:m})}if(!c&&!u)throw new D}finally{b.abort()}return y}async function v(f){if(f!=null)$(f,"options");if((f===null||f===void 0?void 0:f.signal)!=null)Y(f.signal,"options.signal");const y=[];for await(let p of this){var h;if(f!==null&&f!==void 0&&(h=f.signal)!==null&&h!==void 0&&h.aborted)throw new Z(void 0,{cause:f.signal.reason});U(y,p)}return y}function R(f,y){const h=I.call(this,f,y);return async function*p(){for await(let u of h)yield*u}.call(this)}function S(f){if(f=G(f),M(f))return 0;if(f<0)throw new K("number",">= 0",f);return f}function g(f,y=void 0){if(y!=null)$(y,"options");if((y===null||y===void 0?void 0:y.signal)!=null)Y(y.signal,"options.signal");return f=S(f),async function*h(){var p;if(y!==null&&y!==void 0&&(p=y.signal)!==null&&p!==void 0&&p.aborted)throw new Z;for await(let b of this){var u;if(y!==null&&y!==void 0&&(u=y.signal)!==null&&u!==void 0&&u.aborted)throw new Z;if(f--<=0)yield b}}.call(this)}function k(f,y=void 0){if(y!=null)$(y,"options");if((y===null||y===void 0?void 0:y.signal)!=null)Y(y.signal,"options.signal");return f=S(f),async function*h(){var p;if(y!==null&&y!==void 0&&(p=y.signal)!==null&&p!==void 0&&p.aborted)throw new Z;for await(let b of this){var u;if(y!==null&&y!==void 0&&(u=y.signal)!==null&&u!==void 0&&u.aborted)throw new Z;if(f-- >0)yield b;else return}}.call(this)}Q.exports.streamReturningOperators={asIndexedPairs:T,drop:g,filter:C,flatMap:R,map:I,take:k},Q.exports.promiseReturningOperators={every:x,forEach:_,reduce:w,toArray:v,some:A,find:O}}}),qQ=cq({"node_modules/readable-stream/lib/internal/streams/destroy.js"(q,Q){var{aggregateTwoErrors:X,codes:{ERR_MULTIPLE_CALLBACK:J},AbortError:H}=sq(),{Symbol:K}=Dq(),{kDestroyed:Z,isDestroyed:Y,isFinished:B,isServerRequest:$}=rq(),z="#kDestroy",V="#kConstruct";function U(_,C,D){if(_){if(_.stack,C&&!C.errored)C.errored=_;if(D&&!D.errored)D.errored=_}}function W(_,C){const D=this._readableState,w=this._writableState,v=w||D;if(w&&w.destroyed||D&&D.destroyed){if(typeof C==="function")C();return this}if(U(_,w,D),w)w.destroyed=!0;if(D)D.destroyed=!0;if(!v.constructed)this.once(z,(R)=>{G(this,X(R,_),C)});else G(this,_,C);return this}function G(_,C,D){let w=!1;function v(R){if(w)return;w=!0;const{_readableState:S,_writableState:g}=_;if(U(R,g,S),g)g.closed=!0;if(S)S.closed=!0;if(typeof D==="function")D(R);if(R)Aq(M,_,R);else Aq(F,_)}try{_._destroy(C||null,v)}catch(R){v(R)}}function M(_,C){L(_,C),F(_)}function F(_){const{_readableState:C,_writableState:D}=_;if(D)D.closeEmitted=!0;if(C)C.closeEmitted=!0;if(D&&D.emitClose||C&&C.emitClose)_.emit("close")}function L(_,C){const D=_?._readableState,w=_?._writableState;if(w?.errorEmitted||D?.errorEmitted)return;if(w)w.errorEmitted=!0;if(D)D.errorEmitted=!0;_?.emit?.("error",C)}function j(){const _=this._readableState,C=this._writableState;if(_)_.constructed=!0,_.closed=!1,_.closeEmitted=!1,_.destroyed=!1,_.errored=null,_.errorEmitted=!1,_.reading=!1,_.ended=_.readable===!1,_.endEmitted=_.readable===!1;if(C)C.constructed=!0,C.destroyed=!1,C.closed=!1,C.closeEmitted=!1,C.errored=null,C.errorEmitted=!1,C.finalCalled=!1,C.prefinished=!1,C.ended=C.writable===!1,C.ending=C.writable===!1,C.finished=C.writable===!1}function N(_,C,D){const w=_?._readableState,v=_?._writableState;if(v&&v.destroyed||w&&w.destroyed)return this;if(w&&w.autoDestroy||v&&v.autoDestroy)_.destroy(C);else if(C){if(Error.captureStackTrace(C),v&&!v.errored)v.errored=C;if(w&&!w.errored)w.errored=C;if(D)Aq(L,_,C);else L(_,C)}}function P(_,C){if(typeof _._construct!=="function")return;const{_readableState:D,_writableState:w}=_;if(D)D.constructed=!1;if(w)w.constructed=!1;if(_.once(V,C),_.listenerCount(V)>1)return;Aq(E,_)}function E(_){let C=!1;function D(w){if(C){N(_,w!==null&&w!==void 0?w:new J);return}C=!0;const{_readableState:v,_writableState:R}=_,S=R||v;if(v)v.constructed=!0;if(R)R.constructed=!0;if(S.destroyed)_.emit(z,w);else if(w)N(_,w,!0);else Aq(I,_)}try{_._construct(D)}catch(w){D(w)}}function I(_){_.emit(V)}function T(_){return _&&_.setHeader&&typeof _.abort==="function"}function A(_){_.emit("close")}function x(_,C){_.emit("error",C),Aq(A,_)}function O(_,C){if(!_||Y(_))return;if(!C&&!B(_))C=new H;if($(_))_.socket=null,_.destroy(C);else if(T(_))_.abort();else if(T(_.req))_.req.abort();else if(typeof _.destroy==="function")_.destroy(C);else if(typeof _.close==="function")_.close();else if(C)Aq(x,_);else Aq(A,_);if(!_.destroyed)_[Z]=!0}Q.exports={construct:P,destroyer:O,destroy:W,undestroy:j,errorOrDestroy:N}}}),QQ=cq({"node_modules/readable-stream/lib/internal/streams/legacy.js"(q,Q){var{ArrayIsArray:X,ObjectSetPrototypeOf:J}=Dq(),{EventEmitter:H}=_q("bun:events_native"),K;if(gq)K=Cq;else K=H;function Z(B){if(!(this instanceof Z))return new Z(B);K.call(this,B)}J(Z.prototype,K.prototype),J(Z,K),Z.prototype.pipe=function(B,$){const z=this;function V(j){if(B.writable&&B.write(j)===!1&&z.pause)z.pause()}z.on("data",V);function U(){if(z.readable&&z.resume)z.resume()}if(B.on("drain",U),!B._isStdio&&(!$||$.end!==!1))z.on("end",G),z.on("close",M);let W=!1;function G(){if(W)return;W=!0,B.end()}function M(){if(W)return;if(W=!0,typeof B.destroy==="function")B.destroy()}function F(j){if(L(),K.listenerCount(this,"error")===0)this.emit("error",j)}Y(z,"error",F),Y(B,"error",F);function L(){z.removeListener("data",V),B.removeListener("drain",U),z.removeListener("end",G),z.removeListener("close",M),z.removeListener("error",F),B.removeListener("error",F),z.removeListener("end",L),z.removeListener("close",L),B.removeListener("close",L)}return z.on("end",L),z.on("close",L),B.on("close",L),B.emit("pipe",z),B};function Y(B,$,z){if(typeof B.prependListener==="function")return B.prependListener($,z);if(!B._events||!B._events[$])B.on($,z);else if(X(B._events[$]))B._events[$].unshift(z);else B._events[$]=[z,B._events[$]]}Q.exports={Stream:Z,prependListener:Y}}}),XQ=cq({"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js"(q,Q){var{AbortError:X,codes:J}=sq(),H=tq(),{ERR_INVALID_ARG_TYPE:K}=J,Z=(B,$)=>{if(typeof B!=="object"||!("aborted"in B))throw new K($,"AbortSignal",B)};function Y(B){return!!(B&&typeof B.pipe==="function")}Q.exports.addAbortSignal=function B($,z){if(Z($,"signal"),!Y(z))throw new K("stream","stream.Stream",z);return Q.exports.addAbortSignalNoValidate($,z)},Q.exports.addAbortSignalNoValidate=function(B,$){if(typeof B!=="object"||!("aborted"in B))return $;const z=()=>{$.destroy(new X(void 0,{cause:B.reason}))};if(B.aborted)z();else B.addEventListener("abort",z),H($,()=>B.removeEventListener("abort",z));return $}}}),JQ=cq({"node_modules/readable-stream/lib/internal/streams/state.js"(q,Q){var{MathFloor:X,NumberIsInteger:J}=Dq(),{ERR_INVALID_ARG_VALUE:H}=sq().codes;function K(B,$,z){return B.highWaterMark!=null?B.highWaterMark:$?B[z]:null}function Z(B){return B?16:16384}function Y(B,$,z,V){const U=K($,V,z);if(U!=null){if(!J(U)||U<0){const W=V?`options.${z}`:"options.highWaterMark";throw new H(W,U)}return X(U)}return Z(B.objectMode)}Q.exports={getHighWaterMark:Y,getDefaultHighWaterMark:Z}}}),HQ=cq({"node_modules/readable-stream/lib/internal/streams/from.js"(q,Q){var{PromisePrototypeThen:X,SymbolAsyncIterator:J,SymbolIterator:H}=Dq(),{ERR_INVALID_ARG_TYPE:K,ERR_STREAM_NULL_VALUES:Z}=sq().codes;function Y(B,$,z){let V;if(typeof $==="string"||$ instanceof Buffer)return new B({objectMode:!0,...z,read(){this.push($),this.push(null)}});let U;if($&&$[J])U=!0,V=$[J]();else if($&&$[H])U=!1,V=$[H]();else throw new K("iterable",["Iterable"],$);const W=new B({objectMode:!0,highWaterMark:1,...z});let G=!1;W._read=function(){if(!G)G=!0,F()},W._destroy=function(L,j){X(M(L),()=>Aq(j,L),(N)=>Aq(j,N||L))};async function M(L){const j=L!==void 0&&L!==null,N=typeof V.throw==="function";if(j&&N){const{value:P,done:E}=await V.throw(L);if(await P,E)return}if(typeof V.return==="function"){const{value:P}=await V.return();await P}}async function F(){for(;;){try{const{value:L,done:j}=U?await V.next():V.next();if(j)W.push(null);else{const N=L&&typeof L.then==="function"?await L:L;if(N===null)throw G=!1,new Z;else if(W.push(N))continue;else G=!1}}catch(L){W.destroy(L)}break}}return W}Q.exports=Y}}),KQ,ZQ=cq({"node_modules/readable-stream/lib/internal/streams/readable.js"(q,Q){var{ArrayPrototypeIndexOf:X,NumberIsInteger:J,NumberIsNaN:H,NumberParseInt:K,ObjectDefineProperties:Z,ObjectKeys:Y,ObjectSetPrototypeOf:B,Promise:$,SafeSet:z,SymbolAsyncIterator:V,Symbol:U}=Dq(),W=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{EventEmitter:G}=_q("bun:events_native"),{Stream:M,prependListener:F}=QQ();function L(Xq){if(!(this instanceof L))return new L(Xq);const Jq=this instanceof vq();if(this._readableState=new W(Xq,this,Jq),Xq){const{read:Hq,destroy:Kq,construct:Zq,signal:Yq}=Xq;if(typeof Hq==="function")this._read=Hq;if(typeof Kq==="function")this._destroy=Kq;if(typeof Zq==="function")this._construct=Zq;if(Yq&&!Jq)P(Yq,this)}M.call(this,Xq),C.construct(this,()=>{if(this._readableState.needReadable)O(this,this._readableState)})}B(L.prototype,M.prototype),B(L,M),L.prototype.on=function(Xq,Jq){const Hq=M.prototype.on.call(this,Xq,Jq),Kq=this._readableState;if(Xq==="data")if(Kq.readableListening=this.listenerCount("readable")>0,Kq.flowing!==!1)Iq&&Eq("in flowing mode!",this.__id),this.resume();else Iq&&Eq("in readable mode!",this.__id);else if(Xq==="readable"){if(Iq&&Eq("readable listener added!",this.__id),!Kq.endEmitted&&!Kq.readableListening){if(Kq.readableListening=Kq.needReadable=!0,Kq.flowing=!1,Kq.emittedReadable=!1,Iq&&Eq("on readable - state.length, reading, emittedReadable",Kq.length,Kq.reading,Kq.emittedReadable,this.__id),Kq.length)_(this,Kq);else if(!Kq.reading)Aq(n,this)}else if(Kq.endEmitted)Iq&&Eq("end already emitted...",this.__id)}return Hq};class j extends L{#q;#Q;#X;#J;constructor(Xq,Jq){const{objectMode:Hq,highWaterMark:Kq,encoding:Zq,signal:Yq}=Xq;super({objectMode:Hq,highWaterMark:Kq,encoding:Zq,signal:Yq});this.#X=[],this.#q=void 0,this.#J=Jq,this.#Q=!1}#H(){var Xq=this.#X,Jq=0,Hq=Xq.length;for(;Jq0)this.#X=[];return!1}#K(Xq){Xq.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){Iq&&Eq("ReadableFromWeb _read()",this.__id);var Xq=this.#J,Jq=this.#q;if(Xq)Jq=this.#q=Xq.getReader(),this.#J=void 0;else if(this.#H())return;var Hq;try{do{var Kq=!1,Zq;const Yq=Jq.readMany();if(Oq(Yq)){if({done:Kq,value:Zq}=await Yq,this.#Q){this.#X.push(...Zq);return}}else({done:Kq,value:Zq}=Yq);if(Kq){this.#K(Jq);return}if(!this.push(Zq[0])){this.#X=Zq.slice(1);return}for(let Bq=1,$q=Zq.length;Bq<$q;Bq++)if(!this.push(Zq[Bq])){this.#X=Zq.slice(Bq+1);return}}while(!this.#Q)}catch(Yq){Hq=Yq}finally{if(Hq)throw Hq}}_destroy(Xq,Jq){if(!this.#Q){var Hq=this.#q;if(Hq)this.#q=void 0,Hq.cancel(Xq).finally(()=>{this.#Q=!0,Jq(Xq)});return}try{Jq(Xq)}catch(Kq){globalThis.reportError(Kq)}}}function N(Xq,Jq={}){if(!dq(Xq))throw new w("readableStream","ReadableStream",Xq);k(Jq,"options");const{highWaterMark:Hq,encoding:Kq,objectMode:Zq=!1,signal:Yq}=Jq;if(Kq!==void 0&&!Buffer.isEncoding(Kq))throw new oq(Kq,"options.encoding");return lq(Zq,"options.objectMode"),NQ(L,Xq,Jq)||new j({highWaterMark:Hq,encoding:Kq,objectMode:Zq,signal:Yq},Xq)}Q.exports=L,KQ=j;var{addAbortSignal:P}=XQ(),E=tq();const{maybeReadMore:I,resume:T,emitReadable:A,onEofChunk:x}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function O(Xq,Jq){process.nextTick(I,Xq,Jq)}function _(Xq,Jq){Iq&&Eq("NativeReadable - emitReadable",Xq.__id),A(Xq,Jq)}var C=qQ(),{aggregateTwoErrors:D,codes:{ERR_INVALID_ARG_TYPE:w,ERR_METHOD_NOT_IMPLEMENTED:v,ERR_OUT_OF_RANGE:R,ERR_STREAM_PUSH_AFTER_EOF:S,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:g}}=sq(),{validateObject:k}=aq(),{StringDecoder:f}=_q("string_decoder"),y=HQ(),h=()=>{},{errorOrDestroy:p}=C;L.prototype.destroy=C.destroy,L.prototype._undestroy=C.undestroy,L.prototype._destroy=function(Xq,Jq){Jq(Xq)},L.prototype[G.captureRejectionSymbol]=function(Xq){this.destroy(Xq)},L.prototype.push=function(Xq,Jq){return u(this,Xq,Jq,!1)},L.prototype.unshift=function(Xq,Jq){return u(this,Xq,Jq,!0)};function u(Xq,Jq,Hq,Kq){Iq&&Eq("readableAddChunk",Jq,Xq.__id);const Zq=Xq._readableState;let Yq;if(!Zq.objectMode){if(typeof Jq==="string"){if(Hq=Hq||Zq.defaultEncoding,Zq.encoding!==Hq)if(Kq&&Zq.encoding)Jq=Buffer.from(Jq,Hq).toString(Zq.encoding);else Jq=Buffer.from(Jq,Hq),Hq=""}else if(Jq instanceof Buffer)Hq="";else if(M._isUint8Array(Jq)){if(Kq||!Zq.decoder)Jq=M._uint8ArrayToBuffer(Jq);Hq=""}else if(Jq!=null)Yq=new w("chunk",["string","Buffer","Uint8Array"],Jq)}if(Yq)p(Xq,Yq);else if(Jq===null)Zq.reading=!1,x(Xq,Zq);else if(Zq.objectMode||Jq&&Jq.length>0)if(Kq)if(Zq.endEmitted)p(Xq,new g);else if(Zq.destroyed||Zq.errored)return!1;else b(Xq,Zq,Jq,!0);else if(Zq.ended)p(Xq,new S);else if(Zq.destroyed||Zq.errored)return!1;else if(Zq.reading=!1,Zq.decoder&&!Hq)if(Jq=Zq.decoder.write(Jq),Zq.objectMode||Jq.length!==0)b(Xq,Zq,Jq,!1);else O(Xq,Zq);else b(Xq,Zq,Jq,!1);else if(!Kq)Zq.reading=!1,O(Xq,Zq);return!Zq.ended&&(Zq.length0){if(Jq.multiAwaitDrain)Jq.awaitDrainWriters.clear();else Jq.awaitDrainWriters=null;Jq.dataEmitted=!0,Xq.emit("data",Hq)}else{if(Jq.length+=Jq.objectMode?1:Hq.length,Kq)Jq.buffer.unshift(Hq);else Jq.buffer.push(Hq);if(Iq&&Eq("needReadable @ addChunk",Jq.needReadable,Xq.__id),Jq.needReadable)_(Xq,Jq)}O(Xq,Jq)}L.prototype.isPaused=function(){const Xq=this._readableState;return Xq.paused===!0||Xq.flowing===!1},L.prototype.setEncoding=function(Xq){const Jq=new f(Xq);this._readableState.decoder=Jq,this._readableState.encoding=this._readableState.decoder.encoding;const Hq=this._readableState.buffer;let Kq="";for(let Zq=Hq.length;Zq>0;Zq--)Kq+=Jq.write(Hq.shift());if(Kq!=="")Hq.push(Kq);return this._readableState.length=Kq.length,this};var m=1073741824;function c(Xq){if(Xq>m)throw new R("size","<= 1GiB",Xq);else Xq--,Xq|=Xq>>>1,Xq|=Xq>>>2,Xq|=Xq>>>4,Xq|=Xq>>>8,Xq|=Xq>>>16,Xq++;return Xq}function d(Xq,Jq){if(Xq<=0||Jq.length===0&&Jq.ended)return 0;if(Jq.objectMode)return 1;if(H(Xq)){if(Jq.flowing&&Jq.length)return Jq.buffer.first().length;return Jq.length}if(Xq<=Jq.length)return Xq;return Jq.ended?Jq.length:0}L.prototype.read=function(Xq){if(Iq&&Eq("read - n =",Xq,this.__id),!J(Xq))Xq=K(Xq,10);const Jq=this._readableState,Hq=Xq;if(Xq>Jq.highWaterMark)Jq.highWaterMark=c(Xq);if(Xq!==0)Jq.emittedReadable=!1;if(Xq===0&&Jq.needReadable&&((Jq.highWaterMark!==0?Jq.length>=Jq.highWaterMark:Jq.length>0)||Jq.ended)){if(Iq&&Eq("read: emitReadable or endReadable",Jq.length,Jq.ended,this.__id),Jq.length===0&&Jq.ended)r(this);else _(this,Jq);return null}if(Xq=d(Xq,Jq),Xq===0&&Jq.ended){if(Iq&&Eq("read: calling endReadable if length 0 -- length, state.ended",Jq.length,Jq.ended,this.__id),Jq.length===0)r(this);return null}let Kq=Jq.needReadable;if(Iq&&Eq("need readable",Kq,this.__id),Jq.length===0||Jq.length-Xq0)Yq=a(Xq,Jq);else Yq=null;if(Iq&&Eq("ret @ read",Yq,this.__id),Yq===null)Jq.needReadable=Jq.length<=Jq.highWaterMark,Iq&&Eq("state.length while ret = null",Jq.length,this.__id),Xq=0;else if(Jq.length-=Xq,Jq.multiAwaitDrain)Jq.awaitDrainWriters.clear();else Jq.awaitDrainWriters=null;if(Jq.length===0){if(!Jq.ended)Jq.needReadable=!0;if(Hq!==Xq&&Jq.ended)r(this)}if(Yq!==null&&!Jq.errorEmitted&&!Jq.closeEmitted)Jq.dataEmitted=!0,this.emit("data",Yq);return Yq},L.prototype._read=function(Xq){throw new v("_read()")},L.prototype.pipe=function(Xq,Jq){const Hq=this,Kq=this._readableState;if(Kq.pipes.length===1){if(!Kq.multiAwaitDrain)Kq.multiAwaitDrain=!0,Kq.awaitDrainWriters=new z(Kq.awaitDrainWriters?[Kq.awaitDrainWriters]:[])}Kq.pipes.push(Xq),Iq&&Eq("pipe count=%d opts=%j",Kq.pipes.length,Jq,Hq.__id);const Yq=(!Jq||Jq.end!==!1)&&Xq!==process.stdout&&Xq!==process.stderr?$q:jq;if(Kq.endEmitted)Aq(Yq);else Hq.once("end",Yq);Xq.on("unpipe",Bq);function Bq(Nq,Pq){if(Iq&&Eq("onunpipe",Hq.__id),Nq===Hq){if(Pq&&Pq.hasUnpiped===!1)Pq.hasUnpiped=!0,Uq()}}function $q(){Iq&&Eq("onend",Hq.__id),Xq.end()}let zq,Vq=!1;function Uq(){if(Iq&&Eq("cleanup",Hq.__id),Xq.removeListener("close",Fq),Xq.removeListener("finish",Lq),zq)Xq.removeListener("drain",zq);if(Xq.removeListener("error",Mq),Xq.removeListener("unpipe",Bq),Hq.removeListener("end",$q),Hq.removeListener("end",jq),Hq.removeListener("data",Gq),Vq=!0,zq&&Kq.awaitDrainWriters&&(!Xq._writableState||Xq._writableState.needDrain))zq()}function Wq(){if(!Vq){if(Kq.pipes.length===1&&Kq.pipes[0]===Xq)Iq&&Eq("false write response, pause",0,Hq.__id),Kq.awaitDrainWriters=Xq,Kq.multiAwaitDrain=!1;else if(Kq.pipes.length>1&&Kq.pipes.includes(Xq))Iq&&Eq("false write response, pause",Kq.awaitDrainWriters.size,Hq.__id),Kq.awaitDrainWriters.add(Xq);Hq.pause()}if(!zq)zq=l(Hq,Xq),Xq.on("drain",zq)}Hq.on("data",Gq);function Gq(Nq){Iq&&Eq("ondata",Hq.__id);const Pq=Xq.write(Nq);if(Iq&&Eq("dest.write",Pq,Hq.__id),Pq===!1)Wq()}function Mq(Nq){if(Eq("onerror",Nq),jq(),Xq.removeListener("error",Mq),Xq.listenerCount("error")===0){const Pq=Xq._writableState||Xq._readableState;if(Pq&&!Pq.errorEmitted)p(Xq,Nq);else Xq.emit("error",Nq)}}F(Xq,"error",Mq);function Fq(){Xq.removeListener("finish",Lq),jq()}Xq.once("close",Fq);function Lq(){Eq("onfinish"),Xq.removeListener("close",Fq),jq()}Xq.once("finish",Lq);function jq(){Eq("unpipe"),Hq.unpipe(Xq)}if(Xq.emit("pipe",Hq),Xq.writableNeedDrain===!0){if(Kq.flowing)Wq()}else if(!Kq.flowing)Eq("pipe resume"),Hq.resume();return Xq};function l(Xq,Jq){return function Hq(){const Kq=Xq._readableState;if(Kq.awaitDrainWriters===Jq)Eq("pipeOnDrain",1),Kq.awaitDrainWriters=null;else if(Kq.multiAwaitDrain)Eq("pipeOnDrain",Kq.awaitDrainWriters.size),Kq.awaitDrainWriters.delete(Jq);if((!Kq.awaitDrainWriters||Kq.awaitDrainWriters.size===0)&&Xq.listenerCount("data"))Xq.resume()}}L.prototype.unpipe=function(Xq){const Jq=this._readableState,Hq={hasUnpiped:!1};if(Jq.pipes.length===0)return this;if(!Xq){const Zq=Jq.pipes;Jq.pipes=[],this.pause();for(let Yq=0;Yq0,Jq.resumeScheduled&&Jq.paused===!1)Jq.flowing=!0;else if(Xq.listenerCount("data")>0)Xq.resume();else if(!Jq.readableListening)Jq.flowing=null}function n(Xq){Iq&&Eq("on readable nextTick, calling read(0)",Xq.__id),Xq.read(0)}L.prototype.resume=function(){const Xq=this._readableState;if(!Xq.flowing)Iq&&Eq("resume",this.__id),Xq.flowing=!Xq.readableListening,T(this,Xq);return Xq.paused=!1,this},L.prototype.pause=function(){if(Iq&&Eq("call pause flowing=%j",this._readableState.flowing,this.__id),this._readableState.flowing!==!1)Iq&&Eq("pause",this.__id),this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this},L.prototype.wrap=function(Xq){let Jq=!1;Xq.on("data",(Kq)=>{if(!this.push(Kq)&&Xq.pause)Jq=!0,Xq.pause()}),Xq.on("end",()=>{this.push(null)}),Xq.on("error",(Kq)=>{p(this,Kq)}),Xq.on("close",()=>{this.destroy()}),Xq.on("destroy",()=>{this.destroy()}),this._read=()=>{if(Jq&&Xq.resume)Jq=!1,Xq.resume()};const Hq=Y(Xq);for(let Kq=1;Kq{Zq=Bq?D(Zq,Bq):null,Hq(),Hq=h});try{while(!0){const Bq=Xq.destroyed?null:Xq.read();if(Bq!==null)yield Bq;else if(Zq)throw Zq;else if(Zq===null)return;else await new $(Kq)}}catch(Bq){throw Zq=D(Zq,Bq),Zq}finally{if((Zq||(Jq===null||Jq===void 0?void 0:Jq.destroyOnReturn)!==!1)&&(Zq===void 0||Xq._readableState.autoDestroy))C.destroyer(Xq,null);else Xq.off("readable",Kq),Yq()}}Z(L.prototype,{readable:{get(){const Xq=this._readableState;return!!Xq&&Xq.readable!==!1&&!Xq.destroyed&&!Xq.errorEmitted&&!Xq.endEmitted},set(Xq){if(this._readableState)this._readableState.readable=!!Xq}},readableDidRead:{enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{enumerable:!1,get:function(){return this._readableState.flowing},set:function(Xq){if(this._readableState)this._readableState.flowing=Xq}},readableLength:{enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{get(){return this._readableState?this._readableState.closed:!1}},destroyed:{enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(Xq){if(!this._readableState)return;this._readableState.destroyed=Xq}},readableEnded:{enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),L._fromList=a;function a(Xq,Jq){if(Jq.length===0)return null;let Hq;if(Jq.objectMode)Hq=Jq.buffer.shift();else if(!Xq||Xq>=Jq.length){if(Jq.decoder)Hq=Jq.buffer.join("");else if(Jq.buffer.length===1)Hq=Jq.buffer.first();else Hq=Jq.buffer.concat(Jq.length);Jq.buffer.clear()}else Hq=Jq.buffer.consume(Xq,Jq.decoder);return Hq}function r(Xq){const Jq=Xq._readableState;if(Iq&&Eq("endEmitted @ endReadable",Jq.endEmitted,Xq.__id),!Jq.endEmitted)Jq.ended=!0,Aq(t,Jq,Xq)}function t(Xq,Jq){if(Iq&&Eq("endReadableNT -- endEmitted, state.length",Xq.endEmitted,Xq.length,Jq.__id),!Xq.errored&&!Xq.closeEmitted&&!Xq.endEmitted&&Xq.length===0){if(Xq.endEmitted=!0,Jq.emit("end"),Iq&&Eq("end emitted @ endReadableNT",Jq.__id),Jq.writable&&Jq.allowHalfOpen===!1)Aq(e,Jq);else if(Xq.autoDestroy){const Hq=Jq._writableState;if(!Hq||Hq.autoDestroy&&(Hq.finished||Hq.writable===!1))Jq.destroy()}}}function e(Xq){if(Xq.writable&&!Xq.writableEnded&&!Xq.destroyed)Xq.end()}L.from=function(Xq,Jq){return y(L,Xq,Jq)};var qq={newStreamReadableFromReadableStream:N};function Qq(){if(qq===void 0)qq={};return qq}L.fromWeb=function(Xq,Jq){return Qq().newStreamReadableFromReadableStream(Xq,Jq)},L.toWeb=function(Xq){return Qq().newReadableStreamFromStreamReadable(Xq)},L.wrap=function(Xq,Jq){var Hq,Kq;return new L({objectMode:(Hq=(Kq=Xq.readableObjectMode)!==null&&Kq!==void 0?Kq:Xq.objectMode)!==null&&Hq!==void 0?Hq:!0,...Jq,destroy(Zq,Yq){C.destroyer(Xq,Zq),Yq(Zq)}}).wrap(Xq)}}}),YQ=cq({"node_modules/readable-stream/lib/internal/streams/writable.js"(q,Q){var{ArrayPrototypeSlice:X,Error:J,FunctionPrototypeSymbolHasInstance:H,ObjectDefineProperty:K,ObjectDefineProperties:Z,ObjectSetPrototypeOf:Y,StringPrototypeToLowerCase:B,Symbol:$,SymbolHasInstance:z}=Dq(),{EventEmitter:V}=_q("bun:events_native"),U=QQ().Stream,W=qQ(),{addAbortSignal:G}=XQ(),{getHighWaterMark:M,getDefaultHighWaterMark:F}=JQ(),{ERR_INVALID_ARG_TYPE:L,ERR_METHOD_NOT_IMPLEMENTED:j,ERR_MULTIPLE_CALLBACK:N,ERR_STREAM_CANNOT_PIPE:P,ERR_STREAM_DESTROYED:E,ERR_STREAM_ALREADY_FINISHED:I,ERR_STREAM_NULL_VALUES:T,ERR_STREAM_WRITE_AFTER_END:A,ERR_UNKNOWN_ENCODING:x}=sq().codes,{errorOrDestroy:O}=W;function _(s={}){const a=this instanceof vq();if(!a&&!H(_,this))return new _(s);if(this._writableState=new w(s,this,a),s){if(typeof s.write==="function")this._write=s.write;if(typeof s.writev==="function")this._writev=s.writev;if(typeof s.destroy==="function")this._destroy=s.destroy;if(typeof s.final==="function")this._final=s.final;if(typeof s.construct==="function")this._construct=s.construct;if(s.signal)G(s.signal,this)}U.call(this,s),W.construct(this,()=>{const r=this._writableState;if(!r.writing)u(this,r);d(this,r)})}Y(_.prototype,U.prototype),Y(_,U),Q.exports=_;function C(){}var D=$("kOnFinished");function w(s,a,r){if(typeof r!=="boolean")r=a instanceof vq();if(this.objectMode=!!(s&&s.objectMode),r)this.objectMode=this.objectMode||!!(s&&s.writableObjectMode);this.highWaterMark=s?M(this,s,"writableHighWaterMark",r):F(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const t=!!(s&&s.decodeStrings===!1);this.decodeStrings=!t,this.defaultEncoding=s&&s.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=f.bind(void 0,a),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,v(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!s||s.emitClose!==!1,this.autoDestroy=!s||s.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[D]=[]}function v(s){s.buffered=[],s.bufferedIndex=0,s.allBuffers=!0,s.allNoop=!0}w.prototype.getBuffer=function s(){return X(this.buffered,this.bufferedIndex)},K(w.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),K(_,z,{value:function(s){if(H(this,s))return!0;if(this!==_)return!1;return s&&s._writableState instanceof w}}),_.prototype.pipe=function(){O(this,new P)};function R(s,a,r,t){const e=s._writableState;if(typeof r==="function")t=r,r=e.defaultEncoding;else{if(!r)r=e.defaultEncoding;else if(r!=="buffer"&&!Buffer.isEncoding(r))throw new x(r);if(typeof t!=="function")t=C}if(a===null)throw new T;else if(!e.objectMode)if(typeof a==="string"){if(e.decodeStrings!==!1)a=Buffer.from(a,r),r="buffer"}else if(a instanceof Buffer)r="buffer";else if(U._isUint8Array(a))a=U._uint8ArrayToBuffer(a),r="buffer";else throw new L("chunk",["string","Buffer","Uint8Array"],a);let qq;if(e.ending)qq=new A;else if(e.destroyed)qq=new E("write");if(qq)return Aq(t,qq),O(s,qq,!0),qq;return e.pendingcb++,S(s,e,a,r,t)}_.prototype.write=function(s,a,r){return R(this,s,a,r)===!0},_.prototype.cork=function(){this._writableState.corked++},_.prototype.uncork=function(){const s=this._writableState;if(s.corked){if(s.corked--,!s.writing)u(this,s)}},_.prototype.setDefaultEncoding=function s(a){if(typeof a==="string")a=B(a);if(!Buffer.isEncoding(a))throw new x(a);return this._writableState.defaultEncoding=a,this};function S(s,a,r,t,e){const qq=a.objectMode?1:r.length;a.length+=qq;const Qq=a.lengthr.bufferedIndex)u(s,r);if(t)if(r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===e)r.afterWriteTickInfo.count++;else r.afterWriteTickInfo={count:1,cb:e,stream:s,state:r},Aq(y,r.afterWriteTickInfo);else h(s,r,1,e)}}function y({stream:s,state:a,count:r,cb:t}){return a.afterWriteTickInfo=null,h(s,a,r,t)}function h(s,a,r,t){if(!a.ending&&!s.destroyed&&a.length===0&&a.needDrain)a.needDrain=!1,s.emit("drain");while(r-- >0)a.pendingcb--,t();if(a.destroyed)p(a);d(s,a)}function p(s){if(s.writing)return;for(let e=s.bufferedIndex;e1&&s._writev){a.pendingcb-=qq-1;const Xq=a.allNoop?C:(Hq)=>{for(let Kq=Qq;Kq256)r.splice(0,Qq),a.bufferedIndex=0;else a.bufferedIndex=Qq}a.bufferProcessing=!1}_.prototype._write=function(s,a,r){if(this._writev)this._writev([{chunk:s,encoding:a}],r);else throw new j("_write()")},_.prototype._writev=null,_.prototype.end=function(s,a,r,t=!1){const e=this._writableState;if(Iq&&Eq("end",e,this.__id),typeof s==="function")r=s,s=null,a=null;else if(typeof a==="function")r=a,a=null;let qq;if(s!==null&&s!==void 0){let Qq;if(!t)Qq=R(this,s,a);else Qq=this.write(s,a);if(Qq instanceof J)qq=Qq}if(e.corked)e.corked=1,this.uncork();if(qq)this.emit("error",qq);else if(!e.errored&&!e.ending)e.ending=!0,d(this,e,!0),e.ended=!0;else if(e.finished)qq=new I("end");else if(e.destroyed)qq=new E("end");if(typeof r==="function")if(qq||e.finished)Aq(r,qq);else e[D].push(r);return this};function b(s,a){var r=s.ending&&!s.destroyed&&s.constructed&&s.length===0&&!s.errored&&s.buffered.length===0&&!s.finished&&!s.writing&&!s.errorEmitted&&!s.closeEmitted;return Eq("needFinish",r,a),r}function m(s,a){let r=!1;function t(e){if(r){O(s,e!==null&&e!==void 0?e:N());return}if(r=!0,a.pendingcb--,e){const qq=a[D].splice(0);for(let Qq=0;Qq{if(b(e))l(t,e);else e.pendingcb--},s,a);else if(b(a))a.pendingcb++,l(s,a)}}function l(s,a){a.pendingcb--,a.finished=!0;const r=a[D].splice(0);for(let t=0;t{if(y!=null)throw new W("nully","body",y)},(y)=>{G(k,y)});return k=new T({objectMode:!0,readable:!1,write:v,final(y){R(async()=>{try{await f,Aq(y,null)}catch(h){Aq(y,h)}})},destroy:S})}throw new W("Iterable, AsyncIterable or AsyncFunction",C,w)}if(P(_))return O(_.arrayBuffer());if(K(_))return j(T,_,{objectMode:!0,writable:!1});if(typeof(_===null||_===void 0?void 0:_.writable)==="object"||typeof(_===null||_===void 0?void 0:_.readable)==="object"){const w=_!==null&&_!==void 0&&_.readable?Y(_===null||_===void 0?void 0:_.readable)?_===null||_===void 0?void 0:_.readable:O(_.readable):void 0,v=_!==null&&_!==void 0&&_.writable?B(_===null||_===void 0?void 0:_.writable)?_===null||_===void 0?void 0:_.writable:O(_.writable):void 0;return x({readable:w,writable:v})}const D=_===null||_===void 0?void 0:_.then;if(typeof D==="function"){let w;return I(D,_,(v)=>{if(v!=null)w.push(v);w.push(null)},(v)=>{G(w,v)}),w=new T({objectMode:!0,writable:!1,read(){}})}throw new U(C,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],_)};function A(O){let{promise:_,resolve:C}=L();const D=new E,w=D.signal;return{value:O(async function*(){while(!0){const R=_;_=null;const{chunk:S,done:g,cb:k}=await R;if(Aq(k),g)return;if(w.aborted)throw new V(void 0,{cause:w.reason});({promise:_,resolve:C}=L()),yield S}}(),{signal:w}),write(R,S,g){const k=C;C=null,k({chunk:R,done:!1,cb:g})},final(R){const S=C;C=null,S({done:!0,cb:R})},destroy(R,S){D.abort(),S(R)}}}function x(O){const _=O.readable&&typeof O.readable.read!=="function"?F.wrap(O.readable):O.readable,C=O.writable;let D=!!J(_),w=!!H(C),v,R,S,g,k;function f(y){const h=g;if(g=null,h)h(y);else if(y)k.destroy(y);else if(!D&&!w)k.destroy()}if(k=new T({readableObjectMode:!!(_!==null&&_!==void 0&&_.readableObjectMode),writableObjectMode:!!(C!==null&&C!==void 0&&C.writableObjectMode),readable:D,writable:w}),w)z(C,(y)=>{if(w=!1,y)G(_,y);f(y)}),k._write=function(y,h,p){if(C.write(y,h))p();else v=p},k._final=function(y){C.end(),R=y},C.on("drain",function(){if(v){const y=v;v=null,y()}}),C.on("finish",function(){if(R){const y=R;R=null,y()}});if(D)z(_,(y)=>{if(D=!1,y)G(_,y);f(y)}),_.on("readable",function(){if(S){const y=S;S=null,y()}}),_.on("end",function(){k.push(null)}),k._read=function(){while(!0){const y=_.read();if(y===null){S=k._read;return}if(!k.push(y))return}};return k._destroy=function(y,h){if(!y&&g!==null)y=new V;if(S=null,v=null,R=null,g===null)h(y);else g=h,G(C,y),G(_,y)},k}}}),vq=cq({"node_modules/readable-stream/lib/internal/streams/duplex.js"(q,Q){var{ObjectDefineProperties:X,ObjectGetOwnPropertyDescriptor:J,ObjectKeys:H,ObjectSetPrototypeOf:K}=Dq(),Z=ZQ();function Y(U){if(!(this instanceof Y))return new Y(U);if(Z.call(this,U),Tq.call(this,U),U){if(this.allowHalfOpen=U.allowHalfOpen!==!1,U.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(U.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}Q.exports=Y,K(Y.prototype,Z.prototype),K(Y,Z);for(var B in Tq.prototype)if(!Y.prototype[B])Y.prototype[B]=Tq.prototype[B];X(Y.prototype,{writable:J(Tq.prototype,"writable"),writableHighWaterMark:J(Tq.prototype,"writableHighWaterMark"),writableObjectMode:J(Tq.prototype,"writableObjectMode"),writableBuffer:J(Tq.prototype,"writableBuffer"),writableLength:J(Tq.prototype,"writableLength"),writableFinished:J(Tq.prototype,"writableFinished"),writableCorked:J(Tq.prototype,"writableCorked"),writableEnded:J(Tq.prototype,"writableEnded"),writableNeedDrain:J(Tq.prototype,"writableNeedDrain"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(U){if(this._readableState&&this._writableState)this._readableState.destroyed=U,this._writableState.destroyed=U}}});var $;function z(){if($===void 0)$={};return $}Y.fromWeb=function(U,W){return z().newStreamDuplexFromReadableWritablePair(U,W)},Y.toWeb=function(U){return z().newReadableWritablePairFromDuplex(U)};var V;Y.from=function(U){if(!V)V=BQ();return V(U,"body")}}}),$Q=cq({"node_modules/readable-stream/lib/internal/streams/transform.js"(q,Q){var{ObjectSetPrototypeOf:X,Symbol:J}=Dq(),{ERR_METHOD_NOT_IMPLEMENTED:H}=sq().codes,K=vq();function Z(z){if(!(this instanceof Z))return new Z(z);if(K.call(this,z),this._readableState.sync=!1,this[Y]=null,z){if(typeof z.transform==="function")this._transform=z.transform;if(typeof z.flush==="function")this._flush=z.flush}this.on("prefinish",$.bind(this))}X(Z.prototype,K.prototype),X(Z,K),Q.exports=Z;var Y=J("kCallback");function B(z){if(typeof this._flush==="function"&&!this.destroyed)this._flush((V,U)=>{if(V){if(z)z(V);else this.destroy(V);return}if(U!=null)this.push(U);if(this.push(null),z)z()});else if(this.push(null),z)z()}function $(){if(this._final!==B)B.call(this)}Z.prototype._final=B,Z.prototype._transform=function(z,V,U){throw new H("_transform()")},Z.prototype._write=function(z,V,U){const W=this._readableState,G=this._writableState,M=W.length;this._transform(z,V,(F,L)=>{if(F){U(F);return}if(L!=null)this.push(L);if(G.ended||M===W.length||W.length{k=!0});const f=K(R,{readable:S,writable:g},(y)=>{k=!y});return{destroy:(y)=>{if(k)return;k=!0,Y.destroyer(R,y||new W("pipe"))},cleanup:f}}function x(R){return M(R[R.length-1],"streams[stream.length - 1]"),R.pop()}function O(R){if(L(R))return R;else if(N(R))return _(R);throw new z("val",["Readable","Iterable","AsyncIterable"],R)}async function*_(R){if(!T)T=ZQ();yield*T.prototype[H].call(R)}async function C(R,S,g,{end:k}){let f,y=null;const h=(b)=>{if(b)f=b;if(y){const m=y;y=null,m()}},p=()=>new J((b,m)=>{if(f)m(f);else y=()=>{if(f)m(f);else b()}});S.on("drain",h);const u=K(S,{readable:!1},h);try{if(S.writableNeedDrain)await p();for await(let b of R)if(!S.write(b))await p();if(k)S.end();await p(),g()}catch(b){g(f!==b?$(f,b):b)}finally{u(),S.off("drain",h)}}function D(...R){return w(R,Z(x(R)))}function w(R,S,g){if(R.length===1&&X(R[0]))R=R[0];if(R.length<2)throw new U("streams");const k=new E,f=k.signal,y=g===null||g===void 0?void 0:g.signal,h=[];F(y,"options.signal");function p(){l(new G)}y===null||y===void 0||y.addEventListener("abort",p);let u,b;const m=[];let c=0;function d(o){l(o,--c===0)}function l(o,s){if(o&&(!u||u.code==="ERR_STREAM_PREMATURE_CLOSE"))u=o;if(!u&&!s)return;while(m.length)m.shift()(u);if(y===null||y===void 0||y.removeEventListener("abort",p),k.abort(),s){if(!u)h.forEach((a)=>a());Aq(S,u,b)}}let i;for(let o=0;o0,t=a||(g===null||g===void 0?void 0:g.end)!==!1,e=o===R.length-1;if(P(s)){let qq=function(Qq){if(Qq&&Qq.name!=="AbortError"&&Qq.code!=="ERR_STREAM_PREMATURE_CLOSE")d(Qq)};if(t){const{destroy:Qq,cleanup:Xq}=A(s,a,r);if(m.push(Qq),j(s)&&e)h.push(Xq)}if(s.on("error",qq),j(s)&&e)h.push(()=>{s.removeListener("error",qq)})}if(o===0)if(typeof s==="function"){if(i=s({signal:f}),!L(i))throw new V("Iterable, AsyncIterable or Stream","source",i)}else if(L(s)||N(s))i=s;else i=B.from(s);else if(typeof s==="function")if(i=O(i),i=s(i,{signal:f}),a){if(!L(i,!0))throw new V("AsyncIterable",`transform[${o-1}]`,i)}else{var n;if(!I)I=zQ();const qq=new I({objectMode:!0}),Qq=(n=i)===null||n===void 0?void 0:n.then;if(typeof Qq==="function")c++,Qq.call(i,(Hq)=>{if(b=Hq,Hq!=null)qq.write(Hq);if(t)qq.end();Aq(d)},(Hq)=>{qq.destroy(Hq),Aq(d,Hq)});else if(L(i,!0))c++,C(i,qq,d,{end:t});else throw new V("AsyncIterable or Promise","destination",i);i=qq;const{destroy:Xq,cleanup:Jq}=A(i,!1,!0);if(m.push(Xq),e)h.push(Jq)}else if(P(s)){if(N(i)){c+=2;const qq=v(i,s,d,{end:t});if(j(s)&&e)h.push(qq)}else if(L(i))c++,C(i,s,d,{end:t});else throw new z("val",["Readable","Iterable","AsyncIterable"],i);i=s}else i=B.from(s)}if(f!==null&&f!==void 0&&f.aborted||y!==null&&y!==void 0&&y.aborted)Aq(p);return i}function v(R,S,g,{end:k}){if(R.pipe(S,{end:k}),k)R.once("end",()=>S.end());else g();return K(R,{readable:!0,writable:!1},(f)=>{const y=R._readableState;if(f&&f.code==="ERR_STREAM_PREMATURE_CLOSE"&&y&&y.ended&&!y.errored&&!y.errorEmitted)R.once("end",g).once("error",g);else g(f)}),K(S,{readable:!1,writable:!0},g)}Q.exports={pipelineImpl:w,pipeline:D}}}),UQ=cq({"node_modules/readable-stream/lib/internal/streams/compose.js"(q,Q){var{pipeline:X}=VQ(),J=vq(),{destroyer:H}=qQ(),{isNodeStream:K,isReadable:Z,isWritable:Y}=rq(),{AbortError:B,codes:{ERR_INVALID_ARG_VALUE:$,ERR_MISSING_ARGS:z}}=sq();Q.exports=function V(...U){if(U.length===0)throw new z("streams");if(U.length===1)return J.from(U[0]);const W=[...U];if(typeof U[0]==="function")U[0]=J.from(U[0]);if(typeof U[U.length-1]==="function"){const A=U.length-1;U[A]=J.from(U[A])}for(let A=0;A0&&!Y(U[A]))throw new $(`streams[${A}]`,W[A],"must be writable")}let G,M,F,L,j;function N(A){const x=L;if(L=null,x)x(A);else if(A)j.destroy(A);else if(!T&&!I)j.destroy()}const P=U[0],E=X(U,N),I=!!Y(P),T=!!Z(E);if(j=new J({writableObjectMode:!!(P!==null&&P!==void 0&&P.writableObjectMode),readableObjectMode:!!(E!==null&&E!==void 0&&E.writableObjectMode),writable:I,readable:T}),I)j._write=function(A,x,O){if(P.write(A,x))O();else G=O},j._final=function(A){P.end(),M=A},P.on("drain",function(){if(G){const A=G;G=null,A()}}),E.on("finish",function(){if(M){const A=M;M=null,A()}});if(T)E.on("readable",function(){if(F){const A=F;F=null,A()}}),E.on("end",function(){j.push(null)}),j._read=function(){while(!0){const A=E.read();if(A===null){F=j._read;return}if(!j.push(A))return}};return j._destroy=function(A,x){if(!A&&L!==null)A=new B;if(F=null,G=null,M=null,L===null)x(A);else L=x,H(E,A)},j}}}),WQ=cq({"node_modules/readable-stream/lib/stream/promises.js"(q,Q){var{ArrayPrototypePop:X,Promise:J}=Dq(),{isIterable:H,isNodeStream:K}=rq(),{pipelineImpl:Z}=VQ(),{finished:Y}=tq();function B(...$){return new J((z,V)=>{let U,W;const G=$[$.length-1];if(G&&typeof G==="object"&&!K(G)&&!H(G)){const M=X($);U=M.signal,W=M.end}Z($,(M,F)=>{if(M)V(M);else z(F)},{signal:U,end:W})})}Q.exports={finished:Y,pipeline:B}}}),GQ=cq({"node_modules/readable-stream/lib/stream.js"(q,Q){var{ObjectDefineProperty:X,ObjectKeys:J,ReflectApply:H}=Dq(),{promisify:{custom:K}}=wq(),{streamReturningOperators:Z,promiseReturningOperators:Y}=eq(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:B}}=sq(),$=UQ(),{pipeline:z}=VQ(),{destroyer:V}=qQ(),U=tq(),W=WQ(),G=rq(),M=Q.exports=QQ().Stream;M.isDisturbed=G.isDisturbed,M.isErrored=G.isErrored,M.isWritable=G.isWritable,M.isReadable=G.isReadable,M.Readable=ZQ();for(let L of J(Z)){let j=function(...P){if(new.target)throw B();return M.Readable.from(H(N,this,P))};const N=Z[L];X(j,"name",{value:N.name}),X(j,"length",{value:N.length}),X(M.Readable.prototype,L,{value:j,enumerable:!1,configurable:!0,writable:!0})}for(let L of J(Y)){let j=function(...P){if(new.target)throw B();return H(N,this,P)};const N=Y[L];X(j,"name",{value:N.name}),X(j,"length",{value:N.length}),X(M.Readable.prototype,L,{value:j,enumerable:!1,configurable:!0,writable:!0})}M.Writable=YQ(),M.Duplex=vq(),M.Transform=$Q(),M.PassThrough=zQ(),M.pipeline=z;var{addAbortSignal:F}=XQ();M.addAbortSignal=F,M.finished=U,M.destroy=V,M.compose=$,X(M,"promises",{configurable:!0,enumerable:!0,get(){return W}}),X(z,K,{enumerable:!0,get(){return W.pipeline}}),X(U,K,{enumerable:!0,get(){return W.finished}}),M.Stream=M,M._isUint8Array=function L(j){return j instanceof Uint8Array},M._uint8ArrayToBuffer=function L(j){return new Buffer(j.buffer,j.byteOffset,j.byteLength)}}}),MQ=cq({"node_modules/readable-stream/lib/ours/index.js"(q,Q){const X=GQ(),J=WQ(),H=X.Readable.destroy;Q.exports=X,Q.exports._uint8ArrayToBuffer=X._uint8ArrayToBuffer,Q.exports._isUint8Array=X._isUint8Array,Q.exports.isDisturbed=X.isDisturbed,Q.exports.isErrored=X.isErrored,Q.exports.isWritable=X.isWritable,Q.exports.isReadable=X.isReadable,Q.exports.Readable=X.Readable,Q.exports.Writable=X.Writable,Q.exports.Duplex=X.Duplex,Q.exports.Transform=X.Transform,Q.exports.PassThrough=X.PassThrough,Q.exports.addAbortSignal=X.addAbortSignal,Q.exports.finished=X.finished,Q.exports.destroy=X.destroy,Q.exports.destroy=H,Q.exports.pipeline=X.pipeline,Q.exports.compose=X.compose,Q.exports._getNativeReadableStreamPrototype=jQ,Q.exports.NativeWritable=pQ,xq.defineProperty(X,"promises",{configurable:!0,enumerable:!0,get(){return J}}),Q.exports.Stream=X.Stream,Q.exports.default=Q.exports}}),LQ={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0},Tq=YQ(),pQ=class q extends Tq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(Q,X={}){super(X);this._construct=this.#J,this._destroy=this.#K,this._final=this.#Z,this.#q=Q}#J(Q){this._writableState.constructed=!0,this.constructed=!0,Q()}#H(){if(typeof this.#q==="object")if(typeof this.#q.write==="function")this.#Q=this.#q;else throw new Error("Invalid FileSink");else this.#Q=Bun.file(this.#q).writer()}write(Q,X,J,H=this.#X){if(!H)return this.#X=!1,super.write(Q,X,J);if(!this.#Q)this.#H();var K=this.#Q,Z=K.write(Q);if(Oq(Z))return Z.then(()=>{this.emit("drain"),K.flush(!0)}),!1;if(K.flush(!0),J)J(null,Q.byteLength);return!0}end(Q,X,J,H=this.#X){return super.end(Q,X,J,H)}#K(Q,X){if(this._writableState.destroyed=!0,X)X(Q)}#Z(Q){if(this.#Q)this.#Q.end();if(Q)Q()}ref(){if(!this.#Q)this.#H();this.#Q.ref()}unref(){if(!this.#Q)return;this.#Q.unref()}},PQ=MQ();PQ[Symbol.for("CommonJS")]=0;PQ[Symbol.for("::bunternal::")]={_ReadableFromWeb:KQ};var lQ=PQ,EQ=PQ._uint8ArrayToBuffer,IQ=PQ._isUint8Array,TQ=PQ.isDisturbed,AQ=PQ.isErrored,xQ=PQ.isWritable,OQ=PQ.isReadable,_Q=PQ.Readable,Tq=PQ.Writable,CQ=PQ.Duplex,DQ=PQ.Transform,wQ=PQ.PassThrough,vQ=PQ.addAbortSignal,RQ=PQ.finished,SQ=PQ.destroy,gQ=PQ.pipeline,kQ=PQ.compose,fQ=PQ.Stream,yQ=PQ["eos"]=tq,hQ=PQ._getNativeReadableStreamPrototype,pQ=PQ.NativeWritable,uQ=fQ.promise;export{uQ as promises,gQ as pipeline,xQ as isWritable,OQ as isReadable,AQ as isErrored,TQ as isDisturbed,RQ as finished,yQ as eos,SQ as destroy,lQ as default,kQ as compose,vQ as addAbortSignal,EQ as _uint8ArrayToBuffer,IQ as _isUint8Array,hQ as _getNativeReadableStreamPrototype,Tq as Writable,DQ as Transform,fQ as Stream,_Q as Readable,wQ as PassThrough,pQ as NativeWritable,CQ as Duplex}; +import{EventEmitter as Pq} from"bun:events_native";import{StringDecoder as Sq} from"node:string_decoder";var cq=function(q){return typeof q==="object"&&q!==null&&q instanceof ReadableStream},dq=function(q,Q){if(typeof q!=="boolean")throw new iq(Q,"boolean",q)};var iq=function(q,Q,X){return new Error(`The argument '${q}' is invalid. Received '${X}' for type '${Q}'`)},nq=function(q,Q,X){return new Error(`The value '${Q}' is invalid for argument '${q}'. Reason: ${X}`)},FQ=function(q,Q){var[X,J,H,K,Z,B,Y]=globalThis[Symbol.for("Bun.lazy")](q),$=[!1],z=function(F,L,j,N){if(L>0){const A=j.subarray(0,L),E=j.subarray(L);if(A.byteLength>0)F.push(A);if(N)F.push(null);return E.byteLength>0?E:void 0}if(N)F.push(null);return j},V=function(F,L,j,N){if(L.byteLength>0)F.push(L);if(N)F.push(null);return j},U=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const W=new FinalizationRegistry((F)=>F&&Z(F)),G=512;var M=class F extends Q{#q;#Q=1;#X=!1;#J=void 0;#H;#K=!1;#Z=!U;#B;constructor(L,j={}){super(j);if(typeof j.highWaterMark==="number")this.#H=j.highWaterMark;else this.#H=262144;this.#q=L,this.#X=!1,this.#J=void 0,this.#K=!1,this.#B={},W.register(this,this.#q,this.#B)}_read(L){if(Aq&&Nq("NativeReadable._read",this.__id),this.#K){Aq&&Nq("pendingRead is true",this.__id);return}var j=this.#q;if(Aq&&Nq("ptr @ NativeReadable._read",j,this.__id),j===0){this.push(null);return}if(!this.#X)Aq&&Nq("NativeReadable not constructed yet",this.__id),this.#Y(j);return this.#V(this.#$(L),j)}#Y(L){this.#X=!0;const j=J(L,this.#H);if(Aq&&Nq("NativeReadable internal `start` result",j,this.__id),typeof j==="number"&&j>1)this.#Z=!0,Aq&&Nq("NativeReadable resized",this.__id),this.#H=Math.min(this.#H,j);if(Y){const N=Y(L);if(Aq&&Nq("NativeReadable drain result",N,this.__id),(N?.byteLength??0)>0)this.push(N)}}#$(L=this.#H){var j=this.#J;if(Aq&&Nq("chunk @ #getRemainingChunk",j,this.__id),j?.byteLength??0G?L:G;this.#J=j=new Buffer(N)}return j}push(L,j){return Aq&&Nq("NativeReadable push -- result, encoding",L,j,this.__id),super.push(...arguments)}#z(L,j,N){if(Aq&&Nq("result, isClosed @ #handleResult",L,N,this.__id),typeof L==="number"){if(L>=this.#H&&!this.#Z&&!N)this.#H*=2,this.#Z=!0;return z(this,L,j,N)}else if(typeof L==="boolean")return this.push(null),j?.byteLength??0>0?j:void 0;else if(ArrayBuffer.isView(L)){if(L.byteLength>=this.#H&&!this.#Z&&!N)this.#H*=2,this.#Z=!0,Aq&&Nq("Resized",this.__id);return V(this,L,j,N)}else throw Aq&&Nq("Unknown result type",L,this.__id),new Error("Invalid result from pull")}#V(L,j){Aq&&Nq("#internalRead()",this.__id),$[0]=!1;var N=X(j,L,$);if(xq(N))return this.#K=!0,N.then((A)=>{this.#K=!1,Aq&&Nq("pending no longerrrrrrrr (result returned from pull)",this.__id),this.#J=this.#z(A,L,$[0])},(A)=>{Aq&&Nq("error from pull",A,this.__id),errorOrDestroy(this,A)});else this.#J=this.#z(N,L,$[0])}_destroy(L,j){var N=this.#q;if(N===0){j(L);return}if(W.unregister(this.#B),this.#q=0,B)B(N,!1);Aq&&Nq("NativeReadable destroyed",this.__id),H(N,L),j(L)}ref(){var L=this.#q;if(L===0)return;if(this.#Q++===0)B(L,!0)}unref(){var L=this.#q;if(L===0)return;if(this.#Q--===1)B(L,!1)}};if(!B)M.prototype.ref=void 0,M.prototype.unref=void 0;return M},jQ=function(q,Q){return LQ[q]||=FQ(q,Q)},NQ=function(q,Q,X){if(!(Q&&typeof Q==="object"&&Q instanceof ReadableStream))return;const J=wq(Q);if(!J){Nq("no native readable stream");return}const{stream:H,data:K}=J;return new(jQ(K,q))(H,X)},{isPromise:xq,isCallable:Dq,direct:wq,Object:Tq}=globalThis[Symbol.for("Bun.lazy")]("primordials");globalThis.__IDS_TO_TRACK=process.env.DEBUG_TRACK_EE?.length?process.env.DEBUG_TRACK_EE.split(","):process.env.DEBUG_STREAMS?.length?process.env.DEBUG_STREAMS.split(","):null;var gq=!!process.env.DEBUG_TRACK_EE,Aq=!!(process.env.DEBUG||process.env.DEBUG_STREAMS||gq),Nq=Aq?globalThis.__IDS_TO_TRACK?(...q)=>{const Q=q[q.length-1];if(!globalThis.__IDS_TO_TRACK.includes(Q))return;console.log(`ID: ${Q}`,...q.slice(0,-1))}:(...q)=>console.log(...q.slice(0,-1)):()=>{},fq=Tq.create,kq=Tq.defineProperty,yq=Tq.getOwnPropertyDescriptor,hq=Tq.getOwnPropertyNames,pq=Tq.getPrototypeOf,uq=Tq.prototype.hasOwnProperty,bq=Tq.setPrototypeOf,mq=(q,Q)=>function X(){return Q||(0,q[hq(q)[0]])((Q={exports:{}}).exports,Q),Q.exports};var Iq=process.nextTick;var lq=Array.isArray,Oq=mq({"node_modules/readable-stream/lib/ours/primordials.js"(q,Q){Q.exports={ArrayIsArray(X){return Array.isArray(X)},ArrayPrototypeIncludes(X,J){return X.includes(J)},ArrayPrototypeIndexOf(X,J){return X.indexOf(J)},ArrayPrototypeJoin(X,J){return X.join(J)},ArrayPrototypeMap(X,J){return X.map(J)},ArrayPrototypePop(X,J){return X.pop(J)},ArrayPrototypePush(X,J){return X.push(J)},ArrayPrototypeSlice(X,J,H){return X.slice(J,H)},Error,FunctionPrototypeCall(X,J,...H){return X.call(J,...H)},FunctionPrototypeSymbolHasInstance(X,J){return Function.prototype[Symbol.hasInstance].call(X,J)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(X,J){return Tq.defineProperties(X,J)},ObjectDefineProperty(X,J,H){return Tq.defineProperty(X,J,H)},ObjectGetOwnPropertyDescriptor(X,J){return Tq.getOwnPropertyDescriptor(X,J)},ObjectKeys(X){return Tq.keys(X)},ObjectSetPrototypeOf(X,J){return Tq.setPrototypeOf(X,J)},Promise,PromisePrototypeCatch(X,J){return X.catch(J)},PromisePrototypeThen(X,J,H){return X.then(J,H)},PromiseReject(X){return Promise.reject(X)},ReflectApply:Reflect.apply,RegExpPrototypeTest(X,J){return X.test(J)},SafeSet:Set,String,StringPrototypeSlice(X,J,H){return X.slice(J,H)},StringPrototypeToLowerCase(X){return X.toLowerCase()},StringPrototypeToUpperCase(X){return X.toUpperCase()},StringPrototypeTrim(X){return X.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(X,J,H){return X.set(J,H)},Uint8Array}}}),_q=mq({"node_modules/readable-stream/lib/ours/util.js"(q,Q){var X=Tq.getPrototypeOf(async function(){}).constructor,J=typeof Blob!=="undefined"?function K(Z){return Z instanceof Blob}:function K(Z){return!1},H=class extends Error{constructor(K){if(!Array.isArray(K))throw new TypeError(`Expected input to be an Array, got ${typeof K}`);let Z="";for(let B=0;B{K=Y,Z=$}),resolve:K,reject:Z}},promisify(K){return new Promise((Z,B)=>{K((Y,...$)=>{if(Y)return B(Y);return Z(...$)})})},debuglog(){return function(){}},format(K,...Z){return K.replace(/%([sdifj])/g,function(...[B,Y]){const $=Z.shift();if(Y==="f")return $.toFixed(6);else if(Y==="j")return JSON.stringify($);else if(Y==="s"&&typeof $==="object")return`${$.constructor!==Tq?$.constructor.name:""} {}`.trim();else return $.toString()})},inspect(K){switch(typeof K){case"string":if(K.includes("'")){if(!K.includes('"'))return`"${K}"`;else if(!K.includes("`")&&!K.includes("${"))return`\`${K}\``}return`'${K}'`;case"number":if(isNaN(K))return"NaN";else if(Tq.is(K,-0))return String(K);return K;case"bigint":return`${String(K)}n`;case"boolean":case"undefined":return String(K);case"object":return"{}"}},types:{isAsyncFunction(K){return K instanceof X},isArrayBufferView(K){return ArrayBuffer.isView(K)}},isBlob:J},Q.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}}),oq=mq({"node_modules/readable-stream/lib/ours/errors.js"(q,Q){var{format:X,inspect:J,AggregateError:H}=_q(),K=globalThis.AggregateError||H,Z=Symbol("kIsNodeError"),B=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Y=/^([A-Z][a-z0-9]*)+$/,$="__node_internal_",z={};function V(j,N){if(!j)throw new z.ERR_INTERNAL_ASSERTION(N)}function U(j){let N="",A=j.length;const E=j[0]==="-"?1:0;for(;A>=E+4;A-=3)N=`_${j.slice(A-3,A)}${N}`;return`${j.slice(0,A)}${N}`}function W(j,N,A){if(typeof N==="function")return V(N.length<=A.length,`Code: ${j}; The provided arguments length (${A.length}) does not match the required ones (${N.length}).`),N(...A);const E=(N.match(/%[dfijoOs]/g)||[]).length;if(V(E===A.length,`Code: ${j}; The provided arguments length (${A.length}) does not match the required ones (${E}).`),A.length===0)return N;return X(N,...A)}function G(j,N,A){if(!A)A=Error;class E extends A{constructor(...I){super(W(j,N,I))}toString(){return`${this.name} [${j}]: ${this.message}`}}Tq.defineProperties(E.prototype,{name:{value:A.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${j}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),E.prototype.code=j,E.prototype[Z]=!0,z[j]=E}function M(j){const N=$+j.name;return Tq.defineProperty(j,"name",{value:N}),j}function F(j,N){if(j&&N&&j!==N){if(Array.isArray(N.errors))return N.errors.push(j),N;const A=new K([N,j],N.message);return A.code=N.code,A}return j||N}var L=class extends Error{constructor(j="The operation was aborted",N=void 0){if(N!==void 0&&typeof N!=="object")throw new z.ERR_INVALID_ARG_TYPE("options","Object",N);super(j,N);this.code="ABORT_ERR",this.name="AbortError"}};G("ERR_ASSERTION","%s",Error),G("ERR_INVALID_ARG_TYPE",(j,N,A)=>{if(V(typeof j==="string","'name' must be a string"),!Array.isArray(N))N=[N];let E="The ";if(j.endsWith(" argument"))E+=`${j} `;else E+=`"${j}" ${j.includes(".")?"property":"argument"} `;E+="must be ";const I=[],T=[],P=[];for(let O of N)if(V(typeof O==="string","All expected entries have to be of type string"),B.includes(O))I.push(O.toLowerCase());else if(Y.test(O))T.push(O);else V(O!=="object",'The value "object" should be written as "Object"'),P.push(O);if(T.length>0){const O=I.indexOf("object");if(O!==-1)I.splice(I,O,1),T.push("Object")}if(I.length>0){switch(I.length){case 1:E+=`of type ${I[0]}`;break;case 2:E+=`one of type ${I[0]} or ${I[1]}`;break;default:{const O=I.pop();E+=`one of type ${I.join(", ")}, or ${O}`}}if(T.length>0||P.length>0)E+=" or "}if(T.length>0){switch(T.length){case 1:E+=`an instance of ${T[0]}`;break;case 2:E+=`an instance of ${T[0]} or ${T[1]}`;break;default:{const O=T.pop();E+=`an instance of ${T.join(", ")}, or ${O}`}}if(P.length>0)E+=" or "}switch(P.length){case 0:break;case 1:if(P[0].toLowerCase()!==P[0])E+="an ";E+=`${P[0]}`;break;case 2:E+=`one of ${P[0]} or ${P[1]}`;break;default:{const O=P.pop();E+=`one of ${P.join(", ")}, or ${O}`}}if(A==null)E+=`. Received ${A}`;else if(typeof A==="function"&&A.name)E+=`. Received function ${A.name}`;else if(typeof A==="object"){var x;if((x=A.constructor)!==null&&x!==void 0&&x.name)E+=`. Received an instance of ${A.constructor.name}`;else{const O=J(A,{depth:-1});E+=`. Received ${O}`}}else{let O=J(A,{colors:!1});if(O.length>25)O=`${O.slice(0,25)}...`;E+=`. Received type ${typeof A} (${O})`}return E},TypeError),G("ERR_INVALID_ARG_VALUE",(j,N,A="is invalid")=>{let E=J(N);if(E.length>128)E=E.slice(0,128)+"...";return`The ${j.includes(".")?"property":"argument"} '${j}' ${A}. Received ${E}`},TypeError),G("ERR_INVALID_RETURN_VALUE",(j,N,A)=>{var E;const I=A!==null&&A!==void 0&&(E=A.constructor)!==null&&E!==void 0&&E.name?`instance of ${A.constructor.name}`:`type ${typeof A}`;return`Expected ${j} to be returned from the "${N}" function but got ${I}.`},TypeError),G("ERR_MISSING_ARGS",(...j)=>{V(j.length>0,"At least one arg needs to be specified");let N;const A=j.length;switch(j=(Array.isArray(j)?j:[j]).map((E)=>`"${E}"`).join(" or "),A){case 1:N+=`The ${j[0]} argument`;break;case 2:N+=`The ${j[0]} and ${j[1]} arguments`;break;default:{const E=j.pop();N+=`The ${j.join(", ")}, and ${E} arguments`}break}return`${N} must be specified`},TypeError),G("ERR_OUT_OF_RANGE",(j,N,A)=>{V(N,'Missing "range" argument');let E;if(Number.isInteger(A)&&Math.abs(A)>4294967296)E=U(String(A));else if(typeof A==="bigint"){if(E=String(A),A>2n**32n||A<-(2n**32n))E=U(E);E+="n"}else E=J(A);return`The value of "${j}" is out of range. It must be ${N}. Received ${E}`},RangeError),G("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),G("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),G("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),G("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),G("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),G("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),G("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),G("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),G("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),G("ERR_STREAM_WRITE_AFTER_END","write after end",Error),G("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),Q.exports={AbortError:L,aggregateTwoErrors:M(F),hideStackFrames:M,codes:z}}}),sq=mq({"node_modules/readable-stream/lib/internal/validators.js"(q,Q){var{ArrayIsArray:X,ArrayPrototypeIncludes:J,ArrayPrototypeJoin:H,ArrayPrototypeMap:K,NumberIsInteger:Z,NumberMAX_SAFE_INTEGER:B,NumberMIN_SAFE_INTEGER:Y,NumberParseInt:$,RegExpPrototypeTest:z,String:V,StringPrototypeToUpperCase:U,StringPrototypeTrim:W}=Oq(),{hideStackFrames:G,codes:{ERR_SOCKET_BAD_PORT:M,ERR_INVALID_ARG_TYPE:F,ERR_INVALID_ARG_VALUE:L,ERR_OUT_OF_RANGE:j,ERR_UNKNOWN_SIGNAL:N}}=oq(),{normalizeEncoding:A}=_q(),{isAsyncFunction:E,isArrayBufferView:I}=_q().types,T={};function P(i){return i===(i|0)}function x(i){return i===i>>>0}var O=/^[0-7]+$/,_="must be a 32-bit unsigned integer or an octal string";function C(i,n,o){if(typeof i==="undefined")i=o;if(typeof i==="string"){if(!z(O,i))throw new L(n,i,_);i=$(i,8)}return w(i,n,0,4294967295),i}var D=G((i,n,o=Y,s=B)=>{if(typeof i!=="number")throw new F(n,"number",i);if(!Z(i))throw new j(n,"an integer",i);if(is)throw new j(n,`>= ${o} && <= ${s}`,i)}),w=G((i,n,o=-2147483648,s=2147483647)=>{if(typeof i!=="number")throw new F(n,"number",i);if(!P(i)){if(!Z(i))throw new j(n,"an integer",i);throw new j(n,`>= ${o} && <= ${s}`,i)}if(is)throw new j(n,`>= ${o} && <= ${s}`,i)}),v=G((i,n,o)=>{if(typeof i!=="number")throw new F(n,"number",i);if(!x(i)){if(!Z(i))throw new j(n,"an integer",i);throw new j(n,`>= ${o?1:0} && < 4294967296`,i)}if(o&&i===0)throw new j(n,">= 1 && < 4294967296",i)});function R(i,n){if(typeof i!=="string")throw new F(n,"string",i)}function S(i,n){if(typeof i!=="number")throw new F(n,"number",i)}var g=G((i,n,o)=>{if(!J(o,i)){const a="must be one of: "+H(K(o,(r)=>typeof r==="string"?`'${r}'`:V(r)),", ");throw new L(n,i,a)}});function f(i,n){if(typeof i!=="boolean")throw new F(n,"boolean",i)}var k=G((i,n,o)=>{const s=o==null,a=s?!1:o.allowArray,r=s?!1:o.allowFunction;if(!(s?!1:o.nullable)&&i===null||!a&&X(i)||typeof i!=="object"&&(!r||typeof i!=="function"))throw new F(n,"Object",i)}),y=G((i,n,o=0)=>{if(!X(i))throw new F(n,"Array",i);if(i.length{if(!I(i))throw new F(n,["Buffer","TypedArray","DataView"],i)});function u(i,n){const o=A(n),s=i.length;if(o==="hex"&&s%2!==0)throw new L("encoding",n,`is invalid for data of length ${s}`)}function b(i,n="Port",o=!0){if(typeof i!=="number"&&typeof i!=="string"||typeof i==="string"&&W(i).length===0||+i!==+i>>>0||i>65535||i===0&&!o)throw new M(n,i,o);return i|0}var m=G((i,n)=>{if(i!==void 0&&(i===null||typeof i!=="object"||!("aborted"in i)))throw new F(n,"AbortSignal",i)}),c=G((i,n)=>{if(typeof i!=="function")throw new F(n,"Function",i)}),d=G((i,n)=>{if(typeof i!=="function"||E(i))throw new F(n,"Function",i)}),l=G((i,n)=>{if(i!==void 0)throw new F(n,"undefined",i)});Q.exports={isInt32:P,isUint32:x,parseFileMode:C,validateArray:y,validateBoolean:f,validateBuffer:p,validateEncoding:u,validateFunction:c,validateInt32:w,validateInteger:D,validateNumber:S,validateObject:k,validateOneOf:g,validatePlainFunction:d,validatePort:b,validateSignalName:h,validateString:R,validateUint32:v,validateUndefined:l,validateAbortSignal:m}}}),aq=mq({"node_modules/readable-stream/lib/internal/streams/utils.js"(q,Q){var{Symbol:X,SymbolAsyncIterator:J,SymbolIterator:H}=Oq(),K=X("kDestroyed"),Z=X("kIsErrored"),B=X("kIsReadable"),Y=X("kIsDisturbed");function $(v,R=!1){var S;return!!(v&&typeof v.pipe==="function"&&typeof v.on==="function"&&(!R||typeof v.pause==="function"&&typeof v.resume==="function")&&(!v._writableState||((S=v._readableState)===null||S===void 0?void 0:S.readable)!==!1)&&(!v._writableState||v._readableState))}function z(v){var R;return!!(v&&typeof v.write==="function"&&typeof v.on==="function"&&(!v._readableState||((R=v._writableState)===null||R===void 0?void 0:R.writable)!==!1))}function V(v){return!!(v&&typeof v.pipe==="function"&&v._readableState&&typeof v.on==="function"&&typeof v.write==="function")}function U(v){return v&&(v._readableState||v._writableState||typeof v.write==="function"&&typeof v.on==="function"||typeof v.pipe==="function"&&typeof v.on==="function")}function W(v,R){if(v==null)return!1;if(R===!0)return typeof v[J]==="function";if(R===!1)return typeof v[H]==="function";return typeof v[J]==="function"||typeof v[H]==="function"}function G(v){if(!U(v))return null;const{_writableState:R,_readableState:S}=v,g=R||S;return!!(v.destroyed||v[K]||g!==null&&g!==void 0&&g.destroyed)}function M(v){if(!z(v))return null;if(v.writableEnded===!0)return!0;const R=v._writableState;if(R!==null&&R!==void 0&&R.errored)return!1;if(typeof(R===null||R===void 0?void 0:R.ended)!=="boolean")return null;return R.ended}function F(v,R){if(!z(v))return null;if(v.writableFinished===!0)return!0;const S=v._writableState;if(S!==null&&S!==void 0&&S.errored)return!1;if(typeof(S===null||S===void 0?void 0:S.finished)!=="boolean")return null;return!!(S.finished||R===!1&&S.ended===!0&&S.length===0)}function L(v){if(!$(v))return null;if(v.readableEnded===!0)return!0;const R=v._readableState;if(!R||R.errored)return!1;if(typeof(R===null||R===void 0?void 0:R.ended)!=="boolean")return null;return R.ended}function j(v,R){if(!$(v))return null;const S=v._readableState;if(S!==null&&S!==void 0&&S.errored)return!1;if(typeof(S===null||S===void 0?void 0:S.endEmitted)!=="boolean")return null;return!!(S.endEmitted||R===!1&&S.ended===!0&&S.length===0)}function N(v){if(v&&v[B]!=null)return v[B];if(typeof(v===null||v===void 0?void 0:v.readable)!=="boolean")return null;if(G(v))return!1;return $(v)&&v.readable&&!j(v)}function A(v){if(typeof(v===null||v===void 0?void 0:v.writable)!=="boolean")return null;if(G(v))return!1;return z(v)&&v.writable&&!M(v)}function E(v,R){if(!U(v))return null;if(G(v))return!0;if((R===null||R===void 0?void 0:R.readable)!==!1&&N(v))return!1;if((R===null||R===void 0?void 0:R.writable)!==!1&&A(v))return!1;return!0}function I(v){var R,S;if(!U(v))return null;if(v.writableErrored)return v.writableErrored;return(R=(S=v._writableState)===null||S===void 0?void 0:S.errored)!==null&&R!==void 0?R:null}function T(v){var R,S;if(!U(v))return null;if(v.readableErrored)return v.readableErrored;return(R=(S=v._readableState)===null||S===void 0?void 0:S.errored)!==null&&R!==void 0?R:null}function P(v){if(!U(v))return null;if(typeof v.closed==="boolean")return v.closed;const{_writableState:R,_readableState:S}=v;if(typeof(R===null||R===void 0?void 0:R.closed)==="boolean"||typeof(S===null||S===void 0?void 0:S.closed)==="boolean")return(R===null||R===void 0?void 0:R.closed)||(S===null||S===void 0?void 0:S.closed);if(typeof v._closed==="boolean"&&x(v))return v._closed;return null}function x(v){return typeof v._closed==="boolean"&&typeof v._defaultKeepAlive==="boolean"&&typeof v._removedConnection==="boolean"&&typeof v._removedContLen==="boolean"}function O(v){return typeof v._sent100==="boolean"&&x(v)}function _(v){var R;return typeof v._consuming==="boolean"&&typeof v._dumped==="boolean"&&((R=v.req)===null||R===void 0?void 0:R.upgradeOrConnect)===void 0}function C(v){if(!U(v))return null;const{_writableState:R,_readableState:S}=v,g=R||S;return!g&&O(v)||!!(g&&g.autoDestroy&&g.emitClose&&g.closed===!1)}function D(v){var R;return!!(v&&((R=v[Y])!==null&&R!==void 0?R:v.readableDidRead||v.readableAborted))}function w(v){var R,S,g,f,k,y,h,p,u,b;return!!(v&&((R=(S=(g=(f=(k=(y=v[Z])!==null&&y!==void 0?y:v.readableErrored)!==null&&k!==void 0?k:v.writableErrored)!==null&&f!==void 0?f:(h=v._readableState)===null||h===void 0?void 0:h.errorEmitted)!==null&&g!==void 0?g:(p=v._writableState)===null||p===void 0?void 0:p.errorEmitted)!==null&&S!==void 0?S:(u=v._readableState)===null||u===void 0?void 0:u.errored)!==null&&R!==void 0?R:(b=v._writableState)===null||b===void 0?void 0:b.errored))}Q.exports={kDestroyed:K,isDisturbed:D,kIsDisturbed:Y,isErrored:w,kIsErrored:Z,isReadable:N,kIsReadable:B,isClosed:P,isDestroyed:G,isDuplexNodeStream:V,isFinished:E,isIterable:W,isReadableNodeStream:$,isReadableEnded:L,isReadableFinished:j,isReadableErrored:T,isNodeStream:U,isWritable:A,isWritableNodeStream:z,isWritableEnded:M,isWritableFinished:F,isWritableErrored:I,isServerRequest:_,isServerResponse:O,willEmitClose:C}}}),rq=mq({"node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(q,Q){var{AbortError:X,codes:J}=oq(),{ERR_INVALID_ARG_TYPE:H,ERR_STREAM_PREMATURE_CLOSE:K}=J,{once:Z}=_q(),{validateAbortSignal:B,validateFunction:Y,validateObject:$}=sq(),{Promise:z}=Oq(),{isClosed:V,isReadable:U,isReadableNodeStream:W,isReadableFinished:G,isReadableErrored:M,isWritable:F,isWritableNodeStream:L,isWritableFinished:j,isWritableErrored:N,isNodeStream:A,willEmitClose:E}=aq();function I(O){return O.setHeader&&typeof O.abort==="function"}var T=()=>{};function P(O,_,C){var D,w;if(arguments.length===2)C=_,_={};else if(_==null)_={};else $(_,"options");Y(C,"callback"),B(_.signal,"options.signal"),C=Z(C);const v=(D=_.readable)!==null&&D!==void 0?D:W(O),R=(w=_.writable)!==null&&w!==void 0?w:L(O);if(!A(O))throw new H("stream","Stream",O);const{_writableState:S,_readableState:g}=O,f=()=>{if(!O.writable)h()};let k=E(O)&&W(O)===v&&L(O)===R,y=j(O,!1);const h=()=>{if(y=!0,O.destroyed)k=!1;if(k&&(!O.readable||v))return;if(!v||p)C.call(O)};let p=G(O,!1);const u=()=>{if(p=!0,O.destroyed)k=!1;if(k&&(!O.writable||R))return;if(!R||y)C.call(O)},b=(i)=>{C.call(O,i)};let m=V(O);const c=()=>{m=!0;const i=N(O)||M(O);if(i&&typeof i!=="boolean")return C.call(O,i);if(v&&!p&&W(O,!0)){if(!G(O,!1))return C.call(O,new K)}if(R&&!y){if(!j(O,!1))return C.call(O,new K)}C.call(O)},d=()=>{O.req.on("finish",h)};if(I(O)){if(O.on("complete",h),!k)O.on("abort",c);if(O.req)d();else O.on("request",d)}else if(R&&!S)O.on("end",f),O.on("close",f);if(!k&&typeof O.aborted==="boolean")O.on("aborted",c);if(O.on("end",u),O.on("finish",h),_.error!==!1)O.on("error",b);if(O.on("close",c),m)Iq(c);else if(S!==null&&S!==void 0&&S.errorEmitted||g!==null&&g!==void 0&&g.errorEmitted){if(!k)Iq(c)}else if(!v&&(!k||U(O))&&(y||F(O)===!1))Iq(c);else if(!R&&(!k||F(O))&&(p||U(O)===!1))Iq(c);else if(g&&O.req&&O.aborted)Iq(c);const l=()=>{if(C=T,O.removeListener("aborted",c),O.removeListener("complete",h),O.removeListener("abort",c),O.removeListener("request",d),O.req)O.req.removeListener("finish",h);O.removeListener("end",f),O.removeListener("close",f),O.removeListener("finish",h),O.removeListener("end",u),O.removeListener("error",b),O.removeListener("close",c)};if(_.signal&&!m){const i=()=>{const n=C;l(),n.call(O,new X(void 0,{cause:_.signal.reason}))};if(_.signal.aborted)Iq(i);else{const n=C;C=Z((...o)=>{_.signal.removeEventListener("abort",i),n.apply(O,o)}),_.signal.addEventListener("abort",i)}}return l}function x(O,_){return new z((C,D)=>{P(O,_,(w)=>{if(w)D(w);else C()})})}Q.exports=P,Q.exports.finished=x}}),tq=mq({"node_modules/readable-stream/lib/internal/streams/operators.js"(q,Q){var{codes:{ERR_INVALID_ARG_TYPE:X,ERR_MISSING_ARGS:J,ERR_OUT_OF_RANGE:H},AbortError:K}=oq(),{validateAbortSignal:Z,validateInteger:B,validateObject:Y}=sq(),$=Oq().Symbol("kWeak"),{finished:z}=rq(),{ArrayPrototypePush:V,MathFloor:U,Number:W,NumberIsNaN:G,Promise:M,PromiseReject:F,PromisePrototypeCatch:L,Symbol:j}=Oq(),N=j("kEmpty"),A=j("kEof");function E(f,k){if(typeof f!=="function")throw new X("fn",["Function","AsyncFunction"],f);if(k!=null)Y(k,"options");if((k===null||k===void 0?void 0:k.signal)!=null)Z(k.signal,"options.signal");let y=1;if((k===null||k===void 0?void 0:k.concurrency)!=null)y=U(k.concurrency);return B(y,"concurrency",1),async function*h(){var p,u;const b=new AbortController,m=this,c=[],d=b.signal,l={signal:d},i=()=>b.abort();if(k!==null&&k!==void 0&&(p=k.signal)!==null&&p!==void 0&&p.aborted)i();k===null||k===void 0||(u=k.signal)===null||u===void 0||u.addEventListener("abort",i);let n,o,s=!1;function a(){s=!0}async function r(){try{for await(let qq of m){var t;if(s)return;if(d.aborted)throw new K;try{qq=f(qq,l)}catch(Qq){qq=F(Qq)}if(qq===N)continue;if(typeof((t=qq)===null||t===void 0?void 0:t.catch)==="function")qq.catch(a);if(c.push(qq),n)n(),n=null;if(!s&&c.length&&c.length>=y)await new M((Qq)=>{o=Qq})}c.push(A)}catch(qq){const Qq=F(qq);L(Qq,a),c.push(Qq)}finally{var e;if(s=!0,n)n(),n=null;k===null||k===void 0||(e=k.signal)===null||e===void 0||e.removeEventListener("abort",i)}}r();try{while(!0){while(c.length>0){const t=await c[0];if(t===A)return;if(d.aborted)throw new K;if(t!==N)yield t;if(c.shift(),o)o(),o=null}await new M((t)=>{n=t})}}finally{if(b.abort(),s=!0,o)o(),o=null}}.call(this)}function I(f=void 0){if(f!=null)Y(f,"options");if((f===null||f===void 0?void 0:f.signal)!=null)Z(f.signal,"options.signal");return async function*k(){let y=0;for await(let p of this){var h;if(f!==null&&f!==void 0&&(h=f.signal)!==null&&h!==void 0&&h.aborted)throw new K({cause:f.signal.reason});yield[y++,p]}}.call(this)}async function T(f,k=void 0){for await(let y of _.call(this,f,k))return!0;return!1}async function P(f,k=void 0){if(typeof f!=="function")throw new X("fn",["Function","AsyncFunction"],f);return!await T.call(this,async(...y)=>{return!await f(...y)},k)}async function x(f,k){for await(let y of _.call(this,f,k))return y;return}async function O(f,k){if(typeof f!=="function")throw new X("fn",["Function","AsyncFunction"],f);async function y(h,p){return await f(h,p),N}for await(let h of E.call(this,y,k));}function _(f,k){if(typeof f!=="function")throw new X("fn",["Function","AsyncFunction"],f);async function y(h,p){if(await f(h,p))return h;return N}return E.call(this,y,k)}var C=class extends J{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}};async function D(f,k,y){var h;if(typeof f!=="function")throw new X("reducer",["Function","AsyncFunction"],f);if(y!=null)Y(y,"options");if((y===null||y===void 0?void 0:y.signal)!=null)Z(y.signal,"options.signal");let p=arguments.length>1;if(y!==null&&y!==void 0&&(h=y.signal)!==null&&h!==void 0&&h.aborted){const d=new K(void 0,{cause:y.signal.reason});throw this.once("error",()=>{}),await z(this.destroy(d)),d}const u=new AbortController,b=u.signal;if(y!==null&&y!==void 0&&y.signal){const d={once:!0,[$]:this};y.signal.addEventListener("abort",()=>u.abort(),d)}let m=!1;try{for await(let d of this){var c;if(m=!0,y!==null&&y!==void 0&&(c=y.signal)!==null&&c!==void 0&&c.aborted)throw new K;if(!p)k=d,p=!0;else k=await f(k,d,{signal:b})}if(!m&&!p)throw new C}finally{u.abort()}return k}async function w(f){if(f!=null)Y(f,"options");if((f===null||f===void 0?void 0:f.signal)!=null)Z(f.signal,"options.signal");const k=[];for await(let h of this){var y;if(f!==null&&f!==void 0&&(y=f.signal)!==null&&y!==void 0&&y.aborted)throw new K(void 0,{cause:f.signal.reason});V(k,h)}return k}function v(f,k){const y=E.call(this,f,k);return async function*h(){for await(let p of y)yield*p}.call(this)}function R(f){if(f=W(f),G(f))return 0;if(f<0)throw new H("number",">= 0",f);return f}function S(f,k=void 0){if(k!=null)Y(k,"options");if((k===null||k===void 0?void 0:k.signal)!=null)Z(k.signal,"options.signal");return f=R(f),async function*y(){var h;if(k!==null&&k!==void 0&&(h=k.signal)!==null&&h!==void 0&&h.aborted)throw new K;for await(let u of this){var p;if(k!==null&&k!==void 0&&(p=k.signal)!==null&&p!==void 0&&p.aborted)throw new K;if(f--<=0)yield u}}.call(this)}function g(f,k=void 0){if(k!=null)Y(k,"options");if((k===null||k===void 0?void 0:k.signal)!=null)Z(k.signal,"options.signal");return f=R(f),async function*y(){var h;if(k!==null&&k!==void 0&&(h=k.signal)!==null&&h!==void 0&&h.aborted)throw new K;for await(let u of this){var p;if(k!==null&&k!==void 0&&(p=k.signal)!==null&&p!==void 0&&p.aborted)throw new K;if(f-- >0)yield u;else return}}.call(this)}Q.exports.streamReturningOperators={asIndexedPairs:I,drop:S,filter:_,flatMap:v,map:E,take:g},Q.exports.promiseReturningOperators={every:P,forEach:O,reduce:D,toArray:w,some:T,find:x}}}),eq=mq({"node_modules/readable-stream/lib/internal/streams/destroy.js"(q,Q){var{aggregateTwoErrors:X,codes:{ERR_MULTIPLE_CALLBACK:J},AbortError:H}=oq(),{Symbol:K}=Oq(),{kDestroyed:Z,isDestroyed:B,isFinished:Y,isServerRequest:$}=aq(),z="#kDestroy",V="#kConstruct";function U(_,C,D){if(_){if(_.stack,C&&!C.errored)C.errored=_;if(D&&!D.errored)D.errored=_}}function W(_,C){const D=this._readableState,w=this._writableState,v=w||D;if(w&&w.destroyed||D&&D.destroyed){if(typeof C==="function")C();return this}if(U(_,w,D),w)w.destroyed=!0;if(D)D.destroyed=!0;if(!v.constructed)this.once(z,(R)=>{G(this,X(R,_),C)});else G(this,_,C);return this}function G(_,C,D){let w=!1;function v(R){if(w)return;w=!0;const{_readableState:S,_writableState:g}=_;if(U(R,g,S),g)g.closed=!0;if(S)S.closed=!0;if(typeof D==="function")D(R);if(R)Iq(M,_,R);else Iq(F,_)}try{_._destroy(C||null,v)}catch(R){v(R)}}function M(_,C){L(_,C),F(_)}function F(_){const{_readableState:C,_writableState:D}=_;if(D)D.closeEmitted=!0;if(C)C.closeEmitted=!0;if(D&&D.emitClose||C&&C.emitClose)_.emit("close")}function L(_,C){const D=_?._readableState,w=_?._writableState;if(w?.errorEmitted||D?.errorEmitted)return;if(w)w.errorEmitted=!0;if(D)D.errorEmitted=!0;_?.emit?.("error",C)}function j(){const _=this._readableState,C=this._writableState;if(_)_.constructed=!0,_.closed=!1,_.closeEmitted=!1,_.destroyed=!1,_.errored=null,_.errorEmitted=!1,_.reading=!1,_.ended=_.readable===!1,_.endEmitted=_.readable===!1;if(C)C.constructed=!0,C.destroyed=!1,C.closed=!1,C.closeEmitted=!1,C.errored=null,C.errorEmitted=!1,C.finalCalled=!1,C.prefinished=!1,C.ended=C.writable===!1,C.ending=C.writable===!1,C.finished=C.writable===!1}function N(_,C,D){const w=_?._readableState,v=_?._writableState;if(v&&v.destroyed||w&&w.destroyed)return this;if(w&&w.autoDestroy||v&&v.autoDestroy)_.destroy(C);else if(C){if(Error.captureStackTrace(C),v&&!v.errored)v.errored=C;if(w&&!w.errored)w.errored=C;if(D)Iq(L,_,C);else L(_,C)}}function A(_,C){if(typeof _._construct!=="function")return;const{_readableState:D,_writableState:w}=_;if(D)D.constructed=!1;if(w)w.constructed=!1;if(_.once(V,C),_.listenerCount(V)>1)return;Iq(E,_)}function E(_){let C=!1;function D(w){if(C){N(_,w!==null&&w!==void 0?w:new J);return}C=!0;const{_readableState:v,_writableState:R}=_,S=R||v;if(v)v.constructed=!0;if(R)R.constructed=!0;if(S.destroyed)_.emit(z,w);else if(w)N(_,w,!0);else Iq(I,_)}try{_._construct(D)}catch(w){D(w)}}function I(_){_.emit(V)}function T(_){return _&&_.setHeader&&typeof _.abort==="function"}function P(_){_.emit("close")}function x(_,C){_.emit("error",C),Iq(P,_)}function O(_,C){if(!_||B(_))return;if(!C&&!Y(_))C=new H;if($(_))_.socket=null,_.destroy(C);else if(T(_))_.abort();else if(T(_.req))_.req.abort();else if(typeof _.destroy==="function")_.destroy(C);else if(typeof _.close==="function")_.close();else if(C)Iq(x,_);else Iq(P,_);if(!_.destroyed)_[Z]=!0}Q.exports={construct:A,destroyer:O,destroy:W,undestroy:j,errorOrDestroy:N}}}),qQ=mq({"node_modules/readable-stream/lib/internal/streams/legacy.js"(q,Q){var{ArrayIsArray:X,ObjectSetPrototypeOf:J}=Oq();function H(Z){if(!(this instanceof H))return new H(Z);Pq.call(this,Z)}J(H.prototype,Pq.prototype),J(H,Pq),H.prototype.pipe=function(Z,B){const Y=this;function $(F){if(Z.writable&&Z.write(F)===!1&&Y.pause)Y.pause()}Y.on("data",$);function z(){if(Y.readable&&Y.resume)Y.resume()}if(Z.on("drain",z),!Z._isStdio&&(!B||B.end!==!1))Y.on("end",U),Y.on("close",W);let V=!1;function U(){if(V)return;V=!0,Z.end()}function W(){if(V)return;if(V=!0,typeof Z.destroy==="function")Z.destroy()}function G(F){if(M(),Pq.listenerCount(this,"error")===0)this.emit("error",F)}K(Y,"error",G),K(Z,"error",G);function M(){Y.removeListener("data",$),Z.removeListener("drain",z),Y.removeListener("end",U),Y.removeListener("close",W),Y.removeListener("error",G),Z.removeListener("error",G),Y.removeListener("end",M),Y.removeListener("close",M),Z.removeListener("close",M)}return Y.on("end",M),Y.on("close",M),Z.on("close",M),Z.emit("pipe",Y),Z};function K(Z,B,Y){if(typeof Z.prependListener==="function")return Z.prependListener(B,Y);if(!Z._events||!Z._events[B])Z.on(B,Y);else if(X(Z._events[B]))Z._events[B].unshift(Y);else Z._events[B]=[Y,Z._events[B]]}Q.exports={Stream:H,prependListener:K}}}),QQ=mq({"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js"(q,Q){var{AbortError:X,codes:J}=oq(),H=rq(),{ERR_INVALID_ARG_TYPE:K}=J,Z=(Y,$)=>{if(typeof Y!=="object"||!("aborted"in Y))throw new K($,"AbortSignal",Y)};function B(Y){return!!(Y&&typeof Y.pipe==="function")}Q.exports.addAbortSignal=function Y($,z){if(Z($,"signal"),!B(z))throw new K("stream","stream.Stream",z);return Q.exports.addAbortSignalNoValidate($,z)},Q.exports.addAbortSignalNoValidate=function(Y,$){if(typeof Y!=="object"||!("aborted"in Y))return $;const z=()=>{$.destroy(new X(void 0,{cause:Y.reason}))};if(Y.aborted)z();else Y.addEventListener("abort",z),H($,()=>Y.removeEventListener("abort",z));return $}}}),XQ=mq({"node_modules/readable-stream/lib/internal/streams/state.js"(q,Q){var{MathFloor:X,NumberIsInteger:J}=Oq(),{ERR_INVALID_ARG_VALUE:H}=oq().codes;function K(Y,$,z){return Y.highWaterMark!=null?Y.highWaterMark:$?Y[z]:null}function Z(Y){return Y?16:16384}function B(Y,$,z,V){const U=K($,V,z);if(U!=null){if(!J(U)||U<0){const W=V?`options.${z}`:"options.highWaterMark";throw new H(W,U)}return X(U)}return Z(Y.objectMode)}Q.exports={getHighWaterMark:B,getDefaultHighWaterMark:Z}}}),JQ=mq({"node_modules/readable-stream/lib/internal/streams/from.js"(q,Q){var{PromisePrototypeThen:X,SymbolAsyncIterator:J,SymbolIterator:H}=Oq(),{ERR_INVALID_ARG_TYPE:K,ERR_STREAM_NULL_VALUES:Z}=oq().codes;function B(Y,$,z){let V;if(typeof $==="string"||$ instanceof Buffer)return new Y({objectMode:!0,...z,read(){this.push($),this.push(null)}});let U;if($&&$[J])U=!0,V=$[J]();else if($&&$[H])U=!1,V=$[H]();else throw new K("iterable",["Iterable"],$);const W=new Y({objectMode:!0,highWaterMark:1,...z});let G=!1;W._read=function(){if(!G)G=!0,F()},W._destroy=function(L,j){X(M(L),()=>Iq(j,L),(N)=>Iq(j,N||L))};async function M(L){const j=L!==void 0&&L!==null,N=typeof V.throw==="function";if(j&&N){const{value:A,done:E}=await V.throw(L);if(await A,E)return}if(typeof V.return==="function"){const{value:A}=await V.return();await A}}async function F(){for(;;){try{const{value:L,done:j}=U?await V.next():V.next();if(j)W.push(null);else{const N=L&&typeof L.then==="function"?await L:L;if(N===null)throw G=!1,new Z;else if(W.push(N))continue;else G=!1}}catch(L){W.destroy(L)}break}}return W}Q.exports=B}}),HQ,KQ,ZQ=mq({"node_modules/readable-stream/lib/internal/streams/readable.js"(q,Q){var{ArrayPrototypeIndexOf:X,NumberIsInteger:J,NumberIsNaN:H,NumberParseInt:K,ObjectDefineProperties:Z,ObjectKeys:B,ObjectSetPrototypeOf:Y,Promise:$,SafeSet:z,SymbolAsyncIterator:V,Symbol:U}=Oq(),W=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{Stream:G,prependListener:M}=qQ();function F(qq){if(!(this instanceof F))return new F(qq);const Qq=this instanceof Cq();if(this._readableState=new W(qq,this,Qq),qq){const{read:Xq,destroy:Jq,construct:Hq,signal:Kq}=qq;if(typeof Xq==="function")this._read=Xq;if(typeof Jq==="function")this._destroy=Jq;if(typeof Hq==="function")this._construct=Hq;if(Kq&&!Qq)N(Kq,this)}G.call(this,qq),_.construct(this,()=>{if(this._readableState.needReadable)x(this,this._readableState)})}Y(F.prototype,G.prototype),Y(F,G),F.prototype.on=function(qq,Qq){const Xq=G.prototype.on.call(this,qq,Qq),Jq=this._readableState;if(qq==="data")if(Jq.readableListening=this.listenerCount("readable")>0,Jq.flowing!==!1)Aq&&Nq("in flowing mode!",this.__id),this.resume();else Aq&&Nq("in readable mode!",this.__id);else if(qq==="readable"){if(Aq&&Nq("readable listener added!",this.__id),!Jq.endEmitted&&!Jq.readableListening){if(Jq.readableListening=Jq.needReadable=!0,Jq.flowing=!1,Jq.emittedReadable=!1,Aq&&Nq("on readable - state.length, reading, emittedReadable",Jq.length,Jq.reading,Jq.emittedReadable,this.__id),Jq.length)O(this,Jq);else if(!Jq.reading)Iq(l,this)}else if(Jq.endEmitted)Aq&&Nq("end already emitted...",this.__id)}return Xq};class L extends F{#q;#Q;#X;#J;constructor(qq,Qq){const{objectMode:Xq,highWaterMark:Jq,encoding:Hq,signal:Kq}=qq;super({objectMode:Xq,highWaterMark:Jq,encoding:Hq,signal:Kq});this.#X=[],this.#q=void 0,this.#J=Qq,this.#Q=!1}#H(){var qq=this.#X,Qq=0,Xq=qq.length;for(;Qq0)this.#X=[];return!1}#K(qq){qq.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){Aq&&Nq("ReadableFromWeb _read()",this.__id);var qq=this.#J,Qq=this.#q;if(qq)Qq=this.#q=qq.getReader(),this.#J=void 0;else if(this.#H())return;var Xq;try{do{var Jq=!1,Hq;const Kq=Qq.readMany();if(xq(Kq)){if({done:Jq,value:Hq}=await Kq,this.#Q){this.#X.push(...Hq);return}}else({done:Jq,value:Hq}=Kq);if(Jq){this.#K(Qq);return}if(!this.push(Hq[0])){this.#X=Hq.slice(1);return}for(let Zq=1,Bq=Hq.length;Zq{this.#Q=!0,Qq(qq)});return}try{Qq(qq)}catch(Jq){globalThis.reportError(Jq)}}}KQ=L;function j(qq,Qq={}){if(!cq(qq))throw new D("readableStream","ReadableStream",qq);g(Qq,"options");const{highWaterMark:Xq,encoding:Jq,objectMode:Hq=!1,signal:Kq}=Qq;if(Jq!==void 0&&!Buffer.isEncoding(Jq))throw new nq(Jq,"options.encoding");return dq(Hq,"options.objectMode"),NQ(F,qq,Qq)||new L({highWaterMark:Xq,encoding:Jq,objectMode:Hq,signal:Kq},qq)}Q.exports=F,HQ=j;var{addAbortSignal:N}=QQ(),A=rq();const{maybeReadMore:E,resume:I,emitReadable:T,onEofChunk:P}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function x(qq,Qq){process.nextTick(E,qq,Qq)}function O(qq,Qq){Aq&&Nq("NativeReadable - emitReadable",qq.__id),T(qq,Qq)}var _=eq(),{aggregateTwoErrors:C,codes:{ERR_INVALID_ARG_TYPE:D,ERR_METHOD_NOT_IMPLEMENTED:w,ERR_OUT_OF_RANGE:v,ERR_STREAM_PUSH_AFTER_EOF:R,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:S}}=oq(),{validateObject:g}=sq(),f=JQ(),k=()=>{},{errorOrDestroy:y}=_;F.prototype.destroy=_.destroy,F.prototype._undestroy=_.undestroy,F.prototype._destroy=function(qq,Qq){Qq(qq)},F.prototype[Pq.captureRejectionSymbol]=function(qq){this.destroy(qq)},F.prototype.push=function(qq,Qq){return h(this,qq,Qq,!1)},F.prototype.unshift=function(qq,Qq){return h(this,qq,Qq,!0)};function h(qq,Qq,Xq,Jq){Aq&&Nq("readableAddChunk",Qq,qq.__id);const Hq=qq._readableState;let Kq;if(!Hq.objectMode){if(typeof Qq==="string"){if(Xq=Xq||Hq.defaultEncoding,Hq.encoding!==Xq)if(Jq&&Hq.encoding)Qq=Buffer.from(Qq,Xq).toString(Hq.encoding);else Qq=Buffer.from(Qq,Xq),Xq=""}else if(Qq instanceof Buffer)Xq="";else if(G._isUint8Array(Qq)){if(Jq||!Hq.decoder)Qq=G._uint8ArrayToBuffer(Qq);Xq=""}else if(Qq!=null)Kq=new D("chunk",["string","Buffer","Uint8Array"],Qq)}if(Kq)y(qq,Kq);else if(Qq===null)Hq.reading=!1,P(qq,Hq);else if(Hq.objectMode||Qq&&Qq.length>0)if(Jq)if(Hq.endEmitted)y(qq,new S);else if(Hq.destroyed||Hq.errored)return!1;else p(qq,Hq,Qq,!0);else if(Hq.ended)y(qq,new R);else if(Hq.destroyed||Hq.errored)return!1;else if(Hq.reading=!1,Hq.decoder&&!Xq)if(Qq=Hq.decoder.write(Qq),Hq.objectMode||Qq.length!==0)p(qq,Hq,Qq,!1);else x(qq,Hq);else p(qq,Hq,Qq,!1);else if(!Jq)Hq.reading=!1,x(qq,Hq);return!Hq.ended&&(Hq.length0){if(Qq.multiAwaitDrain)Qq.awaitDrainWriters.clear();else Qq.awaitDrainWriters=null;Qq.dataEmitted=!0,qq.emit("data",Xq)}else{if(Qq.length+=Qq.objectMode?1:Xq.length,Jq)Qq.buffer.unshift(Xq);else Qq.buffer.push(Xq);if(Aq&&Nq("needReadable @ addChunk",Qq.needReadable,qq.__id),Qq.needReadable)O(qq,Qq)}x(qq,Qq)}F.prototype.isPaused=function(){const qq=this._readableState;return qq.paused===!0||qq.flowing===!1},F.prototype.setEncoding=function(qq){const Qq=new Sq(qq);this._readableState.decoder=Qq,this._readableState.encoding=this._readableState.decoder.encoding;const Xq=this._readableState.buffer;let Jq="";for(let Hq=Xq.length;Hq>0;Hq--)Jq+=Qq.write(Xq.shift());if(Jq!=="")Xq.push(Jq);return this._readableState.length=Jq.length,this};var u=1073741824;function b(qq){if(qq>u)throw new v("size","<= 1GiB",qq);else qq--,qq|=qq>>>1,qq|=qq>>>2,qq|=qq>>>4,qq|=qq>>>8,qq|=qq>>>16,qq++;return qq}function m(qq,Qq){if(qq<=0||Qq.length===0&&Qq.ended)return 0;if(Qq.objectMode)return 1;if(H(qq)){if(Qq.flowing&&Qq.length)return Qq.buffer.first().length;return Qq.length}if(qq<=Qq.length)return qq;return Qq.ended?Qq.length:0}F.prototype.read=function(qq){if(Aq&&Nq("read - n =",qq,this.__id),!J(qq))qq=K(qq,10);const Qq=this._readableState,Xq=qq;if(qq>Qq.highWaterMark)Qq.highWaterMark=b(qq);if(qq!==0)Qq.emittedReadable=!1;if(qq===0&&Qq.needReadable&&((Qq.highWaterMark!==0?Qq.length>=Qq.highWaterMark:Qq.length>0)||Qq.ended)){if(Aq&&Nq("read: emitReadable or endReadable",Qq.length,Qq.ended,this.__id),Qq.length===0&&Qq.ended)s(this);else O(this,Qq);return null}if(qq=m(qq,Qq),qq===0&&Qq.ended){if(Aq&&Nq("read: calling endReadable if length 0 -- length, state.ended",Qq.length,Qq.ended,this.__id),Qq.length===0)s(this);return null}let Jq=Qq.needReadable;if(Aq&&Nq("need readable",Jq,this.__id),Qq.length===0||Qq.length-qq0)Kq=o(qq,Qq);else Kq=null;if(Aq&&Nq("ret @ read",Kq,this.__id),Kq===null)Qq.needReadable=Qq.length<=Qq.highWaterMark,Aq&&Nq("state.length while ret = null",Qq.length,this.__id),qq=0;else if(Qq.length-=qq,Qq.multiAwaitDrain)Qq.awaitDrainWriters.clear();else Qq.awaitDrainWriters=null;if(Qq.length===0){if(!Qq.ended)Qq.needReadable=!0;if(Xq!==qq&&Qq.ended)s(this)}if(Kq!==null&&!Qq.errorEmitted&&!Qq.closeEmitted)Qq.dataEmitted=!0,this.emit("data",Kq);return Kq},F.prototype._read=function(qq){throw new w("_read()")},F.prototype.pipe=function(qq,Qq){const Xq=this,Jq=this._readableState;if(Jq.pipes.length===1){if(!Jq.multiAwaitDrain)Jq.multiAwaitDrain=!0,Jq.awaitDrainWriters=new z(Jq.awaitDrainWriters?[Jq.awaitDrainWriters]:[])}Jq.pipes.push(qq),Aq&&Nq("pipe count=%d opts=%j",Jq.pipes.length,Qq,Xq.__id);const Kq=(!Qq||Qq.end!==!1)&&qq!==process.stdout&&qq!==process.stderr?Bq:Fq;if(Jq.endEmitted)Iq(Kq);else Xq.once("end",Kq);qq.on("unpipe",Zq);function Zq(Lq,jq){if(Aq&&Nq("onunpipe",Xq.__id),Lq===Xq){if(jq&&jq.hasUnpiped===!1)jq.hasUnpiped=!0,zq()}}function Bq(){Aq&&Nq("onend",Xq.__id),qq.end()}let Yq,$q=!1;function zq(){if(Aq&&Nq("cleanup",Xq.__id),qq.removeListener("close",Gq),qq.removeListener("finish",Mq),Yq)qq.removeListener("drain",Yq);if(qq.removeListener("error",Wq),qq.removeListener("unpipe",Zq),Xq.removeListener("end",Bq),Xq.removeListener("end",Fq),Xq.removeListener("data",Uq),$q=!0,Yq&&Jq.awaitDrainWriters&&(!qq._writableState||qq._writableState.needDrain))Yq()}function Vq(){if(!$q){if(Jq.pipes.length===1&&Jq.pipes[0]===qq)Aq&&Nq("false write response, pause",0,Xq.__id),Jq.awaitDrainWriters=qq,Jq.multiAwaitDrain=!1;else if(Jq.pipes.length>1&&Jq.pipes.includes(qq))Aq&&Nq("false write response, pause",Jq.awaitDrainWriters.size,Xq.__id),Jq.awaitDrainWriters.add(qq);Xq.pause()}if(!Yq)Yq=c(Xq,qq),qq.on("drain",Yq)}Xq.on("data",Uq);function Uq(Lq){Aq&&Nq("ondata",Xq.__id);const jq=qq.write(Lq);if(Aq&&Nq("dest.write",jq,Xq.__id),jq===!1)Vq()}function Wq(Lq){if(Nq("onerror",Lq),Fq(),qq.removeListener("error",Wq),qq.listenerCount("error")===0){const jq=qq._writableState||qq._readableState;if(jq&&!jq.errorEmitted)y(qq,Lq);else qq.emit("error",Lq)}}M(qq,"error",Wq);function Gq(){qq.removeListener("finish",Mq),Fq()}qq.once("close",Gq);function Mq(){Nq("onfinish"),qq.removeListener("close",Gq),Fq()}qq.once("finish",Mq);function Fq(){Nq("unpipe"),Xq.unpipe(qq)}if(qq.emit("pipe",Xq),qq.writableNeedDrain===!0){if(Jq.flowing)Vq()}else if(!Jq.flowing)Nq("pipe resume"),Xq.resume();return qq};function c(qq,Qq){return function Xq(){const Jq=qq._readableState;if(Jq.awaitDrainWriters===Qq)Nq("pipeOnDrain",1),Jq.awaitDrainWriters=null;else if(Jq.multiAwaitDrain)Nq("pipeOnDrain",Jq.awaitDrainWriters.size),Jq.awaitDrainWriters.delete(Qq);if((!Jq.awaitDrainWriters||Jq.awaitDrainWriters.size===0)&&qq.listenerCount("data"))qq.resume()}}F.prototype.unpipe=function(qq){const Qq=this._readableState,Xq={hasUnpiped:!1};if(Qq.pipes.length===0)return this;if(!qq){const Hq=Qq.pipes;Qq.pipes=[],this.pause();for(let Kq=0;Kq0,Qq.resumeScheduled&&Qq.paused===!1)Qq.flowing=!0;else if(qq.listenerCount("data")>0)qq.resume();else if(!Qq.readableListening)Qq.flowing=null}function l(qq){Aq&&Nq("on readable nextTick, calling read(0)",qq.__id),qq.read(0)}F.prototype.resume=function(){const qq=this._readableState;if(!qq.flowing)Aq&&Nq("resume",this.__id),qq.flowing=!qq.readableListening,I(this,qq);return qq.paused=!1,this},F.prototype.pause=function(){if(Aq&&Nq("call pause flowing=%j",this._readableState.flowing,this.__id),this._readableState.flowing!==!1)Aq&&Nq("pause",this.__id),this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this},F.prototype.wrap=function(qq){let Qq=!1;qq.on("data",(Jq)=>{if(!this.push(Jq)&&qq.pause)Qq=!0,qq.pause()}),qq.on("end",()=>{this.push(null)}),qq.on("error",(Jq)=>{y(this,Jq)}),qq.on("close",()=>{this.destroy()}),qq.on("destroy",()=>{this.destroy()}),this._read=()=>{if(Qq&&qq.resume)Qq=!1,qq.resume()};const Xq=B(qq);for(let Jq=1;Jq{Hq=Zq?C(Hq,Zq):null,Xq(),Xq=k});try{while(!0){const Zq=qq.destroyed?null:qq.read();if(Zq!==null)yield Zq;else if(Hq)throw Hq;else if(Hq===null)return;else await new $(Jq)}}catch(Zq){throw Hq=C(Hq,Zq),Hq}finally{if((Hq||(Qq===null||Qq===void 0?void 0:Qq.destroyOnReturn)!==!1)&&(Hq===void 0||qq._readableState.autoDestroy))_.destroyer(qq,null);else qq.off("readable",Jq),Kq()}}Z(F.prototype,{readable:{get(){const qq=this._readableState;return!!qq&&qq.readable!==!1&&!qq.destroyed&&!qq.errorEmitted&&!qq.endEmitted},set(qq){if(this._readableState)this._readableState.readable=!!qq}},readableDidRead:{enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{enumerable:!1,get:function(){return this._readableState.flowing},set:function(qq){if(this._readableState)this._readableState.flowing=qq}},readableLength:{enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{get(){return this._readableState?this._readableState.closed:!1}},destroyed:{enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(qq){if(!this._readableState)return;this._readableState.destroyed=qq}},readableEnded:{enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),F._fromList=o;function o(qq,Qq){if(Qq.length===0)return null;let Xq;if(Qq.objectMode)Xq=Qq.buffer.shift();else if(!qq||qq>=Qq.length){if(Qq.decoder)Xq=Qq.buffer.join("");else if(Qq.buffer.length===1)Xq=Qq.buffer.first();else Xq=Qq.buffer.concat(Qq.length);Qq.buffer.clear()}else Xq=Qq.buffer.consume(qq,Qq.decoder);return Xq}function s(qq){const Qq=qq._readableState;if(Aq&&Nq("endEmitted @ endReadable",Qq.endEmitted,qq.__id),!Qq.endEmitted)Qq.ended=!0,Iq(a,Qq,qq)}function a(qq,Qq){if(Aq&&Nq("endReadableNT -- endEmitted, state.length",qq.endEmitted,qq.length,Qq.__id),!qq.errored&&!qq.closeEmitted&&!qq.endEmitted&&qq.length===0){if(qq.endEmitted=!0,Qq.emit("end"),Aq&&Nq("end emitted @ endReadableNT",Qq.__id),Qq.writable&&Qq.allowHalfOpen===!1)Iq(r,Qq);else if(qq.autoDestroy){const Xq=Qq._writableState;if(!Xq||Xq.autoDestroy&&(Xq.finished||Xq.writable===!1))Qq.destroy()}}}function r(qq){if(qq.writable&&!qq.writableEnded&&!qq.destroyed)qq.end()}F.from=function(qq,Qq){return f(F,qq,Qq)};var t={newStreamReadableFromReadableStream:j};function e(){if(t===void 0)t={};return t}F.fromWeb=function(qq,Qq){return e().newStreamReadableFromReadableStream(qq,Qq)},F.toWeb=function(qq){return e().newReadableStreamFromStreamReadable(qq)},F.wrap=function(qq,Qq){var Xq,Jq;return new F({objectMode:(Xq=(Jq=qq.readableObjectMode)!==null&&Jq!==void 0?Jq:qq.objectMode)!==null&&Xq!==void 0?Xq:!0,...Qq,destroy(Hq,Kq){_.destroyer(qq,Hq),Kq(Hq)}}).wrap(qq)}}}),BQ=mq({"node_modules/readable-stream/lib/internal/streams/writable.js"(q,Q){var{ArrayPrototypeSlice:X,Error:J,FunctionPrototypeSymbolHasInstance:H,ObjectDefineProperty:K,ObjectDefineProperties:Z,ObjectSetPrototypeOf:B,StringPrototypeToLowerCase:Y,Symbol:$,SymbolHasInstance:z}=Oq(),V=qQ().Stream,U=eq(),{addAbortSignal:W}=QQ(),{getHighWaterMark:G,getDefaultHighWaterMark:M}=XQ(),{ERR_INVALID_ARG_TYPE:F,ERR_METHOD_NOT_IMPLEMENTED:L,ERR_MULTIPLE_CALLBACK:j,ERR_STREAM_CANNOT_PIPE:N,ERR_STREAM_DESTROYED:A,ERR_STREAM_ALREADY_FINISHED:E,ERR_STREAM_NULL_VALUES:I,ERR_STREAM_WRITE_AFTER_END:T,ERR_UNKNOWN_ENCODING:P}=oq().codes,{errorOrDestroy:x}=U;function O(o={}){const s=this instanceof Cq();if(!s&&!H(O,this))return new O(o);if(this._writableState=new D(o,this,s),o){if(typeof o.write==="function")this._write=o.write;if(typeof o.writev==="function")this._writev=o.writev;if(typeof o.destroy==="function")this._destroy=o.destroy;if(typeof o.final==="function")this._final=o.final;if(typeof o.construct==="function")this._construct=o.construct;if(o.signal)W(o.signal,this)}V.call(this,o),U.construct(this,()=>{const a=this._writableState;if(!a.writing)p(this,a);c(this,a)})}B(O.prototype,V.prototype),B(O,V),Q.exports=O;function _(){}var C=$("kOnFinished");function D(o,s,a){if(typeof a!=="boolean")a=s instanceof Cq();if(this.objectMode=!!(o&&o.objectMode),a)this.objectMode=this.objectMode||!!(o&&o.writableObjectMode);this.highWaterMark=o?G(this,o,"writableHighWaterMark",a):M(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const r=!!(o&&o.decodeStrings===!1);this.decodeStrings=!r,this.defaultEncoding=o&&o.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=f.bind(void 0,s),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,w(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!o||o.emitClose!==!1,this.autoDestroy=!o||o.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[C]=[]}function w(o){o.buffered=[],o.bufferedIndex=0,o.allBuffers=!0,o.allNoop=!0}D.prototype.getBuffer=function o(){return X(this.buffered,this.bufferedIndex)},K(D.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),K(O,z,{value:function(o){if(H(this,o))return!0;if(this!==O)return!1;return o&&o._writableState instanceof D}}),O.prototype.pipe=function(){x(this,new N)};function v(o,s,a,r){const t=o._writableState;if(typeof a==="function")r=a,a=t.defaultEncoding;else{if(!a)a=t.defaultEncoding;else if(a!=="buffer"&&!Buffer.isEncoding(a))throw new P(a);if(typeof r!=="function")r=_}if(s===null)throw new I;else if(!t.objectMode)if(typeof s==="string"){if(t.decodeStrings!==!1)s=Buffer.from(s,a),a="buffer"}else if(s instanceof Buffer)a="buffer";else if(V._isUint8Array(s))s=V._uint8ArrayToBuffer(s),a="buffer";else throw new F("chunk",["string","Buffer","Uint8Array"],s);let e;if(t.ending)e=new T;else if(t.destroyed)e=new A("write");if(e)return Iq(r,e),x(o,e,!0),e;return t.pendingcb++,R(o,t,s,a,r)}O.prototype.write=function(o,s,a){return v(this,o,s,a)===!0},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){const o=this._writableState;if(o.corked){if(o.corked--,!o.writing)p(this,o)}},O.prototype.setDefaultEncoding=function o(s){if(typeof s==="string")s=Y(s);if(!Buffer.isEncoding(s))throw new P(s);return this._writableState.defaultEncoding=s,this};function R(o,s,a,r,t){const e=s.objectMode?1:a.length;s.length+=e;const qq=s.lengtha.bufferedIndex)p(o,a);if(r)if(a.afterWriteTickInfo!==null&&a.afterWriteTickInfo.cb===t)a.afterWriteTickInfo.count++;else a.afterWriteTickInfo={count:1,cb:t,stream:o,state:a},Iq(k,a.afterWriteTickInfo);else y(o,a,1,t)}}function k({stream:o,state:s,count:a,cb:r}){return s.afterWriteTickInfo=null,y(o,s,a,r)}function y(o,s,a,r){if(!s.ending&&!o.destroyed&&s.length===0&&s.needDrain)s.needDrain=!1,o.emit("drain");while(a-- >0)s.pendingcb--,r();if(s.destroyed)h(s);c(o,s)}function h(o){if(o.writing)return;for(let t=o.bufferedIndex;t1&&o._writev){s.pendingcb-=e-1;const Qq=s.allNoop?_:(Jq)=>{for(let Hq=qq;Hq256)a.splice(0,qq),s.bufferedIndex=0;else s.bufferedIndex=qq}s.bufferProcessing=!1}O.prototype._write=function(o,s,a){if(this._writev)this._writev([{chunk:o,encoding:s}],a);else throw new L("_write()")},O.prototype._writev=null,O.prototype.end=function(o,s,a,r=!1){const t=this._writableState;if(Aq&&Nq("end",t,this.__id),typeof o==="function")a=o,o=null,s=null;else if(typeof s==="function")a=s,s=null;let e;if(o!==null&&o!==void 0){let qq;if(!r)qq=v(this,o,s);else qq=this.write(o,s);if(qq instanceof J)e=qq}if(t.corked)t.corked=1,this.uncork();if(e)this.emit("error",e);else if(!t.errored&&!t.ending)t.ending=!0,c(this,t,!0),t.ended=!0;else if(t.finished)e=new E("end");else if(t.destroyed)e=new A("end");if(typeof a==="function")if(e||t.finished)Iq(a,e);else t[C].push(a);return this};function u(o,s){var a=o.ending&&!o.destroyed&&o.constructed&&o.length===0&&!o.errored&&o.buffered.length===0&&!o.finished&&!o.writing&&!o.errorEmitted&&!o.closeEmitted;return Nq("needFinish",a,s),a}function b(o,s){let a=!1;function r(t){if(a){x(o,t!==null&&t!==void 0?t:j());return}if(a=!0,s.pendingcb--,t){const e=s[C].splice(0);for(let qq=0;qq{if(u(t))d(r,t);else t.pendingcb--},o,s);else if(u(s))s.pendingcb++,d(o,s)}}function d(o,s){s.pendingcb--,s.finished=!0;const a=s[C].splice(0);for(let r=0;r{if(g!=null)throw new U("nully","body",g)},(g)=>{W(R,g)});return R=new A({objectMode:!0,readable:!1,write:C,final(g){D(async()=>{try{await S,Iq(g,null)}catch(f){Iq(g,f)}})},destroy:w})}throw new U("Iterable, AsyncIterable or AsyncFunction",x,_)}if(j(P))return T(P.arrayBuffer());if(H(P))return L(A,P,{objectMode:!0,writable:!1});if(typeof(P===null||P===void 0?void 0:P.writable)==="object"||typeof(P===null||P===void 0?void 0:P.readable)==="object"){const _=P!==null&&P!==void 0&&P.readable?Z(P===null||P===void 0?void 0:P.readable)?P===null||P===void 0?void 0:P.readable:T(P.readable):void 0,C=P!==null&&P!==void 0&&P.writable?B(P===null||P===void 0?void 0:P.writable)?P===null||P===void 0?void 0:P.writable:T(P.writable):void 0;return I({readable:_,writable:C})}const O=P===null||P===void 0?void 0:P.then;if(typeof O==="function"){let _;return N(O,P,(C)=>{if(C!=null)_.push(C);_.push(null)},(C)=>{W(_,C)}),_=new A({objectMode:!0,writable:!1,read(){}})}throw new V(x,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],P)};function E(T){let{promise:P,resolve:x}=F();const O=new AbortController,_=O.signal;return{value:T(async function*(){while(!0){const D=P;P=null;const{chunk:w,done:v,cb:R}=await D;if(Iq(R),v)return;if(_.aborted)throw new z(void 0,{cause:_.reason});({promise:P,resolve:x}=F()),yield w}}(),{signal:_}),write(D,w,v){const R=x;x=null,R({chunk:D,done:!1,cb:v})},final(D){const w=x;x=null,w({done:!0,cb:D})},destroy(D,w){O.abort(),w(D)}}}function I(T){const P=T.readable&&typeof T.readable.read!=="function"?M.wrap(T.readable):T.readable,x=T.writable;let O=!!X(P),_=!!J(x),C,D,w,v,R;function S(g){const f=v;if(v=null,f)f(g);else if(g)R.destroy(g);else if(!O&&!_)R.destroy()}if(R=new A({readableObjectMode:!!(P!==null&&P!==void 0&&P.readableObjectMode),writableObjectMode:!!(x!==null&&x!==void 0&&x.writableObjectMode),readable:O,writable:_}),_)$(x,(g)=>{if(_=!1,g)W(P,g);S(g)}),R._write=function(g,f,k){if(x.write(g,f))k();else C=k},R._final=function(g){x.end(),D=g},x.on("drain",function(){if(C){const g=C;C=null,g()}}),x.on("finish",function(){if(D){const g=D;D=null,g()}});if(O)$(P,(g)=>{if(O=!1,g)W(P,g);S(g)}),P.on("readable",function(){if(w){const g=w;w=null,g()}}),P.on("end",function(){R.push(null)}),R._read=function(){while(!0){const g=P.read();if(g===null){w=R._read;return}if(!R.push(g))return}};return R._destroy=function(g,f){if(!g&&v!==null)g=new z;if(w=null,C=null,D=null,v===null)f(g);else v=f,W(x,g),W(P,g)},R}}}),Cq=mq({"node_modules/readable-stream/lib/internal/streams/duplex.js"(q,Q){var{ObjectDefineProperties:X,ObjectGetOwnPropertyDescriptor:J,ObjectKeys:H,ObjectSetPrototypeOf:K}=Oq(),Z=ZQ();function B(U){if(!(this instanceof B))return new B(U);if(Z.call(this,U),Eq.call(this,U),U){if(this.allowHalfOpen=U.allowHalfOpen!==!1,U.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(U.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}Q.exports=B,K(B.prototype,Z.prototype),K(B,Z);for(var Y in Eq.prototype)if(!B.prototype[Y])B.prototype[Y]=Eq.prototype[Y];X(B.prototype,{writable:J(Eq.prototype,"writable"),writableHighWaterMark:J(Eq.prototype,"writableHighWaterMark"),writableObjectMode:J(Eq.prototype,"writableObjectMode"),writableBuffer:J(Eq.prototype,"writableBuffer"),writableLength:J(Eq.prototype,"writableLength"),writableFinished:J(Eq.prototype,"writableFinished"),writableCorked:J(Eq.prototype,"writableCorked"),writableEnded:J(Eq.prototype,"writableEnded"),writableNeedDrain:J(Eq.prototype,"writableNeedDrain"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(U){if(this._readableState&&this._writableState)this._readableState.destroyed=U,this._writableState.destroyed=U}}});var $;function z(){if($===void 0)$={};return $}B.fromWeb=function(U,W){return z().newStreamDuplexFromReadableWritablePair(U,W)},B.toWeb=function(U){return z().newReadableWritablePairFromDuplex(U)};var V;B.from=function(U){if(!V)V=YQ();return V(U,"body")}}}),$Q=mq({"node_modules/readable-stream/lib/internal/streams/transform.js"(q,Q){var{ObjectSetPrototypeOf:X,Symbol:J}=Oq(),{ERR_METHOD_NOT_IMPLEMENTED:H}=oq().codes,K=Cq();function Z(z){if(!(this instanceof Z))return new Z(z);if(K.call(this,z),this._readableState.sync=!1,this[B]=null,z){if(typeof z.transform==="function")this._transform=z.transform;if(typeof z.flush==="function")this._flush=z.flush}this.on("prefinish",$.bind(this))}X(Z.prototype,K.prototype),X(Z,K),Q.exports=Z;var B=J("kCallback");function Y(z){if(typeof this._flush==="function"&&!this.destroyed)this._flush((V,U)=>{if(V){if(z)z(V);else this.destroy(V);return}if(U!=null)this.push(U);if(this.push(null),z)z()});else if(this.push(null),z)z()}function $(){if(this._final!==Y)Y.call(this)}Z.prototype._final=Y,Z.prototype._transform=function(z,V,U){throw new H("_transform()")},Z.prototype._write=function(z,V,U){const W=this._readableState,G=this._writableState,M=W.length;this._transform(z,V,(F,L)=>{if(F){U(F);return}if(L!=null)this.push(L);if(G.ended||M===W.length||W.length{g=!0});const f=K(v,{readable:R,writable:S},(k)=>{g=!k});return{destroy:(k)=>{if(g)return;g=!0,B.destroyer(v,k||new W("pipe"))},cleanup:f}}function P(v){return M(v[v.length-1],"streams[stream.length - 1]"),v.pop()}function x(v){if(L(v))return v;else if(N(v))return O(v);throw new z("val",["Readable","Iterable","AsyncIterable"],v)}async function*O(v){if(!I)I=ZQ();yield*I.prototype[H].call(v)}async function _(v,R,S,{end:g}){let f,k=null;const y=(u)=>{if(u)f=u;if(k){const b=k;k=null,b()}},h=()=>new J((u,b)=>{if(f)b(f);else k=()=>{if(f)b(f);else u()}});R.on("drain",y);const p=K(R,{readable:!1},y);try{if(R.writableNeedDrain)await h();for await(let u of v)if(!R.write(u))await h();if(g)R.end();await h(),S()}catch(u){S(f!==u?$(f,u):u)}finally{p(),R.off("drain",y)}}function C(...v){return D(v,Z(P(v)))}function D(v,R,S){if(v.length===1&&X(v[0]))v=v[0];if(v.length<2)throw new U("streams");const g=new AbortController,f=g.signal,k=S===null||S===void 0?void 0:S.signal,y=[];F(k,"options.signal");function h(){d(new G)}k===null||k===void 0||k.addEventListener("abort",h);let p,u;const b=[];let m=0;function c(n){d(n,--m===0)}function d(n,o){if(n&&(!p||p.code==="ERR_STREAM_PREMATURE_CLOSE"))p=n;if(!p&&!o)return;while(b.length)b.shift()(p);if(k===null||k===void 0||k.removeEventListener("abort",h),g.abort(),o){if(!p)y.forEach((s)=>s());Iq(R,p,u)}}let l;for(let n=0;n0,r=s||(S===null||S===void 0?void 0:S.end)!==!1,t=n===v.length-1;if(A(o)){let e=function(qq){if(qq&&qq.name!=="AbortError"&&qq.code!=="ERR_STREAM_PREMATURE_CLOSE")c(qq)};if(r){const{destroy:qq,cleanup:Qq}=T(o,s,a);if(b.push(qq),j(o)&&t)y.push(Qq)}if(o.on("error",e),j(o)&&t)y.push(()=>{o.removeListener("error",e)})}if(n===0)if(typeof o==="function"){if(l=o({signal:f}),!L(l))throw new V("Iterable, AsyncIterable or Stream","source",l)}else if(L(o)||N(o))l=o;else l=Y.from(o);else if(typeof o==="function")if(l=x(l),l=o(l,{signal:f}),s){if(!L(l,!0))throw new V("AsyncIterable",`transform[${n-1}]`,l)}else{var i;if(!E)E=zQ();const e=new E({objectMode:!0}),qq=(i=l)===null||i===void 0?void 0:i.then;if(typeof qq==="function")m++,qq.call(l,(Jq)=>{if(u=Jq,Jq!=null)e.write(Jq);if(r)e.end();Iq(c)},(Jq)=>{e.destroy(Jq),Iq(c,Jq)});else if(L(l,!0))m++,_(l,e,c,{end:r});else throw new V("AsyncIterable or Promise","destination",l);l=e;const{destroy:Qq,cleanup:Xq}=T(l,!1,!0);if(b.push(Qq),t)y.push(Xq)}else if(A(o)){if(N(l)){m+=2;const e=w(l,o,c,{end:r});if(j(o)&&t)y.push(e)}else if(L(l))m++,_(l,o,c,{end:r});else throw new z("val",["Readable","Iterable","AsyncIterable"],l);l=o}else l=Y.from(o)}if(f!==null&&f!==void 0&&f.aborted||k!==null&&k!==void 0&&k.aborted)Iq(h);return l}function w(v,R,S,{end:g}){if(v.pipe(R,{end:g}),g)v.once("end",()=>R.end());else S();return K(v,{readable:!0,writable:!1},(f)=>{const k=v._readableState;if(f&&f.code==="ERR_STREAM_PREMATURE_CLOSE"&&k&&k.ended&&!k.errored&&!k.errorEmitted)v.once("end",S).once("error",S);else S(f)}),K(R,{readable:!1,writable:!0},S)}Q.exports={pipelineImpl:D,pipeline:C}}}),UQ=mq({"node_modules/readable-stream/lib/internal/streams/compose.js"(q,Q){var{pipeline:X}=VQ(),J=Cq(),{destroyer:H}=eq(),{isNodeStream:K,isReadable:Z,isWritable:B}=aq(),{AbortError:Y,codes:{ERR_INVALID_ARG_VALUE:$,ERR_MISSING_ARGS:z}}=oq();Q.exports=function V(...U){if(U.length===0)throw new z("streams");if(U.length===1)return J.from(U[0]);const W=[...U];if(typeof U[0]==="function")U[0]=J.from(U[0]);if(typeof U[U.length-1]==="function"){const P=U.length-1;U[P]=J.from(U[P])}for(let P=0;P0&&!B(U[P]))throw new $(`streams[${P}]`,W[P],"must be writable")}let G,M,F,L,j;function N(P){const x=L;if(L=null,x)x(P);else if(P)j.destroy(P);else if(!T&&!I)j.destroy()}const A=U[0],E=X(U,N),I=!!B(A),T=!!Z(E);if(j=new J({writableObjectMode:!!(A!==null&&A!==void 0&&A.writableObjectMode),readableObjectMode:!!(E!==null&&E!==void 0&&E.writableObjectMode),writable:I,readable:T}),I)j._write=function(P,x,O){if(A.write(P,x))O();else G=O},j._final=function(P){A.end(),M=P},A.on("drain",function(){if(G){const P=G;G=null,P()}}),E.on("finish",function(){if(M){const P=M;M=null,P()}});if(T)E.on("readable",function(){if(F){const P=F;F=null,P()}}),E.on("end",function(){j.push(null)}),j._read=function(){while(!0){const P=E.read();if(P===null){F=j._read;return}if(!j.push(P))return}};return j._destroy=function(P,x){if(!P&&L!==null)P=new Y;if(F=null,G=null,M=null,L===null)x(P);else L=x,H(E,P)},j}}}),WQ=mq({"node_modules/readable-stream/lib/stream/promises.js"(q,Q){var{ArrayPrototypePop:X,Promise:J}=Oq(),{isIterable:H,isNodeStream:K}=aq(),{pipelineImpl:Z}=VQ(),{finished:B}=rq();function Y(...$){return new J((z,V)=>{let U,W;const G=$[$.length-1];if(G&&typeof G==="object"&&!K(G)&&!H(G)){const M=X($);U=M.signal,W=M.end}Z($,(M,F)=>{if(M)V(M);else z(F)},{signal:U,end:W})})}Q.exports={finished:B,pipeline:Y}}}),GQ=mq({"node_modules/readable-stream/lib/stream.js"(q,Q){var{ObjectDefineProperty:X,ObjectKeys:J,ReflectApply:H}=Oq(),{promisify:{custom:K}}=_q(),{streamReturningOperators:Z,promiseReturningOperators:B}=tq(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:Y}}=oq(),$=UQ(),{pipeline:z}=VQ(),{destroyer:V}=eq(),U=rq(),W=WQ(),G=aq(),M=Q.exports=qQ().Stream;M.isDisturbed=G.isDisturbed,M.isErrored=G.isErrored,M.isWritable=G.isWritable,M.isReadable=G.isReadable,M.Readable=ZQ();for(let L of J(Z)){let j=function(...A){if(new.target)throw Y();return M.Readable.from(H(N,this,A))};const N=Z[L];X(j,"name",{value:N.name}),X(j,"length",{value:N.length}),X(M.Readable.prototype,L,{value:j,enumerable:!1,configurable:!0,writable:!0})}for(let L of J(B)){let j=function(...A){if(new.target)throw Y();return H(N,this,A)};const N=B[L];X(j,"name",{value:N.name}),X(j,"length",{value:N.length}),X(M.Readable.prototype,L,{value:j,enumerable:!1,configurable:!0,writable:!0})}M.Writable=BQ(),M.Duplex=Cq(),M.Transform=$Q(),M.PassThrough=zQ(),M.pipeline=z;var{addAbortSignal:F}=QQ();M.addAbortSignal=F,M.finished=U,M.destroy=V,M.compose=$,X(M,"promises",{configurable:!0,enumerable:!0,get(){return W}}),X(z,K,{enumerable:!0,get(){return W.pipeline}}),X(U,K,{enumerable:!0,get(){return W.finished}}),M.Stream=M,M._isUint8Array=function L(j){return j instanceof Uint8Array},M._uint8ArrayToBuffer=function L(j){return new Buffer(j.buffer,j.byteOffset,j.byteLength)}}}),MQ=mq({"node_modules/readable-stream/lib/ours/index.js"(q,Q){const X=GQ(),J=WQ(),H=X.Readable.destroy;Q.exports=X,Q.exports._uint8ArrayToBuffer=X._uint8ArrayToBuffer,Q.exports._isUint8Array=X._isUint8Array,Q.exports.isDisturbed=X.isDisturbed,Q.exports.isErrored=X.isErrored,Q.exports.isWritable=X.isWritable,Q.exports.isReadable=X.isReadable,Q.exports.Readable=X.Readable,Q.exports.Writable=X.Writable,Q.exports.Duplex=X.Duplex,Q.exports.Transform=X.Transform,Q.exports.PassThrough=X.PassThrough,Q.exports.addAbortSignal=X.addAbortSignal,Q.exports.finished=X.finished,Q.exports.destroy=X.destroy,Q.exports.destroy=H,Q.exports.pipeline=X.pipeline,Q.exports.compose=X.compose,Q.exports._getNativeReadableStreamPrototype=jQ,Q.exports.NativeWritable=pQ,Tq.defineProperty(X,"promises",{configurable:!0,enumerable:!0,get(){return J}}),Q.exports.Stream=X.Stream,Q.exports.default=Q.exports}}),LQ={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0},Eq=BQ(),pQ=class q extends Eq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(Q,X={}){super(X);this._construct=this.#J,this._destroy=this.#K,this._final=this.#Z,this.#q=Q}#J(Q){this._writableState.constructed=!0,this.constructed=!0,Q()}#H(){if(typeof this.#q==="object")if(typeof this.#q.write==="function")this.#Q=this.#q;else throw new Error("Invalid FileSink");else this.#Q=Bun.file(this.#q).writer()}write(Q,X,J,H=this.#X){if(!H)return this.#X=!1,super.write(Q,X,J);if(!this.#Q)this.#H();var K=this.#Q,Z=K.write(Q);if(xq(Z))return Z.then(()=>{this.emit("drain"),K.flush(!0)}),!1;if(K.flush(!0),J)J(null,Q.byteLength);return!0}end(Q,X,J,H=this.#X){return super.end(Q,X,J,H)}#K(Q,X){if(this._writableState.destroyed=!0,X)X(Q)}#Z(Q){if(this.#Q)this.#Q.end();if(Q)Q()}ref(){if(!this.#Q)this.#H();this.#Q.ref()}unref(){if(!this.#Q)return;this.#Q.unref()}},AQ=MQ();AQ[Symbol.for("CommonJS")]=0;AQ[Symbol.for("::bunternal::")]={_ReadableFromWeb:HQ,_ReadableFromWebForUndici:KQ};var lQ=AQ,EQ=AQ._uint8ArrayToBuffer,IQ=AQ._isUint8Array,TQ=AQ.isDisturbed,PQ=AQ.isErrored,xQ=AQ.isWritable,OQ=AQ.isReadable,_Q=AQ.Readable,Eq=AQ.Writable,CQ=AQ.Duplex,DQ=AQ.Transform,wQ=AQ.PassThrough,vQ=AQ.addAbortSignal,RQ=AQ.finished,SQ=AQ.destroy,gQ=AQ.pipeline,fQ=AQ.compose,kQ=AQ.Stream,yQ=AQ["eos"]=rq,hQ=AQ._getNativeReadableStreamPrototype,pQ=AQ.NativeWritable,uQ=kQ.promises;export{uQ as promises,gQ as pipeline,xQ as isWritable,OQ as isReadable,PQ as isErrored,TQ as isDisturbed,RQ as finished,yQ as eos,SQ as destroy,lQ as default,fQ as compose,vQ as addAbortSignal,EQ as _uint8ArrayToBuffer,IQ as _isUint8Array,hQ as _getNativeReadableStreamPrototype,Eq as Writable,DQ as Transform,kQ as Stream,_Q as Readable,wQ as PassThrough,pQ as NativeWritable,CQ as Duplex}; diff --git a/src/js/out/modules/node/stream.promises.js b/src/js/out/modules/node/stream.promises.js index b25dc7b50..f095ac718 100644 --- a/src/js/out/modules/node/stream.promises.js +++ b/src/js/out/modules/node/stream.promises.js @@ -1 +1 @@ -var{promises:o}=import.meta.require("node:stream"),{pipeline:m,finished:C}=o,J={pipeline:m,finished:C,[Symbol.for("CommonJS")]:0};export{m as pipeline,C as finished,J as default}; +import{promises as S} from"node:stream";var{pipeline:b,finished:c}=S,g={pipeline:b,finished:c,[Symbol.for("CommonJS")]:0};export{b as pipeline,c as finished,g as default}; diff --git a/src/js/out/modules/node/timers.promises.js b/src/js/out/modules/node/timers.promises.js index ff4640cf2..d76e46f3c 100644 --- a/src/js/out/modules/node/timers.promises.js +++ b/src/js/out/modules/node/timers.promises.js @@ -173,8 +173,10 @@ class AbortError extends Error { this.code = "ABORT_ERR"; } } +var timers_promises_default = { setTimeout: setTimeoutPromise, setImmediate: setImmediatePromise, setInterval: setIntervalPromise }; export { setTimeoutPromise as setTimeout, setIntervalPromise as setInterval, - setImmediatePromise as setImmediate + setImmediatePromise as setImmediate, + timers_promises_default as default }; diff --git a/src/js/out/modules/node/tls.js b/src/js/out/modules/node/tls.js index 1e436a85f..4cceadc7f 100644 --- a/src/js/out/modules/node/tls.js +++ b/src/js/out/modules/node/tls.js @@ -1,4 +1,5 @@ -var {isTypedArray } = import.meta.require("node:util/types"); +import {isTypedArray} from "node:util/types"; +import net, {Server as NetServer} from "node:net"; var parseCertString = function() { throwNotImplemented("Not implemented"); }, isValidTLSArray = function(obj) { @@ -16,7 +17,12 @@ var parseCertString = function() { return new SecureContext(options); }, createServer = function(options, connectionListener) { return new Server(options, connectionListener); -}, InternalSecureContext = class SecureContext2 { +}, getCiphers = function() { + return DEFAULT_CIPHERS.split(":"); +}, getCurves = function() { + return; +}, convertALPNProtocols = function(protocols, out) { +}, InternalTCPSocket = net[Symbol.for("::bunternal::")], InternalSecureContext = class SecureContext2 { context; constructor(options) { const context = {}; @@ -54,7 +60,7 @@ var parseCertString = function() { } this.context = context; } -}, { [Symbol.for("::bunternal::")]: InternalTCPSocket, Server: NetServer } = import.meta.require("net"), buntls = Symbol.for("::buntls::"), SocketClass, TLSSocket = function(InternalTLSSocket) { +}, buntls = Symbol.for("::buntls::"), SocketClass, TLSSocket = function(InternalTLSSocket) { return SocketClass = InternalTLSSocket, Object.defineProperty(SocketClass.prototype, Symbol.toStringTag, { value: "TLSSocket", enumerable: !1 @@ -209,37 +215,37 @@ var CLIENT_RENEG_LIMIT = 3, CLIENT_RENEG_WINDOW = 600, DEFAULT_ECDH_CURVE = "aut return new TLSSocket(port).connect(port, host, connectListener); return new TLSSocket().connect(port, host, connectListener); }, connect = createConnection, exports = { - createSecureContext, - parseCertString, - getCiphers() { - return DEFAULT_CIPHERS.split(":"); - }, - getCurves() { - return; - }, - convertALPNProtocols(protocols, out) { - }, - TLSSocket, - SecureContext, + [Symbol.for("CommonJS")]: 0, CLIENT_RENEG_LIMIT, CLIENT_RENEG_WINDOW, - DEFAULT_ECDH_CURVE, - DEFAULT_CIPHERS, - DEFAULT_MIN_VERSION, - DEFAULT_MAX_VERSION, - [Symbol.for("CommonJS")]: 0, connect, + convertALPNProtocols, createConnection, + createSecureContext, + createServer, + DEFAULT_CIPHERS, + DEFAULT_ECDH_CURVE, + DEFAULT_MAX_VERSION, + DEFAULT_MIN_VERSION, + getCiphers, + getCurves, + parseCertString, + SecureContext, Server, - createServer -}, tls_default = exports; + TLSSocket +}; export { parseCertString, - tls_default as default, + getCurves, + getCiphers, + exports as default, + createServer, createSecureContext, createConnection, + convertALPNProtocols, connect, TLSSocket, + Server, SecureContext, DEFAULT_MIN_VERSION, DEFAULT_MAX_VERSION, diff --git a/src/js/out/modules/node/url.js b/src/js/out/modules/node/url.js index cfc70e725..25172c68f 100644 --- a/src/js/out/modules/node/url.js +++ b/src/js/out/modules/node/url.js @@ -1,36 +1,44 @@ -var it = function(s) { - return typeof s == "string"; -}, D = function(s) { - return typeof s == "object" && s !== null; -}, I = function(s) { - return s === null; -}, E = function(s) { - return s == null; -}; -var m = function() { +var Url = function() { this.protocol = null, this.slashes = null, this.auth = null, this.host = null, this.port = null, this.hostname = null, this.hash = null, this.search = null, this.query = null, this.pathname = null, this.path = null, this.href = null; -}, A = function(s, r, t) { - if (s && D(s) && s instanceof m) - return s; - var o = new m; - return o.parse(s, r, t), o; -}, V = function(s) { - return it(s) && (s = A(s)), s instanceof m ? s.format() : m.prototype.format.call(s); -}, W = function(s, r) { - return A(s, !1, !0).resolve(r); -}, X = function(s, r) { - return s ? A(s, !1, !0).resolveObject(r) : r; -}, { URL: F, URLSearchParams: M, [Symbol.for("Bun.lazy")]: S } = globalThis, tt = /^([a-z0-9.+-]+:)/i, st = /:[0-9]*$/, ht = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, et = [ - "<", - ">", - '"', - "`", - " ", - "\r", - ` -`, - " " -], rt = ["{", "}", "|", "\\", "^", "`"].concat(et), B = ["'"].concat(rt), G = ["%", "/", "?", ";", "#"].concat(B), J = ["/", "?", "#"], ot = 255, K = /^[+a-z0-9A-Z_-]{0,63}$/, at = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, nt = { javascript: !0, "javascript:": !0 }, N = { javascript: !0, "javascript:": !0 }, R = { +}, urlParse = function(url, parseQueryString, slashesDenoteHost) { + if (url && typeof url === "object" && url instanceof Url) + return url; + var u = new Url; + return u.parse(url, parseQueryString, slashesDenoteHost), u; +}, urlFormat = function(obj) { + if (typeof obj === "string") + obj = urlParse(obj); + if (!(obj instanceof Url)) + return Url.prototype.format.call(obj); + return obj.format(); +}, urlResolve = function(source, relative) { + return urlParse(source, !1, !0).resolve(relative); +}, urlResolveObject = function(source, relative) { + if (!source) + return relative; + return urlParse(source, !1, !0).resolveObject(relative); +}, urlToHttpOptions = function(url) { + const options = { + protocol: url.protocol, + hostname: typeof url.hostname === "string" && url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : url.hostname, + hash: url.hash, + search: url.search, + pathname: url.pathname, + path: `${url.pathname || ""}${url.search || ""}`, + href: url.href + }; + if (url.port !== "") + options.port = Number(url.port); + if (url.username || url.password) + options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`; + return options; +}, { URL, URLSearchParams } = globalThis, protocolPattern = /^([a-z0-9.+-]+:)/i, portPattern = /:[0-9]*$/, simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/, delims = ["<", ">", '"', "`", " ", "\r", "\n", "\t"], unwise = ["{", "}", "|", "\\", "^", "`"].concat(delims), autoEscape = ["'"].concat(unwise), nonHostChars = ["%", "/", "?", ";", "#"].concat(autoEscape), hostEndingChars = ["/", "?", "#"], hostnameMaxLen = 255, hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, unsafeProtocol = { + javascript: !0, + "javascript:": !0 +}, hostlessProtocol = { + javascript: !0, + "javascript:": !0 +}, slashedProtocol = { http: !0, https: !0, ftp: !0, @@ -41,196 +49,318 @@ var m = function() { "ftp:": !0, "gopher:": !0, "file:": !0 -}, Z = { - parse(s) { - var r = decodeURIComponent; - return (s + "").replace(/\+/g, " ").split("&").filter(Boolean).reduce(function(t, o, a) { - var l = o.split("="), f = r(l[0] || ""), h = r(l[1] || ""), g = t[f]; - return t[f] = g === void 0 ? h : [].concat(g, h), t; - }, {}); - }, - stringify(s) { - var r = encodeURIComponent; - return Object.keys(s || {}).reduce(function(t, o) { - return [].concat(s[o]).forEach(function(a) { - t.push(r(o) + "=" + r(a)); - }), t; - }, []).join("&").replace(/\s/g, "+"); - } }; -m.prototype.parse = function(s, r, t) { - if (!it(s)) - throw new TypeError("Parameter 'url' must be a string, not " + typeof s); - var o = s.indexOf("?"), a = o !== -1 && o < s.indexOf("#") ? "?" : "#", l = s.split(a), f = /\\/g; - l[0] = l[0].replace(f, "/"), s = l.join(a); - var h = s; - if (h = h.trim(), !t && s.split("#").length === 1) { - var g = ht.exec(h); - if (g) - return this.path = h, this.href = h, this.pathname = g[1], g[2] ? (this.search = g[2], r ? this.query = Z.parse(this.search.substr(1)) : this.query = this.search.substr(1)) : r && (this.search = "", this.query = {}), this; +Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { + if (typeof url !== "string") + throw new TypeError("Parameter 'url' must be a string, not " + typeof url); + var queryIndex = url.indexOf("?"), splitter = queryIndex !== -1 && queryIndex < url.indexOf("#") ? "?" : "#", uSplit = url.split(splitter), slashRegex = /\\/g; + uSplit[0] = uSplit[0].replace(slashRegex, "/"), url = uSplit.join(splitter); + var rest = url; + if (rest = rest.trim(), !slashesDenoteHost && url.split("#").length === 1) { + var simplePath = simplePathPattern.exec(rest); + if (simplePath) { + if (this.path = rest, this.href = rest, this.pathname = simplePath[1], simplePath[2]) + if (this.search = simplePath[2], parseQueryString) + this.query = new URLSearchParams(this.search.substr(1)).toJSON(); + else + this.query = this.search.substr(1); + else if (parseQueryString) + this.search = "", this.query = {}; + return this; + } } - var c = tt.exec(h); - if (c) { - c = c[0]; - var v = c.toLowerCase(); - this.protocol = v, h = h.substr(c.length); + var proto = protocolPattern.exec(rest); + if (proto) { + proto = proto[0]; + var lowerProto = proto.toLowerCase(); + this.protocol = lowerProto, rest = rest.substr(proto.length); } - if (t || c || h.match(/^\/\/[^@\/]+@[^@\/]+/)) { - var j = h.substr(0, 2) === "//"; - j && !(c && N[c]) && (h = h.substr(2), this.slashes = !0); + if (slashesDenoteHost || proto || rest.match(/^\/\/[^@/]+@[^@/]+/)) { + var slashes = rest.substr(0, 2) === "//"; + if (slashes && !(proto && hostlessProtocol[proto])) + rest = rest.substr(2), this.slashes = !0; } - if (!N[c] && (j || c && !R[c])) { - for (var u = -1, n = 0;n < J.length; n++) { - var b = h.indexOf(J[n]); - b !== -1 && (u === -1 || b < u) && (u = b); + if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) { + var hostEnd = -1; + for (var i = 0;i < hostEndingChars.length; i++) { + var hec = rest.indexOf(hostEndingChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; } - var P, p; - u === -1 ? p = h.lastIndexOf("@") : p = h.lastIndexOf("@", u), p !== -1 && (P = h.slice(0, p), h = h.slice(p + 1), this.auth = decodeURIComponent(P)), u = -1; - for (var n = 0;n < G.length; n++) { - var b = h.indexOf(G[n]); - b !== -1 && (u === -1 || b < u) && (u = b); + var auth, atSign; + if (hostEnd === -1) + atSign = rest.lastIndexOf("@"); + else + atSign = rest.lastIndexOf("@", hostEnd); + if (atSign !== -1) + auth = rest.slice(0, atSign), rest = rest.slice(atSign + 1), this.auth = decodeURIComponent(auth); + hostEnd = -1; + for (var i = 0;i < nonHostChars.length; i++) { + var hec = rest.indexOf(nonHostChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; } - u === -1 && (u = h.length), this.host = h.slice(0, u), h = h.slice(u), this.parseHost(), this.hostname = this.hostname || ""; - var C = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]"; - if (!C) - for (var e = this.hostname.split(/\./), n = 0, i = e.length;n < i; n++) { - var d = e[n]; - if (!!d && !d.match(K)) { - for (var y = "", x = 0, _ = d.length;x < _; x++) - d.charCodeAt(x) > 127 ? y += "x" : y += d[x]; - if (!y.match(K)) { - var q = e.slice(0, n), O = e.slice(n + 1), U = d.match(at); - U && (q.push(U[1]), O.unshift(U[2])), O.length && (h = "/" + O.join(".") + h), this.hostname = q.join("."); + if (hostEnd === -1) + hostEnd = rest.length; + this.host = rest.slice(0, hostEnd), rest = rest.slice(hostEnd), this.parseHost(), this.hostname = this.hostname || ""; + var ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]"; + if (!ipv6Hostname) { + var hostparts = this.hostname.split(/\./); + for (var i = 0, l = hostparts.length;i < l; i++) { + var part = hostparts[i]; + if (!part) + continue; + if (!part.match(hostnamePartPattern)) { + var newpart = ""; + for (var j = 0, k = part.length;j < k; j++) + if (part.charCodeAt(j) > 127) + newpart += "x"; + else + newpart += part[j]; + if (!newpart.match(hostnamePartPattern)) { + var validParts = hostparts.slice(0, i), notHost = hostparts.slice(i + 1), bit = part.match(hostnamePartStart); + if (bit) + validParts.push(bit[1]), notHost.unshift(bit[2]); + if (notHost.length) + rest = "/" + notHost.join(".") + rest; + this.hostname = validParts.join("."); break; } } } - this.hostname.length > ot ? this.hostname = "" : this.hostname = this.hostname.toLowerCase(), C || (this.hostname = new F(`https://${this.hostname}`).hostname); - var w = this.port ? ":" + this.port : "", H = this.hostname || ""; - this.host = H + w, this.href += this.host, C && (this.hostname = this.hostname.substr(1, this.hostname.length - 2), h[0] !== "/" && (h = "/" + h)); + } + if (this.hostname.length > hostnameMaxLen) + this.hostname = ""; + else + this.hostname = this.hostname.toLowerCase(); + if (!ipv6Hostname) + this.hostname = new URL("http://" + this.hostname).hostname; + var p = this.port ? ":" + this.port : "", h = this.hostname || ""; + if (this.host = h + p, this.href += this.host, ipv6Hostname) { + if (this.hostname = this.hostname.substr(1, this.hostname.length - 2), rest[0] !== "/") + rest = "/" + rest; + } } - if (!nt[v]) - for (var n = 0, i = B.length;n < i; n++) { - var L = B[n]; - if (h.indexOf(L) !== -1) { - var z = encodeURIComponent(L); - z === L && (z = escape(L)), h = h.split(L).join(z); - } + if (!unsafeProtocol[lowerProto]) + for (var i = 0, l = autoEscape.length;i < l; i++) { + var ae = autoEscape[i]; + if (rest.indexOf(ae) === -1) + continue; + var esc = encodeURIComponent(ae); + if (esc === ae) + esc = escape(ae); + rest = rest.split(ae).join(esc); } - var $ = h.indexOf("#"); - $ !== -1 && (this.hash = h.substr($), h = h.slice(0, $)); - var T = h.indexOf("?"); - if (T !== -1 ? (this.search = h.substr(T), this.query = h.substr(T + 1), r && (this.query = Z.parse(this.query)), h = h.slice(0, T)) : r && (this.search = "", this.query = {}), h && (this.pathname = h), R[v] && this.hostname && !this.pathname && (this.pathname = "/"), this.pathname || this.search) { - var w = this.pathname || "", Q = this.search || ""; - this.path = w + Q; + var hash = rest.indexOf("#"); + if (hash !== -1) + this.hash = rest.substr(hash), rest = rest.slice(0, hash); + var qm = rest.indexOf("?"); + if (qm !== -1) { + if (this.search = rest.substr(qm), this.query = rest.substr(qm + 1), parseQueryString) + this.query = new URLSearchParams(this.query); + rest = rest.slice(0, qm); + } else if (parseQueryString) + this.search = "", this.query = {}; + if (rest) + this.pathname = rest; + if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) + this.pathname = "/"; + if (this.pathname || this.search) { + var p = this.pathname || "", s = this.search || ""; + this.path = p + s; } return this.href = this.format(), this; }; -m.prototype.format = function() { - var s = this.auth || ""; - s && (s = encodeURIComponent(s), s = s.replace(/%3A/i, ":"), s += "@"); - var r = this.protocol || "", t = this.pathname || "", o = this.hash || "", a = !1, l = ""; - this.host ? a = s + this.host : this.hostname && (a = s + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]"), this.port && (a += ":" + this.port)), this.query && D(this.query) && Object.keys(this.query).length && (l = Z.stringify(this.query)); - var f = this.search || l && "?" + l || ""; - return r && r.substr(-1) !== ":" && (r += ":"), this.slashes || (!r || R[r]) && a !== !1 ? (a = "//" + (a || ""), t && t.charAt(0) !== "/" && (t = "/" + t)) : a || (a = ""), o && o.charAt(0) !== "#" && (o = "#" + o), f && f.charAt(0) !== "?" && (f = "?" + f), t = t.replace(/[?#]/g, function(h) { - return encodeURIComponent(h); - }), f = f.replace("#", "%23"), r + a + t + f + o; +Url.prototype.format = function() { + var auth = this.auth || ""; + if (auth) + auth = encodeURIComponent(auth), auth = auth.replace(/%3A/i, ":"), auth += "@"; + var protocol = this.protocol || "", pathname = this.pathname || "", hash = this.hash || "", host = !1, query = ""; + if (this.host) + host = auth + this.host; + else if (this.hostname) { + if (host = auth + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]"), this.port) + host += ":" + this.port; + } + if (this.query && typeof this.query === "object" && Object.keys(this.query).length) + query = new URLSearchParams(this.query).toString(); + var search = this.search || query && "?" + query || ""; + if (protocol && protocol.substr(-1) !== ":") + protocol += ":"; + if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== !1) { + if (host = "//" + (host || ""), pathname && pathname.charAt(0) !== "/") + pathname = "/" + pathname; + } else if (!host) + host = ""; + if (hash && hash.charAt(0) !== "#") + hash = "#" + hash; + if (search && search.charAt(0) !== "?") + search = "?" + search; + return pathname = pathname.replace(/[?#]/g, function(match) { + return encodeURIComponent(match); + }), search = search.replace("#", "%23"), protocol + host + pathname + search + hash; }; -m.prototype.resolve = function(s) { - return this.resolveObject(A(s, !1, !0)).format(); +Url.prototype.resolve = function(relative) { + return this.resolveObject(urlParse(relative, !1, !0)).format(); }; -m.prototype.resolveObject = function(s) { - if (it(s)) { - var r = new m; - r.parse(s, !1, !0), s = r; +Url.prototype.resolveObject = function(relative) { + if (typeof relative === "string") { + var rel = new Url; + rel.parse(relative, !1, !0), relative = rel; } - for (var t = new m, o = Object.keys(this), a = 0;a < o.length; a++) { - var l = o[a]; - t[l] = this[l]; + var result = new Url, tkeys = Object.keys(this); + for (var tk = 0;tk < tkeys.length; tk++) { + var tkey = tkeys[tk]; + result[tkey] = this[tkey]; } - if (t.hash = s.hash, s.href === "") - return t.href = t.format(), t; - if (s.slashes && !s.protocol) { - for (var f = Object.keys(s), h = 0;h < f.length; h++) { - var g = f[h]; - g !== "protocol" && (t[g] = s[g]); + if (result.hash = relative.hash, relative.href === "") + return result.href = result.format(), result; + if (relative.slashes && !relative.protocol) { + var rkeys = Object.keys(relative); + for (var rk = 0;rk < rkeys.length; rk++) { + var rkey = rkeys[rk]; + if (rkey !== "protocol") + result[rkey] = relative[rkey]; } - return R[t.protocol] && t.hostname && !t.pathname && (t.path = t.pathname = "/"), t.href = t.format(), t; + if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) + result.pathname = "/", result.path = result.pathname; + return result.href = result.format(), result; } - if (s.protocol && s.protocol !== t.protocol) { - if (!R[s.protocol]) { - for (var c = Object.keys(s), v = 0;v < c.length; v++) { - var j = c[v]; - t[j] = s[j]; + if (relative.protocol && relative.protocol !== result.protocol) { + if (!slashedProtocol[relative.protocol]) { + var keys = Object.keys(relative); + for (var v = 0;v < keys.length; v++) { + var k = keys[v]; + result[k] = relative[k]; } - return t.href = t.format(), t; + return result.href = result.format(), result; } - if (t.protocol = s.protocol, !s.host && !N[s.protocol]) { - for (var i = (s.pathname || "").split("/");i.length && !(s.host = i.shift()); ) + if (result.protocol = relative.protocol, !relative.host && !hostlessProtocol[relative.protocol]) { + var relPath = (relative.pathname || "").split("/"); + while (relPath.length && !(relative.host = relPath.shift())) ; - s.host || (s.host = ""), s.hostname || (s.hostname = ""), i[0] !== "" && i.unshift(""), i.length < 2 && i.unshift(""), t.pathname = i.join("/"); + if (!relative.host) + relative.host = ""; + if (!relative.hostname) + relative.hostname = ""; + if (relPath[0] !== "") + relPath.unshift(""); + if (relPath.length < 2) + relPath.unshift(""); + result.pathname = relPath.join("/"); } else - t.pathname = s.pathname; - if (t.search = s.search, t.query = s.query, t.host = s.host || "", t.auth = s.auth, t.hostname = s.hostname || s.host, t.port = s.port, t.pathname || t.search) { - var u = t.pathname || "", n = t.search || ""; - t.path = u + n; + result.pathname = relative.pathname; + if (result.search = relative.search, result.query = relative.query, result.host = relative.host || "", result.auth = relative.auth, result.hostname = relative.hostname || relative.host, result.port = relative.port, result.pathname || result.search) { + var p = result.pathname || "", s = result.search || ""; + result.path = p + s; + } + return result.slashes = result.slashes || relative.slashes, result.href = result.format(), result; + } + var isSourceAbs = result.pathname && result.pathname.charAt(0) === "/", isRelAbs = relative.host || relative.pathname && relative.pathname.charAt(0) === "/", mustEndAbs = isRelAbs || isSourceAbs || result.host && relative.pathname, removeAllDots = mustEndAbs, srcPath = result.pathname && result.pathname.split("/") || [], relPath = relative.pathname && relative.pathname.split("/") || [], psychotic = result.protocol && !slashedProtocol[result.protocol]; + if (psychotic) { + if (result.hostname = "", result.port = null, result.host) + if (srcPath[0] === "") + srcPath[0] = result.host; + else + srcPath.unshift(result.host); + if (result.host = "", relative.protocol) { + if (relative.hostname = null, relative.port = null, relative.host) + if (relPath[0] === "") + relPath[0] = relative.host; + else + relPath.unshift(relative.host); + relative.host = null; } - return t.slashes = t.slashes || s.slashes, t.href = t.format(), t; + mustEndAbs = mustEndAbs && (relPath[0] === "" || srcPath[0] === ""); } - var b = t.pathname && t.pathname.charAt(0) === "/", P = s.host || s.pathname && s.pathname.charAt(0) === "/", p = P || b || t.host && s.pathname, C = p, e = t.pathname && t.pathname.split("/") || [], i = s.pathname && s.pathname.split("/") || [], d = t.protocol && !R[t.protocol]; - if (d && (t.hostname = "", t.port = null, t.host && (e[0] === "" ? e[0] = t.host : e.unshift(t.host)), t.host = "", s.protocol && (s.hostname = null, s.port = null, s.host && (i[0] === "" ? i[0] = s.host : i.unshift(s.host)), s.host = null), p = p && (i[0] === "" || e[0] === "")), P) - t.host = s.host || s.host === "" ? s.host : t.host, t.hostname = s.hostname || s.hostname === "" ? s.hostname : t.hostname, t.search = s.search, t.query = s.query, e = i; - else if (i.length) - e || (e = []), e.pop(), e = e.concat(i), t.search = s.search, t.query = s.query; - else if (!E(s.search)) { - if (d) { - t.hostname = t.host = e.shift(); - var y = t.host && t.host.indexOf("@") > 0 ? t.host.split("@") : !1; - y && (t.auth = y.shift(), t.host = t.hostname = y.shift()); + if (isRelAbs) + result.host = relative.host || relative.host === "" ? relative.host : result.host, result.hostname = relative.hostname || relative.hostname === "" ? relative.hostname : result.hostname, result.search = relative.search, result.query = relative.query, srcPath = relPath; + else if (relPath.length) { + if (!srcPath) + srcPath = []; + srcPath.pop(), srcPath = srcPath.concat(relPath), result.search = relative.search, result.query = relative.query; + } else if (relative.search != null) { + if (psychotic) { + result.host = srcPath.shift(), result.hostname = result.host; + var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : !1; + if (authInHost) + result.auth = authInHost.shift(), result.hostname = authInHost.shift(), result.host = result.hostname; } - return t.search = s.search, t.query = s.query, (!I(t.pathname) || !I(t.search)) && (t.path = (t.pathname ? t.pathname : "") + (t.search ? t.search : "")), t.href = t.format(), t; + if (result.search = relative.search, result.query = relative.query, result.pathname !== null || result.search !== null) + result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : ""); + return result.href = result.format(), result; } - if (!e.length) - return t.pathname = null, t.search ? t.path = "/" + t.search : t.path = null, t.href = t.format(), t; - for (var x = e.slice(-1)[0], _ = (t.host || s.host || e.length > 1) && (x === "." || x === "..") || x === "", q = 0, O = e.length;O >= 0; O--) - x = e[O], x === "." ? e.splice(O, 1) : x === ".." ? (e.splice(O, 1), q++) : q && (e.splice(O, 1), q--); - if (!p && !C) - for (;q--; q) - e.unshift(".."); - p && e[0] !== "" && (!e[0] || e[0].charAt(0) !== "/") && e.unshift(""), _ && e.join("/").substr(-1) !== "/" && e.push(""); - var U = e[0] === "" || e[0] && e[0].charAt(0) === "/"; - if (d) { - t.hostname = t.host = U ? "" : e.length ? e.shift() : ""; - var y = t.host && t.host.indexOf("@") > 0 ? t.host.split("@") : !1; - y && (t.auth = y.shift(), t.host = t.hostname = y.shift()); + if (!srcPath.length) { + if (result.pathname = null, result.search) + result.path = "/" + result.search; + else + result.path = null; + return result.href = result.format(), result; + } + var last = srcPath.slice(-1)[0], hasTrailingSlash = (result.host || relative.host || srcPath.length > 1) && (last === "." || last === "..") || last === "", up = 0; + for (var i = srcPath.length;i >= 0; i--) + if (last = srcPath[i], last === ".") + srcPath.splice(i, 1); + else if (last === "..") + srcPath.splice(i, 1), up++; + else if (up) + srcPath.splice(i, 1), up--; + if (!mustEndAbs && !removeAllDots) + for (;up--; up) + srcPath.unshift(".."); + if (mustEndAbs && srcPath[0] !== "" && (!srcPath[0] || srcPath[0].charAt(0) !== "/")) + srcPath.unshift(""); + if (hasTrailingSlash && srcPath.join("/").substr(-1) !== "/") + srcPath.push(""); + var isAbsolute = srcPath[0] === "" || srcPath[0] && srcPath[0].charAt(0) === "/"; + if (psychotic) { + result.hostname = isAbsolute ? "" : srcPath.length ? srcPath.shift() : "", result.host = result.hostname; + var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : !1; + if (authInHost) + result.auth = authInHost.shift(), result.hostname = authInHost.shift(), result.host = result.hostname; + } + if (mustEndAbs = mustEndAbs || result.host && srcPath.length, mustEndAbs && !isAbsolute) + srcPath.unshift(""); + if (srcPath.length > 0) + result.pathname = srcPath.join("/"); + else + result.pathname = null, result.path = null; + if (result.pathname !== null || result.search !== null) + result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : ""); + return result.auth = relative.auth || result.auth, result.slashes = result.slashes || relative.slashes, result.href = result.format(), result; +}; +Url.prototype.parseHost = function() { + var host = this.host, port = portPattern.exec(host); + if (port) { + if (port = port[0], port !== ":") + this.port = port.substr(1); + host = host.substr(0, host.length - port.length); } - return p = p || t.host && e.length, p && !U && e.unshift(""), e.length ? t.pathname = e.join("/") : (t.pathname = null, t.path = null), (!I(t.pathname) || !I(t.search)) && (t.path = (t.pathname ? t.pathname : "") + (t.search ? t.search : "")), t.auth = s.auth || t.auth, t.slashes = t.slashes || s.slashes, t.href = t.format(), t; -}, m.prototype.parseHost = function() { - var s = this.host, r = st.exec(s); - r && (r = r[0], r !== ":" && (this.port = r.substr(1)), s = s.substr(0, s.length - r.length)), s && (this.hostname = s); + if (host) + this.hostname = host; }; -var Y, k; -S && (Y = S("pathToFileURL"), k = S("fileURLToPath")); -var ut = { - parse: A, - resolve: W, - resolveObject: X, - format: V, - Url: m, - pathToFileURL: Y, - fileURLToPath: k, - URL: F, - URLSearchParams: M +var lazy = globalThis[Symbol.for("Bun.lazy")], pathToFileURL = lazy("pathToFileURL"), fileURLToPath = lazy("fileURLToPath"), defaultObject = { + parse: urlParse, + resolve: urlResolve, + resolveObject: urlResolveObject, + format: urlFormat, + Url, + URLSearchParams, + URL, + pathToFileURL, + fileURLToPath, + urlToHttpOptions }; export { - X as resolveObject, - W as resolve, - Y as pathToFileURL, - A as parse, - V as format, - k as fileURLToPath, - ut as default, - m as Url, - M as URLSearchParams, - F as URL + urlToHttpOptions, + urlResolveObject as resolveObject, + urlResolve as resolve, + pathToFileURL, + urlParse as parse, + urlFormat as format, + fileURLToPath, + defaultObject as default, + Url, + URLSearchParams, + URL }; diff --git a/src/js/out/modules/node/util.js b/src/js/out/modules/node/util.js index bb439a3fa..b0881147c 100644 --- a/src/js/out/modules/node/util.js +++ b/src/js/out/modules/node/util.js @@ -1,10 +1,14 @@ +import * as types from "node:util/types"; +import {default as default2} from "node:util/types"; var isBufferInterface = function({ copy, fill, readUint8 }) { return typeof copy === "function" && typeof fill === "function" && typeof readUint8 === "function"; }; function isBuffer(value) { return Buffer.isBuffer(value) || typeof value === "object" && isBufferInterface(value || {}); } -var format = function(f) { +var isFunction = function(value) { + return typeof value === "function"; +}, format = function(f) { if (!isString(f)) { var objects = []; for (var i = 0;i < arguments.length; i++) @@ -37,33 +41,30 @@ var format = function(f) { else str += " " + inspect(x); return str; -}, deprecate = function(fn, msg) { - if (typeof process !== "undefined" && process.noDeprecation === !0) +}, deprecate = function(fn, msg, code) { + if (process.noDeprecation === !0) return fn; - if (typeof process === "undefined") - return function() { - return exports.deprecate(fn, msg).apply(this, arguments); - }; - var warned = !1; - function deprecated() { - if (!warned) { - if (process.throwDeprecation) - throw new Error(msg); - else if (process.traceDeprecation) - console.trace(msg); - else - console.error(msg); - warned = !0; - } - return fn.apply(this, arguments); - } - return deprecated; + var realFn = fn, wrapper = () => { + return fnToWrap.apply(this, arguments); + }, deprecater = () => { + if (process.throwDeprecation) { + var err = new Error(msg); + if (code) + err.code = code; + throw err; + } else if (process.traceDeprecation) + console.trace(msg); + else + console.error(msg); + return fnToWrap = realFn, realFn.apply(this, arguments); + }, fnToWrap = deprecater; + return wrapper; }, debuglog = function(set) { if (set = set.toUpperCase(), !debugs[set]) if (debugEnvRegex.test(set)) { var pid = process.pid; debugs[set] = function() { - var msg = exports.format.apply(exports, arguments); + var msg = format.apply(cjs_exports, arguments); console.error("%s %d: %s", set, pid, msg); }; } else @@ -82,7 +83,7 @@ var format = function(f) { if (isBoolean(opts)) ctx.showHidden = opts; else if (opts) - exports._extend(ctx, opts); + _extend(ctx, opts); if (isUndefined(ctx.showHidden)) ctx.showHidden = !1; if (isUndefined(ctx.depth)) @@ -108,7 +109,7 @@ var format = function(f) { hash[val] = !0; }), hash; }, formatValue = function(ctx, value, recurseTimes) { - if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== exports.inspect && !(value.constructor && value.constructor.prototype === value)) { + if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== inspect && !(value.constructor && value.constructor.prototype === value)) { var ret = value.inspect(recurseTimes, ctx); if (!isString(ret)) ret = formatValue(ctx, ret, recurseTimes); @@ -127,9 +128,9 @@ var format = function(f) { var name = value.name ? ": " + value.name : ""; return ctx.stylize("[Function" + name + "]", "special"); } - if (isRegExp(value)) + if (isRegExp2(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp"); - if (isDate(value)) + if (isDate2(value)) return ctx.stylize(Date.prototype.toString.call(value), "date"); if (isError(value)) return formatError(value); @@ -141,16 +142,16 @@ var format = function(f) { var n = value.name ? ": " + value.name : ""; base = " [Function" + n + "]"; } - if (isRegExp(value)) + if (isRegExp2(value)) base = " " + RegExp.prototype.toString.call(value); - if (isDate(value)) + if (isDate2(value)) base = " " + Date.prototype.toUTCString.call(value); if (isError(value)) base = " " + formatError(value); if (keys.length === 0 && (!array || value.length == 0)) return braces[0] + base + braces[1]; if (recurseTimes < 0) - if (isRegExp(value)) + if (isRegExp2(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp"); else return ctx.stylize("[Object]", "special"); @@ -255,8 +256,6 @@ var format = function(f) { return arg === void 0; }, isObject = function(arg) { return typeof arg === "object" && arg !== null; -}, isFunction = function(arg) { - return typeof arg === "function"; }, isPrimitive = function(arg) { return arg === null || typeof arg === "boolean" || typeof arg === "number" || typeof arg === "string" || typeof arg === "symbol" || typeof arg === "undefined"; }, pad = function(n) { @@ -289,7 +288,7 @@ var format = function(f) { }); } return Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)), Object.defineProperties(callbackified, getOwnPropertyDescriptors(original)), callbackified; -}, __getOwnPropNames = Object.getOwnPropertyNames, __commonJS = (cb, mod) => function __require() { +}, cjs_exports = {}, util_default = cjs_exports, __getOwnPropNames = Object.getOwnPropertyNames, __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }, require_inherits_browser = __commonJS({ "node_modules/inherits/inherits_browser.js"(exports, module2) { @@ -304,17 +303,10 @@ var format = function(f) { }); }; } -}), deepEquals = Bun.deepEquals, isDeepStrictEqual = (a, b) => deepEquals(a, b, !0), exports = { - isDeepStrictEqual -}, getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors, formatRegExp = /%[sdj%]/g; -exports.format = format; -exports.deprecate = deprecate; -var debugs = {}, debugEnvRegex = /^$/; +}), deepEquals = Bun.deepEquals, isDeepStrictEqual = (a, b) => deepEquals(a, b, !0), getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors, formatRegExp = /%[sdj%]/g, debugs = {}, debugEnvRegex = /^$/; if (process.env.NODE_DEBUG) debugEnv = process.env.NODE_DEBUG, debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase(), debugEnvRegex = new RegExp("^" + debugEnv + "$", "i"); var debugEnv; -exports.debuglog = debuglog; -exports.inspect = inspect; inspect.colors = { bold: [1, 22], italic: [3, 23], @@ -340,31 +332,16 @@ inspect.styles = { date: "magenta", regexp: "red" }; -var types = import.meta.require("node:util/types"); -exports.types = types; -exports.isArray = isArray; -exports.isBoolean = isBoolean; -exports.isNull = isNull; -exports.isNullOrUndefined = isNullOrUndefined; -exports.isNumber = isNumber; -exports.isString = isString; -exports.isSymbol = isSymbol; -exports.isUndefined = isUndefined; -var isRegExp = exports.isRegExp = exports.types.isRegExp; -exports.isObject = isObject; -var isDate = exports.isDate = exports.types.isDate, isError = exports.isError = exports.types.isNativeError, isFunction = exports.isFunction = isFunction; -exports.isPrimitive = isPrimitive; -exports.isBuffer = isBuffer; -var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], log = exports.log = function() { - console.log("%s - %s", timestamp(), exports.format.apply(exports, arguments)); -}, inherits = exports.inherits = require_inherits_browser(), _extend = exports._extend = function(origin, add) { +var isRegExp2 = types.isRegExp, isDate2 = types.isDate, isError = types.isNativeError, months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], log = function log2() { + console.log("%s - %s", timestamp(), format.apply(cjs_exports, arguments)); +}, inherits = inherits = require_inherits_browser(), _extend = function(origin, add) { if (!add || !isObject(add)) return origin; var keys = Object.keys(add), i = keys.length; while (i--) origin[keys[i]] = add[keys[i]]; return origin; -}, kCustomPromisifiedSymbol = Symbol.for("util.promisify.custom"), promisify = exports.promisify = function promisify2(original) { +}, kCustomPromisifiedSymbol = Symbol.for("util.promisify.custom"), promisify = function promisify2(original) { if (typeof original !== "function") throw new TypeError('The "original" argument must be of type Function'); if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) { @@ -406,18 +383,47 @@ var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oc }); return Object.defineProperties(fn, getOwnPropertyDescriptors(original)); }; -exports.promisify.custom = kCustomPromisifiedSymbol; -exports.callbackify = callbackify; -var TextDecoder = exports.TextDecoder = globalThis.TextDecoder, TextEncoder = exports.TextEncoder = globalThis.TextEncoder; -exports[Symbol.for("CommonJS")] = 0; -var util_default = exports; +promisify.custom = kCustomPromisifiedSymbol; +var { TextDecoder, TextEncoder } = globalThis; +Object.assign(cjs_exports, { + format, + deprecate, + debuglog, + _extend, + inspect, + types, + isArray, + isBoolean, + isNull, + isNullOrUndefined, + isNumber, + isString, + isSymbol, + isUndefined, + isRegExp: isRegExp2, + isObject, + isDate: isDate2, + isFunction, + isError, + isPrimitive, + isBuffer, + log, + inherits, + promisify, + callbackify, + isDeepStrictEqual, + TextDecoder, + TextEncoder, + [Symbol.for("CommonJS")]: 0 +}); export { + default2 as types, promisify, log, isUndefined, isSymbol, isString, - isRegExp, + isRegExp2 as isRegExp, isPrimitive, isObject, isNumber, @@ -426,7 +432,7 @@ export { isFunction, isError, isDeepStrictEqual, - isDate, + isDate2 as isDate, isBuffer, isBoolean, isArray, diff --git a/src/js/out/modules/node/zlib.js b/src/js/out/modules/node/zlib.js index afc7652e5..ff9ab3f3b 100644 --- a/src/js/out/modules/node/zlib.js +++ b/src/js/out/modules/node/zlib.js @@ -1,8 +1,14 @@ +import {default as assert} from "node:assert"; +import * as AssertModule from "node:assert"; +import * as BufferModule from "node:buffer"; +import * as StreamModule from "node:stream"; +import * as Util from "node:util"; +var Deflate, Inflate, Gzip, Gunzip, DeflateRaw, InflateRaw, Unzip, createDeflate, createInflate, createDeflateRaw, createInflateRaw, createGzip, createGunzip, createUnzip, deflate, deflateSync, gzip, gzipSync, deflateRaw, deflateRawSync, unzip, unzipSync, inflate, inflateSync, gunzip, gunzipSync, inflateRaw, inflateRawSync, constants; var __getOwnPropNames = Object.getOwnPropertyNames; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; -var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ +var require_zstream = __commonJS({ "node_modules/pako/lib/zlib/zstream.js"(exports, module2) { function ZStream() { this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; @@ -816,7 +822,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ function deflateInit(strm, level) { return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); } - function deflate(strm, flush) { + function deflate2(strm, flush) { var old_flush, s, beg, val; if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR; @@ -995,7 +1001,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ } return s.strstart += s.lookahead, s.block_start = s.strstart, s.insert = s.lookahead, s.lookahead = 0, s.match_length = s.prev_length = MIN_MATCH - 1, s.match_available = 0, strm.next_in = next, strm.input = input, strm.avail_in = avail, s.wrap = wrap, Z_OK; } - exports.deflateInit = deflateInit, exports.deflateInit2 = deflateInit2, exports.deflateReset = deflateReset, exports.deflateResetKeep = deflateResetKeep, exports.deflateSetHeader = deflateSetHeader, exports.deflate = deflate, exports.deflateEnd = deflateEnd, exports.deflateSetDictionary = deflateSetDictionary, exports.deflateInfo = "pako deflate (from Nodeca project)"; + exports.deflateInit = deflateInit, exports.deflateInit2 = deflateInit2, exports.deflateReset = deflateReset, exports.deflateResetKeep = deflateResetKeep, exports.deflateSetHeader = deflateSetHeader, exports.deflate = deflate2, exports.deflateEnd = deflateEnd, exports.deflateSetDictionary = deflateSetDictionary, exports.deflateInfo = "pako deflate (from Nodeca project)"; } }), require_inffast = __commonJS({ "node_modules/pako/lib/zlib/inffast.js"(exports, module2) { @@ -1416,7 +1422,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ } return 0; } - function inflate(strm, flush) { + function inflate2(strm, flush) { var state, input, output, next, put, have, left, hold, bits, _in, _out, copy, from, from_source, here = 0, here_bits, here_op, here_val, last_bits, last_op, last_val, len, ret, hbuf = new utils.Buf8(4), opts, n, order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) return Z_STREAM_ERROR; @@ -1948,7 +1954,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ return state.mode = MEM, Z_MEM_ERROR; return state.havedict = 1, Z_OK; } - exports.inflateReset = inflateReset, exports.inflateReset2 = inflateReset2, exports.inflateResetKeep = inflateResetKeep, exports.inflateInit = inflateInit, exports.inflateInit2 = inflateInit2, exports.inflate = inflate, exports.inflateEnd = inflateEnd, exports.inflateGetHeader = inflateGetHeader, exports.inflateSetDictionary = inflateSetDictionary, exports.inflateInfo = "pako inflate (from Nodeca project)"; + exports.inflateReset = inflateReset, exports.inflateReset2 = inflateReset2, exports.inflateResetKeep = inflateResetKeep, exports.inflateInit = inflateInit, exports.inflateInit2 = inflateInit2, exports.inflate = inflate2, exports.inflateEnd = inflateEnd, exports.inflateGetHeader = inflateGetHeader, exports.inflateSetDictionary = inflateSetDictionary, exports.inflateInfo = "pako inflate (from Nodeca project)"; } }), require_constants = __commonJS({ "node_modules/pako/lib/zlib/constants.js"(exports, module2) { @@ -1984,9 +1990,9 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ } }), require_binding = __commonJS({ "node_modules/browserify-zlib/lib/binding.js"(exports) { - var assert = require2("assert"), Zstream = require_zstream(), zlib_deflate = require_deflate(), zlib_inflate = require_inflate(), constants = require_constants(); - for (key in constants) - exports[key] = constants[key]; + var Zstream = require_zstream(), zlib_deflate = require_deflate(), zlib_inflate = require_inflate(), constants2 = require_constants(); + for (key in constants2) + exports[key] = constants2[key]; var key; exports.NONE = 0, exports.DEFLATE = 1, exports.INFLATE = 2, exports.GZIP = 3, exports.GUNZIP = 4, exports.DEFLATERAW = 5, exports.INFLATERAW = 6, exports.UNZIP = 7; var GZIP_HEADER_ID1 = 31, GZIP_HEADER_ID2 = 139; @@ -2169,7 +2175,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ } }), require_lib = __commonJS({ "node_modules/browserify-zlib/lib/index.js"(exports) { - var Buffer2 = require2("buffer").Buffer, Transform = require2("stream").Transform, binding = require_binding(), util = require2("util"), assert = require2("assert").ok, kMaxLength = require2("buffer").kMaxLength, kRangeErrorMessage = "Cannot create final Buffer. It would be larger than 0x" + kMaxLength.toString(16) + " bytes"; + var Buffer22 = BufferModule.Buffer, Transform2 = StreamModule.Transform, binding = require_binding(), util = Util, assert2 = AssertModule.ok, kMaxLength2 = BufferModule.kMaxLength, kRangeErrorMessage = "Cannot create final Buffer. It would be larger than 0x" + kMaxLength2.toString(16) + " bytes"; binding.Z_MIN_WINDOWBITS = 8, binding.Z_MAX_WINDOWBITS = 15, binding.Z_DEFAULT_WINDOWBITS = 15, binding.Z_MIN_CHUNK = 64, binding.Z_MAX_CHUNK = Infinity, binding.Z_DEFAULT_CHUNK = 16384, binding.Z_MIN_MEMLEVEL = 1, binding.Z_MAX_MEMLEVEL = 9, binding.Z_DEFAULT_MEMLEVEL = 8, binding.Z_MIN_LEVEL = -1, binding.Z_MAX_LEVEL = 9, binding.Z_DEFAULT_LEVEL = binding.Z_DEFAULT_COMPRESSION; var bkeys = Object.keys(binding); for (bk = 0;bk < bkeys.length; bk++) @@ -2197,62 +2203,62 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ enumerable: !0, value: Object.freeze(codes), writable: !1 - }), exports.constants = require_constants(), exports.Deflate = Deflate, exports.Inflate = Inflate, exports.Gzip = Gzip, exports.Gunzip = Gunzip, exports.DeflateRaw = DeflateRaw, exports.InflateRaw = InflateRaw, exports.Unzip = Unzip, exports.createDeflate = function(o) { - return new Deflate(o); + }), exports.constants = require_constants(), exports.Deflate = Deflate2, exports.Inflate = Inflate2, exports.Gzip = Gzip2, exports.Gunzip = Gunzip2, exports.DeflateRaw = DeflateRaw2, exports.InflateRaw = InflateRaw2, exports.Unzip = Unzip2, exports.createDeflate = function(o) { + return new Deflate2(o); }, exports.createInflate = function(o) { - return new Inflate(o); + return new Inflate2(o); }, exports.createDeflateRaw = function(o) { - return new DeflateRaw(o); + return new DeflateRaw2(o); }, exports.createInflateRaw = function(o) { - return new InflateRaw(o); + return new InflateRaw2(o); }, exports.createGzip = function(o) { - return new Gzip(o); + return new Gzip2(o); }, exports.createGunzip = function(o) { - return new Gunzip(o); + return new Gunzip2(o); }, exports.createUnzip = function(o) { - return new Unzip(o); + return new Unzip2(o); }, exports.deflate = function(buffer, opts, callback) { if (typeof opts === "function") callback = opts, opts = {}; - return zlibBuffer(new Deflate(opts), buffer, callback); + return zlibBuffer(new Deflate2(opts), buffer, callback); }, exports.deflateSync = function(buffer, opts) { - return zlibBufferSync(new Deflate(opts), buffer); + return zlibBufferSync(new Deflate2(opts), buffer); }, exports.gzip = function(buffer, opts, callback) { if (typeof opts === "function") callback = opts, opts = {}; - return zlibBuffer(new Gzip(opts), buffer, callback); + return zlibBuffer(new Gzip2(opts), buffer, callback); }, exports.gzipSync = function(buffer, opts) { - return zlibBufferSync(new Gzip(opts), buffer); + return zlibBufferSync(new Gzip2(opts), buffer); }, exports.deflateRaw = function(buffer, opts, callback) { if (typeof opts === "function") callback = opts, opts = {}; - return zlibBuffer(new DeflateRaw(opts), buffer, callback); + return zlibBuffer(new DeflateRaw2(opts), buffer, callback); }, exports.deflateRawSync = function(buffer, opts) { - return zlibBufferSync(new DeflateRaw(opts), buffer); + return zlibBufferSync(new DeflateRaw2(opts), buffer); }, exports.unzip = function(buffer, opts, callback) { if (typeof opts === "function") callback = opts, opts = {}; - return zlibBuffer(new Unzip(opts), buffer, callback); + return zlibBuffer(new Unzip2(opts), buffer, callback); }, exports.unzipSync = function(buffer, opts) { - return zlibBufferSync(new Unzip(opts), buffer); + return zlibBufferSync(new Unzip2(opts), buffer); }, exports.inflate = function(buffer, opts, callback) { if (typeof opts === "function") callback = opts, opts = {}; - return zlibBuffer(new Inflate(opts), buffer, callback); + return zlibBuffer(new Inflate2(opts), buffer, callback); }, exports.inflateSync = function(buffer, opts) { - return zlibBufferSync(new Inflate(opts), buffer); + return zlibBufferSync(new Inflate2(opts), buffer); }, exports.gunzip = function(buffer, opts, callback) { if (typeof opts === "function") callback = opts, opts = {}; - return zlibBuffer(new Gunzip(opts), buffer, callback); + return zlibBuffer(new Gunzip2(opts), buffer, callback); }, exports.gunzipSync = function(buffer, opts) { - return zlibBufferSync(new Gunzip(opts), buffer); + return zlibBufferSync(new Gunzip2(opts), buffer); }, exports.inflateRaw = function(buffer, opts, callback) { if (typeof opts === "function") callback = opts, opts = {}; - return zlibBuffer(new InflateRaw(opts), buffer, callback); + return zlibBuffer(new InflateRaw2(opts), buffer, callback); }, exports.inflateRawSync = function(buffer, opts) { - return zlibBufferSync(new InflateRaw(opts), buffer); + return zlibBufferSync(new InflateRaw2(opts), buffer); }; function zlibBuffer(engine, buffer, callback) { var buffers = [], nread = 0; @@ -2268,54 +2274,54 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ } function onEnd() { var buf, err = null; - if (nread >= kMaxLength) + if (nread >= kMaxLength2) err = new RangeError(kRangeErrorMessage); else - buf = Buffer2.concat(buffers, nread); + buf = Buffer22.concat(buffers, nread); buffers = [], engine.close(), callback(err, buf); } } function zlibBufferSync(engine, buffer) { if (typeof buffer === "string") - buffer = Buffer2.from(buffer); - if (!Buffer2.isBuffer(buffer)) + buffer = Buffer22.from(buffer); + if (!Buffer22.isBuffer(buffer)) throw new TypeError("Not a string or buffer"); var flushFlag = engine._finishFlushFlag; return engine._processChunk(buffer, flushFlag); } - function Deflate(opts) { - if (!(this instanceof Deflate)) - return new Deflate(opts); + function Deflate2(opts) { + if (!(this instanceof Deflate2)) + return new Deflate2(opts); Zlib.call(this, opts, binding.DEFLATE); } - function Inflate(opts) { - if (!(this instanceof Inflate)) - return new Inflate(opts); + function Inflate2(opts) { + if (!(this instanceof Inflate2)) + return new Inflate2(opts); Zlib.call(this, opts, binding.INFLATE); } - function Gzip(opts) { - if (!(this instanceof Gzip)) - return new Gzip(opts); + function Gzip2(opts) { + if (!(this instanceof Gzip2)) + return new Gzip2(opts); Zlib.call(this, opts, binding.GZIP); } - function Gunzip(opts) { - if (!(this instanceof Gunzip)) - return new Gunzip(opts); + function Gunzip2(opts) { + if (!(this instanceof Gunzip2)) + return new Gunzip2(opts); Zlib.call(this, opts, binding.GUNZIP); } - function DeflateRaw(opts) { - if (!(this instanceof DeflateRaw)) - return new DeflateRaw(opts); + function DeflateRaw2(opts) { + if (!(this instanceof DeflateRaw2)) + return new DeflateRaw2(opts); Zlib.call(this, opts, binding.DEFLATERAW); } - function InflateRaw(opts) { - if (!(this instanceof InflateRaw)) - return new InflateRaw(opts); + function InflateRaw2(opts) { + if (!(this instanceof InflateRaw2)) + return new InflateRaw2(opts); Zlib.call(this, opts, binding.INFLATERAW); } - function Unzip(opts) { - if (!(this instanceof Unzip)) - return new Unzip(opts); + function Unzip2(opts) { + if (!(this instanceof Unzip2)) + return new Unzip2(opts); Zlib.call(this, opts, binding.UNZIP); } function isValidFlushFlag(flag) { @@ -2323,7 +2329,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ } function Zlib(opts, mode) { var _this = this; - if (this._opts = opts = opts || {}, this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK, Transform.call(this, opts), opts.flush && !isValidFlushFlag(opts.flush)) + if (this._opts = opts = opts || {}, this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK, Transform2.call(this, opts), opts.flush && !isValidFlushFlag(opts.flush)) throw new Error("Invalid flush flag: " + opts.flush); if (opts.finishFlush && !isValidFlushFlag(opts.finishFlush)) throw new Error("Invalid flush flag: " + opts.finishFlush); @@ -2348,7 +2354,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ throw new Error("Invalid strategy: " + opts.strategy); } if (opts.dictionary) { - if (!Buffer2.isBuffer(opts.dictionary)) + if (!Buffer22.isBuffer(opts.dictionary)) throw new Error("Invalid dictionary: it should be a Buffer instance"); } this._handle = new binding.Zlib(mode); @@ -2364,7 +2370,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ var strategy = exports.Z_DEFAULT_STRATEGY; if (typeof opts.strategy === "number") strategy = opts.strategy; - this._handle.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS, level, opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, strategy, opts.dictionary), this._buffer = Buffer2.allocUnsafe(this._chunkSize), this._offset = 0, this._level = level, this._strategy = strategy, this.once("end", this.close), Object.defineProperty(this, "_closed", { + this._handle.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS, level, opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, strategy, opts.dictionary), this._buffer = Buffer22.allocUnsafe(this._chunkSize), this._offset = 0, this._level = level, this._strategy = strategy, this.once("end", this.close), Object.defineProperty(this, "_closed", { get: function() { return !_this._handle; }, @@ -2372,7 +2378,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ enumerable: !0 }); } - util.inherits(Zlib, Transform), Zlib.prototype.params = function(level, strategy, callback) { + util.inherits(Zlib, Transform2), Zlib.prototype.params = function(level, strategy, callback) { if (level < exports.Z_MIN_LEVEL || level > exports.Z_MAX_LEVEL) throw new RangeError("Invalid compression level: " + level); if (strategy != exports.Z_FILTERED && strategy != exports.Z_HUFFMAN_ONLY && strategy != exports.Z_RLE && strategy != exports.Z_FIXED && strategy != exports.Z_DEFAULT_STRATEGY) @@ -2380,7 +2386,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ if (this._level !== level || this._strategy !== strategy) { var self = this; this.flush(binding.Z_SYNC_FLUSH, function() { - if (assert(self._handle, "zlib binding closed"), self._handle.params(level, strategy), !self._hadError) { + if (assert2(self._handle, "zlib binding closed"), self._handle.params(level, strategy), !self._hadError) { if (self._level = level, self._strategy = strategy, callback) callback(); } @@ -2388,9 +2394,9 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ } else process.nextTick(callback); }, Zlib.prototype.reset = function() { - return assert(this._handle, "zlib binding closed"), this._handle.reset(); + return assert2(this._handle, "zlib binding closed"), this._handle.reset(); }, Zlib.prototype._flush = function(callback) { - this._transform(Buffer2.alloc(0), "", callback); + this._transform(Buffer22.alloc(0), "", callback); }, Zlib.prototype.flush = function(kind, callback) { var _this2 = this, ws = this._writableState; if (typeof kind === "function" || kind === void 0 && !callback) @@ -2407,7 +2413,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ return _this2.flush(kind, callback); }); } else - this._flushFlag = kind, this.write(Buffer2.alloc(0), "", callback); + this._flushFlag = kind, this.write(Buffer22.alloc(0), "", callback); }, Zlib.prototype.close = function(callback) { _close(this, callback), process.nextTick(emitCloseNT, this); }; @@ -2423,7 +2429,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ } Zlib.prototype._transform = function(chunk, encoding, cb) { var flushFlag, ws = this._writableState, ending = ws.ending || ws.ended, last = ending && (!chunk || ws.length === chunk.length); - if (chunk !== null && !Buffer2.isBuffer(chunk)) + if (chunk !== null && !Buffer22.isBuffer(chunk)) return cb(new Error("invalid input")); if (!this._handle) return cb(new Error("zlib binding closed")); @@ -2438,18 +2444,18 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ var buffers = [], nread = 0, error; this.on("error", function(er) { error = er; - }), assert(this._handle, "zlib binding closed"); + }), assert2(this._handle, "zlib binding closed"); do var res = this._handle.writeSync(flushFlag, chunk, inOff, availInBefore, this._buffer, this._offset, availOutBefore); while (!this._hadError && callback(res[0], res[1])); if (this._hadError) throw error; - if (nread >= kMaxLength) + if (nread >= kMaxLength2) throw _close(this), new RangeError(kRangeErrorMessage); - var buf = Buffer2.concat(buffers, nread); + var buf = Buffer22.concat(buffers, nread); return _close(this), buf; } - assert(this._handle, "zlib binding closed"); + assert2(this._handle, "zlib binding closed"); var req = this._handle.write(flushFlag, chunk, inOff, availInBefore, this._buffer, this._offset, availOutBefore); req.buffer = chunk, req.callback = callback; function callback(availInAfter, availOutAfter) { @@ -2458,7 +2464,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ if (self._hadError) return; var have = availOutBefore - availOutAfter; - if (assert(have >= 0, "have should not go down"), have > 0) { + if (assert2(have >= 0, "have should not go down"), have > 0) { var out = self._buffer.slice(self._offset, self._offset + have); if (self._offset += have, async) self.push(out); @@ -2466,7 +2472,7 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ buffers.push(out), nread += out.length; } if (availOutAfter === 0 || self._offset >= self._chunkSize) - availOutBefore = self._chunkSize, self._offset = 0, self._buffer = Buffer2.allocUnsafe(self._chunkSize); + availOutBefore = self._chunkSize, self._offset = 0, self._buffer = Buffer22.allocUnsafe(self._chunkSize); if (availOutAfter === 0) { if (inOff += availInBefore - availInAfter, availInBefore = availInAfter, !async) return !0; @@ -2478,41 +2484,40 @@ var require2 = (id) => import.meta.require(id), require_zstream = __commonJS({ return !1; cb(); } - }, util.inherits(Deflate, Zlib), util.inherits(Inflate, Zlib), util.inherits(Gzip, Zlib), util.inherits(Gunzip, Zlib), util.inherits(DeflateRaw, Zlib), util.inherits(InflateRaw, Zlib), util.inherits(Unzip, Zlib); + }, util.inherits(Deflate2, Zlib), util.inherits(Inflate2, Zlib), util.inherits(Gzip2, Zlib), util.inherits(Gunzip2, Zlib), util.inherits(DeflateRaw2, Zlib), util.inherits(InflateRaw2, Zlib), util.inherits(Unzip2, Zlib); } }), zlib_exports = require_lib(); zlib_exports[Symbol.for("CommonJS")] = 0; -var zlib_default = zlib_exports, { - Deflate, - Inflate, - Gzip, - Gunzip, - DeflateRaw, - InflateRaw, - Unzip, - createDeflate, - createInflate, - createDeflateRaw, - createInflateRaw, - createGzip, - createGunzip, - createUnzip, - deflate, - deflateSync, - gzip, - gzipSync, - deflateRaw, - deflateRawSync, - unzip, - unzipSync, - inflate, - inflateSync, - gunzip, - gunzipSync, - inflateRaw, - inflateRawSync, - constants -} = zlib_exports; +var zlib_default = zlib_exports; +Deflate = zlib_exports.Deflate; +Inflate = zlib_exports.Inflate; +Gzip = zlib_exports.Gzip; +Gunzip = zlib_exports.Gunzip; +DeflateRaw = zlib_exports.DeflateRaw; +InflateRaw = zlib_exports.InflateRaw; +Unzip = zlib_exports.Unzip; +createDeflate = zlib_exports.createDeflate; +createInflate = zlib_exports.createInflate; +createDeflateRaw = zlib_exports.createDeflateRaw; +createInflateRaw = zlib_exports.createInflateRaw; +createGzip = zlib_exports.createGzip; +createGunzip = zlib_exports.createGunzip; +createUnzip = zlib_exports.createUnzip; +deflate = zlib_exports.deflate; +deflateSync = zlib_exports.deflateSync; +gzip = zlib_exports.gzip; +gzipSync = zlib_exports.gzipSync; +deflateRaw = zlib_exports.deflateRaw; +deflateRawSync = zlib_exports.deflateRawSync; +unzip = zlib_exports.unzip; +unzipSync = zlib_exports.unzipSync; +inflate = zlib_exports.inflate; +inflateSync = zlib_exports.inflateSync; +gunzip = zlib_exports.gunzip; +gunzipSync = zlib_exports.gunzipSync; +inflateRaw = zlib_exports.inflateRaw; +inflateRawSync = zlib_exports.inflateRawSync; +constants = zlib_exports.constants; export { unzipSync, unzip, diff --git a/src/js/out/modules/thirdparty/depd.js b/src/js/out/modules/thirdparty/depd.js index 09f125e7c..6118e8cf1 100644 --- a/src/js/out/modules/thirdparty/depd.js +++ b/src/js/out/modules/thirdparty/depd.js @@ -1,51 +1,23 @@ -var depd = function(...args) { - return args.length ? bundle_default(...args) : bundle_default; -}; -/*! - * depd - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ -var { create: __create, defineProperty: __defProp, getOwnPropertyDescriptor: __getOwnPropDesc, getOwnPropertyNames: __getOwnPropNames, getPrototypeOf: __getProtoOf } = Object, __hasOwnProp = Object.prototype.hasOwnProperty, __commonJS = (cb, mod) => function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}, __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { - get: () => from[key], - enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable - }); - } - return to; -}, __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod)), require_browser = __commonJS({ - "node_modules/depd/lib/browser/index.js"(exports, module) { - module.exports = depd2; - function depd2(namespace) { - if (!namespace) - throw new TypeError("argument namespace is required"); - function deprecate(message) { - } - return deprecate._file = void 0, deprecate._ignored = !0, deprecate._namespace = namespace, deprecate._traced = !1, deprecate._warned = Object.create(null), deprecate.function = wrapfunction, deprecate.property = wrapproperty, deprecate; - } - function wrapfunction(fn, message) { - if (typeof fn !== "function") - throw new TypeError("argument fn must be a function"); - return fn; - } - function wrapproperty(obj, prop, message) { - if (!obj || typeof obj !== "object" && typeof obj !== "function") - throw new TypeError("argument obj must be object"); - var descriptor = Object.getOwnPropertyDescriptor(obj, prop); - if (!descriptor) - throw new TypeError("must call property on owner object"); - if (!descriptor.configurable) - throw new TypeError("property must be configurable"); - } +var depd2 = function(namespace) { + if (!namespace) + throw new TypeError("argument namespace is required"); + function deprecate(message) { } -}), import_depd = __toESM(require_browser()), bundle_default = import_depd.default; -depd[Symbol.for("CommonJS")] = !0; -var depd_default = depd; + return deprecate._file = void 0, deprecate._ignored = !0, deprecate._namespace = namespace, deprecate._traced = !1, deprecate._warned = Object.create(null), deprecate.function = wrapfunction, deprecate.property = wrapproperty, deprecate; +}, wrapfunction = function(fn, message) { + if (typeof fn !== "function") + throw new TypeError("argument fn must be a function"); + return fn; +}, wrapproperty = function(obj, prop, message) { + if (!obj || typeof obj !== "object" && typeof obj !== "function") + throw new TypeError("argument obj must be object"); + var descriptor = Object.getOwnPropertyDescriptor(obj, prop); + if (!descriptor) + throw new TypeError("must call property on owner object"); + if (!descriptor.configurable) + throw new TypeError("property must be configurable"); +}, depd_default = depd2; +depd2[Symbol.for("CommonJS")] = 0; export { depd_default as default }; diff --git a/src/js/out/modules/thirdparty/undici.js b/src/js/out/modules/thirdparty/undici.js index 01f19a64e..20dec6158 100644 --- a/src/js/out/modules/thirdparty/undici.js +++ b/src/js/out/modules/thirdparty/undici.js @@ -1,3 +1,6 @@ +import {EventEmitter} from "node:events"; +import NodeStreamModule from "node:stream"; +import {Readable} from "node:stream"; var notImplemented = function() { throw new Error("Not implemented in bun"); }; @@ -66,28 +69,21 @@ async function request(url, options = { const body = resp.body ? new BodyReadable(resp) : null; return { statusCode, headers: headers.toJSON(), body, trailers, opaque: kEmptyObject, context: kEmptyObject }; } -function stream() { +var stream = function() { throw new Error("Not implemented in bun"); -} -function pipeline() { +}, pipeline = function() { throw new Error("Not implemented in bun"); -} -function connect() { +}, connect = function() { throw new Error("Not implemented in bun"); -} -function upgrade() { +}, upgrade = function() { throw new Error("Not implemented in bun"); -} -function mockErrors() { +}, mockErrors = function() { throw new Error("Not implemented in bun"); -} +}; function Undici() { throw new Error("Not implemented in bun"); } -var { EventEmitter } = import.meta.require("events"), { - Readable, - [Symbol.for("::bunternal::")]: { _ReadableFromWeb } -} = import.meta.require("node:stream"), ObjectCreate = Object.create, kEmptyObject = ObjectCreate(null), fetch = Bun.fetch, Response = globalThis.Response, Headers = globalThis.Headers, Request = globalThis.Request, URLSearchParams = globalThis.URLSearchParams, URL = globalThis.URL; +var { Object } = globalThis[Symbol.for("Bun.lazy")]("primordials"), { _ReadableFromWebForUndici: ReadableFromWeb } = NodeStreamModule[Symbol.for("::bunternal::")], ObjectCreate = Object.create, kEmptyObject = ObjectCreate(null), fetch = Bun.fetch, Response = globalThis.Response, Headers = globalThis.Headers, Request = globalThis.Request, URLSearchParams = globalThis.URLSearchParams, URL = globalThis.URL; class File extends Blob { } @@ -99,7 +95,7 @@ class FileReader extends EventTarget { } var FormData = globalThis.FormData; -class BodyReadable extends _ReadableFromWeb { +class BodyReadable extends ReadableFromWeb { #response; #bodyUsed; constructor(response, options = {}) { @@ -220,11 +216,16 @@ export { URL, Response, Request, + Pool, MockPool, MockClient, MockAgent, Headers, FormData, FileReader, - File + File, + Dispatcher, + Client, + BalancedPool, + Agent }; diff --git a/src/js/out/modules/thirdparty/ws.js b/src/js/out/modules/thirdparty/ws.js index dd616d86a..7a48da4c1 100644 --- a/src/js/out/modules/thirdparty/ws.js +++ b/src/js/out/modules/thirdparty/ws.js @@ -1,5 +1,5 @@ -var EventEmitter = import.meta.require("node:events"); -var http = import.meta.require("node:http"); +import {EventEmitter} from "node:events"; +import http from "node:http"; var emitWarning = function(type, message) { if (emittedWarnings.has(type)) return; diff --git a/src/js/thirdparty/depd.js b/src/js/thirdparty/depd.js index f69f4312e..2da8901bc 100644 --- a/src/js/thirdparty/depd.js +++ b/src/js/thirdparty/depd.js @@ -1,89 +1,35 @@ -// Hardcoded module "depd" -// TODO: remove this module from being bundled into bun -// This is a temporary workaround for a CommonJS <> ESM interop issue. - -/*! - * depd - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __commonJS = (cb, mod) => - function __require() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; - }; -var __copyProps = (to, from, except, desc) => { - if ((from && typeof from === "object") || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { - get: () => from[key], - enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable, - }); +function depd2(namespace) { + if (!namespace) { + throw new TypeError("argument namespace is required"); + } + function deprecate(message) {} + deprecate._file = void 0; + deprecate._ignored = true; + deprecate._namespace = namespace; + deprecate._traced = false; + deprecate._warned = /* @__PURE__ */ Object.create(null); + deprecate.function = wrapfunction; + deprecate.property = wrapproperty; + return deprecate; +} +function wrapfunction(fn, message) { + if (typeof fn !== "function") { + throw new TypeError("argument fn must be a function"); + } + return fn; +} +function wrapproperty(obj, prop, message) { + if (!obj || (typeof obj !== "object" && typeof obj !== "function")) { + throw new TypeError("argument obj must be object"); + } + var descriptor = Object.getOwnPropertyDescriptor(obj, prop); + if (!descriptor) { + throw new TypeError("must call property on owner object"); + } + if (!descriptor.configurable) { + throw new TypeError("property must be configurable"); } - return to; -}; -var __toESM = (mod, isNodeMode, target) => ( - (target = mod != null ? __create(__getProtoOf(mod)) : {}), - __copyProps( - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, - mod, - ) -); - -// node_modules/depd/lib/browser/index.js -var require_browser = __commonJS({ - "node_modules/depd/lib/browser/index.js"(exports, module) { - "use strict"; - module.exports = depd2; - function depd2(namespace) { - if (!namespace) { - throw new TypeError("argument namespace is required"); - } - function deprecate(message) {} - deprecate._file = void 0; - deprecate._ignored = true; - deprecate._namespace = namespace; - deprecate._traced = false; - deprecate._warned = /* @__PURE__ */ Object.create(null); - deprecate.function = wrapfunction; - deprecate.property = wrapproperty; - return deprecate; - } - function wrapfunction(fn, message) { - if (typeof fn !== "function") { - throw new TypeError("argument fn must be a function"); - } - return fn; - } - function wrapproperty(obj, prop, message) { - if (!obj || (typeof obj !== "object" && typeof obj !== "function")) { - throw new TypeError("argument obj must be object"); - } - var descriptor = Object.getOwnPropertyDescriptor(obj, prop); - if (!descriptor) { - throw new TypeError("must call property on owner object"); - } - if (!descriptor.configurable) { - throw new TypeError("property must be configurable"); - } - } - }, -}); - -// bundle.js -var import_depd = __toESM(require_browser()); -var bundle_default = import_depd.default; - -function depd(...args) { - return args.length ? bundle_default(...args) : bundle_default; } -depd[Symbol.for("CommonJS")] = true; // TODO: this requires hacky default export -export default depd; +export default depd2; +depd2[Symbol.for("CommonJS")] = 0; diff --git a/src/js/thirdparty/undici.js b/src/js/thirdparty/undici.js index cf3968b58..579e33d1d 100644 --- a/src/js/thirdparty/undici.js +++ b/src/js/thirdparty/undici.js @@ -1,27 +1,27 @@ -// const { Object } = import.meta.primordials; -const { EventEmitter } = import.meta.require("events"); -const { - Readable, - [Symbol.for("::bunternal::")]: { _ReadableFromWeb }, -} = import.meta.require("node:stream"); +const { Object } = globalThis[Symbol.for("Bun.lazy")]("primordials"); +import { EventEmitter } from "events"; +import NodeStreamModule from "node:stream"; +import { Readable } from "node:stream"; + +const { _ReadableFromWebForUndici: ReadableFromWeb } = NodeStreamModule[Symbol.for("::bunternal::")]; const ObjectCreate = Object.create; const kEmptyObject = ObjectCreate(null); -export var fetch = Bun.fetch; -export var Response = globalThis.Response; -export var Headers = globalThis.Headers; -export var Request = globalThis.Request; -export var URLSearchParams = globalThis.URLSearchParams; -export var URL = globalThis.URL; -export class File extends Blob {} -export class FileReader extends EventTarget { +var fetch = Bun.fetch; +var Response = globalThis.Response; +var Headers = globalThis.Headers; +var Request = globalThis.Request; +var URLSearchParams = globalThis.URLSearchParams; +var URL = globalThis.URL; +class File extends Blob {} +class FileReader extends EventTarget { constructor() { throw new Error("Not implemented yet!"); } } -export var FormData = globalThis.FormData; +var FormData = globalThis.FormData; function notImplemented() { throw new Error("Not implemented in bun"); } @@ -45,7 +45,7 @@ function notImplemented() { * @typedef {import('events').EventEmitter} EventEmitter */ -class BodyReadable extends _ReadableFromWeb { +class BodyReadable extends ReadableFromWeb { #response; #bodyUsed; @@ -127,7 +127,7 @@ class BodyReadable extends _ReadableFromWeb { * context: Object; * }} */ -export async function request( +async function request( url, options = { method: "GET", @@ -228,36 +228,36 @@ export async function request( return { statusCode, headers: headers.toJSON(), body, trailers, opaque: kEmptyObject, context: kEmptyObject }; } -export function stream() { +function stream() { throw new Error("Not implemented in bun"); } -export function pipeline() { +function pipeline() { throw new Error("Not implemented in bun"); } -export function connect() { +function connect() { throw new Error("Not implemented in bun"); } -export function upgrade() { +function upgrade() { throw new Error("Not implemented in bun"); } -export class MockClient { +class MockClient { constructor() { throw new Error("Not implemented in bun"); } } -export class MockPool { +class MockPool { constructor() { throw new Error("Not implemented in bun"); } } -export class MockAgent { +class MockAgent { constructor() { throw new Error("Not implemented in bun"); } } -export function mockErrors() { +function mockErrors() { throw new Error("Not implemented in bun"); } @@ -329,3 +329,29 @@ export default { Undici, [Symbol.for("CommonJS")]: 0, }; + +export { + fetch, + Response, + Headers, + Request, + URLSearchParams, + URL, + File, + FileReader, + FormData, + request, + stream, + pipeline, + connect, + upgrade, + MockClient, + MockPool, + MockAgent, + mockErrors, + Dispatcher, + Pool, + BalancedPool, + Client, + Agent, +}; diff --git a/src/js/thirdparty/ws.js b/src/js/thirdparty/ws.js index 3af650764..5b27c5b50 100644 --- a/src/js/thirdparty/ws.js +++ b/src/js/thirdparty/ws.js @@ -3,7 +3,7 @@ // this just wraps WebSocket to look like an EventEmitter // without actually using an EventEmitter polyfill -import EventEmitter from "events"; +import { EventEmitter } from "events"; import http from "http"; const kBunInternals = Symbol.for("::bunternal::"); diff --git a/src/js_parser.zig b/src/js_parser.zig index 28bd4aa0b..16560d525 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -21217,7 +21217,7 @@ fn NewParser_( logger.Loc.Empty, ); const cjsGlobal = p.newSymbol(.unbound, "$_BunCommonJSModule_$") catch unreachable; - var call_args = allocator.alloc(Expr, 6) catch unreachable; + var all_call_args = allocator.alloc(Expr, 7) catch unreachable; const this_module = p.newExpr( E.Dot{ .name = "module", @@ -21226,14 +21226,72 @@ fn NewParser_( }, logger.Loc.Empty, ); + var call_args = all_call_args[1..]; + var bind_args = all_call_args[0..1]; + bind_args[0] = this_module; + const get_require = p.newExpr( + E.Dot{ + .name = "require", + .target = this_module, + .name_loc = logger.Loc.Empty, + }, + logger.Loc.Empty, + ); + + const create_binding = p.newExpr( + E.Call{ + .target = p.newExpr(E.Dot{ + .name = "bind", + .name_loc = logger.Loc.Empty, + .target = get_require, + }, logger.Loc.Empty), + .args = bun.BabyList(Expr).init(bind_args), + }, + logger.Loc.Empty, + ); + + const module_id = p.newExpr(E.Dot{ + .name = "id", + .target = this_module, + .name_loc = logger.Loc.Empty, + }, logger.Loc.Empty); + + const require_path = p.newExpr( + E.Dot{ + .name = "path", + .target = get_require, + .name_loc = logger.Loc.Empty, + }, + logger.Loc.Empty, + ); + const assign_binding = p.newExpr( + E.Binary{ + .left = get_require, + .right = create_binding, + .op = .bin_assign, + }, + logger.Loc.Empty, + ); + + const assign_id = p.newExpr(E.Binary{ + .left = require_path, + .right = module_id, + .op = .bin_assign, + }, logger.Loc.Empty); + + var create_require = [3]Expr{ + assign_binding, + assign_id, + get_require, + }; // - // (function(module, exports, require, __dirname, __filename) {}).call(this.exports, this.module, this.exports, this.require, __dirname, __filename) + // (function(module, exports, require, __dirname, __filename) {}).call(this.exports, this.module, this.exports, this.module.require = this.module.require.bind(module), (this.module.require.id = this.module.id, this.module.require), __dirname, __filename) call_args[0..6].* = .{ p.newExpr( E.Dot{ .name = "exports", - .target = p.newExpr(E.Identifier{ .ref = cjsGlobal }, logger.Loc.Empty), + .target = this_module, .name_loc = logger.Loc.Empty, }, logger.Loc.Empty, @@ -21242,33 +21300,12 @@ fn NewParser_( p.newExpr( E.Dot{ .name = "exports", - .target = p.newExpr(E.Identifier{ .ref = cjsGlobal }, logger.Loc.Empty), + .target = this_module, .name_loc = logger.Loc.Empty, }, logger.Loc.Empty, ), - p.newExpr( - E.Binary{ - .left = p.newExpr( - E.Dot{ - .name = "require", - .target = this_module, - .name_loc = logger.Loc.Empty, - }, - logger.Loc.Empty, - ), - .op = .bin_assign, - .right = p.newExpr( - E.Dot{ - .name = "require", - .target = p.newExpr(E.Identifier{ .ref = cjsGlobal }, logger.Loc.Empty), - .name_loc = logger.Loc.Empty, - }, - logger.Loc.Empty, - ), - }, - logger.Loc.Empty, - ), + Expr.joinAllWithComma(&create_require, p.allocator), p.newExpr( E.Dot{ .name = "__dirname", diff --git a/src/js_printer.zig b/src/js_printer.zig index bd771d7b8..a47cc1a23 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -4379,10 +4379,10 @@ fn NewPrinter( p.printGlobalBunImportStatement(s.*); return; }, - .hardcoded => { - p.printHardcodedImportStatement(s.*); - return; - }, + // .hardcoded => { + // p.printHardcodedImportStatement(s.*); + // return; + // }, else => {}, } } @@ -4392,71 +4392,6 @@ fn NewPrinter( const module_id = record.module_id; - if (comptime is_bun_platform) { - if (!record.path.is_disabled) { - if (record.contains_import_star) { - p.print("var "); - p.printSymbol(s.namespace_ref); - p.@"print = "(); - p.print("import.meta.require("); - p.printImportRecordPath(record); - p.print(")"); - p.printSemicolonAfterStatement(); - } - - if (s.items.len > 0 or s.default_name != null) { - p.printIndent(); - p.printSpaceBeforeIdentifier(); - p.printWhitespacer(ws("var {")); - - if (s.default_name) |default_name| { - p.printSpace(); - p.print("default:"); - p.printSpace(); - p.printSymbol(default_name.ref.?); - - if (s.items.len > 0) { - p.printSpace(); - p.print(","); - p.printSpace(); - for (s.items, 0..) |item, i| { - p.printClauseItemAs(item, .@"var"); - - if (i < s.items.len - 1) { - p.print(","); - p.printSpace(); - } - } - } - } else { - for (s.items, 0..) |item, i| { - p.printClauseItemAs(item, .@"var"); - - if (i < s.items.len - 1) { - p.print(","); - p.printSpace(); - } - } - } - - p.print("}"); - p.@"print = "(); - - if (record.contains_import_star) { - p.printSymbol(s.namespace_ref); - p.printSemicolonAfterStatement(); - } else { - p.print("import.meta.require("); - p.printImportRecordPath(record); - p.print(")"); - p.printSemicolonAfterStatement(); - } - } - - return; - } - } - if (!record.path.is_disabled and std.mem.indexOfScalar(u32, p.imported_module_ids.items, module_id) == null) { p.printWhitespacer(ws("import * as")); p.print(" "); diff --git a/src/string.zig b/src/string.zig index 2c75dcc33..54af2ba68 100644 --- a/src/string.zig +++ b/src/string.zig @@ -164,8 +164,13 @@ pub const WTFStringImplStruct = extern struct { return std.mem.Allocator{ .ptr = self, .vtable = StringImplAllocator.VTablePtr }; } + pub fn hasPrefix(self: WTFStringImpl, text: []const u8) bool { + return Bun__WTFStringImpl__hasPrefix(self, text.ptr, text.len); + } + extern fn Bun__WTFStringImpl__deref(self: WTFStringImpl) void; extern fn Bun__WTFStringImpl__ref(self: WTFStringImpl) void; + extern fn Bun__WTFStringImpl__hasPrefix(self: *const WTFStringImplStruct, offset: [*]const u8, length: usize) bool; }; pub const StringImplAllocator = struct { @@ -616,6 +621,10 @@ pub const String = extern struct { } pub fn hasPrefixComptime(this: String, comptime value: []const u8) bool { + if (this.tag == .WTFStringImpl) { + return this.value.WTFStringImpl.hasPrefix(value); + } + return this.toZigString().substring(0, value.len).eqlComptime(value); } diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 0e98f3f5f..d075b38f5 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -1484,7 +1484,8 @@ pub fn convertUTF16ToUTF8(list_: std.ArrayList(u8), comptime Type: type, utf16: pub fn toUTF8AllocWithType(allocator: std.mem.Allocator, comptime Type: type, utf16: Type) ![]u8 { if (bun.FeatureFlags.use_simdutf and comptime Type == []const u16) { const length = bun.simdutf.length.utf8.from.utf16.le(utf16); - var list = try std.ArrayList(u8).initCapacity(allocator, length); + // add 4 bytes of padding for SIMDUTF + var list = try std.ArrayList(u8).initCapacity(allocator, length + 4); list = try convertUTF16ToUTF8(list, Type, utf16); return list.items; } diff --git a/test/bun.lockb b/test/bun.lockb index a26f2fdfe..528415ddd 100755 Binary files a/test/bun.lockb and b/test/bun.lockb differ diff --git a/test/bundler/esbuild/default.test.ts b/test/bundler/esbuild/default.test.ts index 0d1775606..4c4cf87be 100644 --- a/test/bundler/esbuild/default.test.ts +++ b/test/bundler/esbuild/default.test.ts @@ -1,8 +1,8 @@ import assert from "assert"; import dedent from "dedent"; + import { ESBUILD_PATH, RUN_UNCHECKED_TESTS, itBundled, testForFile } from "../expectBundled"; var { describe, test, expect } = testForFile(import.meta.path); - // Tests ported from: // https://github.com/evanw/esbuild/blob/main/internal/bundler_tests/bundler_default_test.go @@ -375,7 +375,10 @@ describe("bundler", () => { // assert bundles weird as of writing "/test.js": /* js */ ` - globalThis.assert = import.meta.require('assert'); + globalThis.assert = require('assert'); + if (typeof assert.deepEqual !== 'function') { + throw new Error('assert.deepEqual is not a function'); + } require('./out.js'); `, }, @@ -1335,8 +1338,8 @@ describe("bundler", () => { import fs from "fs"; import assert from "assert"; import * as module from './out.js'; - assert(module.fs === fs, 'export * as fs from "fs"; works') - assert(module.readFileSync === fs.readFileSync, 'export {readFileSync} from "fs"; works') + assert(module.fs.default === fs, 'export * as fs from "fs"; works') + assert(module.fs.default.readFileSync === fs.readFileSync, 'export {readFileSync} from "fs"; works') `, }, target: "node", @@ -1356,10 +1359,10 @@ describe("bundler", () => { `, "/test.js": /* js */ ` - import fs from "fs"; + import * as fs from "fs"; import assert from "assert"; import * as module from './out.js'; - assert(module.f === fs, 'export {fs as f} works') + assert(module.f.default === fs.default, 'export {fs as f} works') assert(module.rfs === fs.readFileSync, 'export {rfs} works') `, }, @@ -1379,7 +1382,7 @@ describe("bundler", () => { `, "/test.js": /* js */ ` - import fs from "fs"; + import * as fs from "fs"; import assert from "assert"; import * as mod from './out.js'; assert(mod.fs === fs, 'exports.fs') diff --git a/test/cli/run/require-cache-fixture-b.cjs b/test/cli/run/require-cache-fixture-b.cjs index 8f8e40ff0..c3f2c8a26 100644 --- a/test/cli/run/require-cache-fixture-b.cjs +++ b/test/cli/run/require-cache-fixture-b.cjs @@ -1,3 +1,8 @@ exports.foo = 123; exports.bar = 456; exports.baz = 789; + +if (require.main === module) { + console.error(__filename, module.id); + throw new Error("require.main === module"); +} diff --git a/test/cli/run/require-cache-fixture.cjs b/test/cli/run/require-cache-fixture.cjs index b04e751ac..ce02b86d7 100644 --- a/test/cli/run/require-cache-fixture.cjs +++ b/test/cli/run/require-cache-fixture.cjs @@ -3,6 +3,11 @@ const Bun = (globalThis.Bun ??= { gc() {} }); const { resolve } = require("path"); +if (require.main !== module) { + console.error(__filename, module.id); + throw new Error("require.main !== module"); +} + if (__filename !== resolve(module.filename)) { console.error(__filename, module.id); throw new Error("__filename !== module.id"); diff --git a/test/js/bun/eventsource/eventsource.test.ts b/test/js/bun/eventsource/eventsource.test.ts index 2f5b7d755..d4da99aa3 100644 --- a/test/js/bun/eventsource/eventsource.test.ts +++ b/test/js/bun/eventsource/eventsource.test.ts @@ -1,153 +1,153 @@ -function sse(req: Request) { - const signal = req.signal; - return new Response( - new ReadableStream({ - type: "direct", - async pull(controller) { - while (!signal.aborted) { - await controller.write(`data:Hello, World!\n\n`); - await controller.write(`event: bun\ndata: Hello, World!\n\n`); - await controller.write(`event: lines\ndata: Line 1!\ndata: Line 2!\n\n`); - await controller.write(`event: id_test\nid:1\n\n`); - await controller.flush(); - await Bun.sleep(100); - } - controller.close(); - }, - }), - { status: 200, headers: { "Content-Type": "text/event-stream" } }, - ); -} +// function sse(req: Request) { +// const signal = req.signal; +// return new Response( +// new ReadableStream({ +// type: "direct", +// async pull(controller) { +// while (!signal.aborted) { +// await controller.write(`data:Hello, World!\n\n`); +// await controller.write(`event: bun\ndata: Hello, World!\n\n`); +// await controller.write(`event: lines\ndata: Line 1!\ndata: Line 2!\n\n`); +// await controller.write(`event: id_test\nid:1\n\n`); +// await controller.flush(); +// await Bun.sleep(100); +// } +// controller.close(); +// }, +// }), +// { status: 200, headers: { "Content-Type": "text/event-stream" } }, +// ); +// } -function sse_unstable(req: Request) { - const signal = req.signal; - let id = parseInt(req.headers.get("last-event-id") || "0", 10); +// function sse_unstable(req: Request) { +// const signal = req.signal; +// let id = parseInt(req.headers.get("last-event-id") || "0", 10); - return new Response( - new ReadableStream({ - type: "direct", - async pull(controller) { - if (!signal.aborted) { - await controller.write(`id:${++id}\ndata: Hello, World!\nretry:100\n\n`); - await controller.flush(); - } - controller.close(); - }, - }), - { status: 200, headers: { "Content-Type": "text/event-stream" } }, - ); -} +// return new Response( +// new ReadableStream({ +// type: "direct", +// async pull(controller) { +// if (!signal.aborted) { +// await controller.write(`id:${++id}\ndata: Hello, World!\nretry:100\n\n`); +// await controller.flush(); +// } +// controller.close(); +// }, +// }), +// { status: 200, headers: { "Content-Type": "text/event-stream" } }, +// ); +// } -function sseServer( - done: (err?: unknown) => void, - pathname: string, - callback: (evtSource: EventSource, done: (err?: unknown) => void) => void, -) { - const server = Bun.serve({ - port: 0, - fetch(req) { - if (new URL(req.url).pathname === "/stream") { - return sse(req); - } - if (new URL(req.url).pathname === "/unstable") { - return sse_unstable(req); - } - return new Response("Hello, World!"); - }, - }); - let evtSource: EventSource | undefined; - try { - evtSource = new EventSource(`http://localhost:${server.port}${pathname}`); - callback(evtSource, err => { - try { - done(err); - evtSource?.close(); - } catch (err) { - done(err); - } finally { - server.stop(true); - } - }); - } catch (err) { - evtSource?.close(); - server.stop(true); - done(err); - } -} +// function sseServer( +// done: (err?: unknown) => void, +// pathname: string, +// callback: (evtSource: EventSource, done: (err?: unknown) => void) => void, +// ) { +// const server = Bun.serve({ +// port: 0, +// fetch(req) { +// if (new URL(req.url).pathname === "/stream") { +// return sse(req); +// } +// if (new URL(req.url).pathname === "/unstable") { +// return sse_unstable(req); +// } +// return new Response("Hello, World!"); +// }, +// }); +// let evtSource: EventSource | undefined; +// try { +// evtSource = new EventSource(`http://localhost:${server.port}${pathname}`); +// callback(evtSource, err => { +// try { +// done(err); +// evtSource?.close(); +// } catch (err) { +// done(err); +// } finally { +// server.stop(true); +// } +// }); +// } catch (err) { +// evtSource?.close(); +// server.stop(true); +// done(err); +// } +// } -import { describe, expect, it } from "bun:test"; +// import { describe, expect, it } from "bun:test"; -describe("events", () => { - it("should call open", done => { - sseServer(done, "/stream", (evtSource, done) => { - evtSource.onopen = () => { - done(); - }; - evtSource.onerror = err => { - done(err); - }; - }); - }); +// describe("events", () => { +// it("should call open", done => { +// sseServer(done, "/stream", (evtSource, done) => { +// evtSource.onopen = () => { +// done(); +// }; +// evtSource.onerror = err => { +// done(err); +// }; +// }); +// }); - it("should call message", done => { - sseServer(done, "/stream", (evtSource, done) => { - evtSource.onmessage = e => { - expect(e.data).toBe("Hello, World!"); - done(); - }; - }); - }); +// it("should call message", done => { +// sseServer(done, "/stream", (evtSource, done) => { +// evtSource.onmessage = e => { +// expect(e.data).toBe("Hello, World!"); +// done(); +// }; +// }); +// }); - it("should call custom event", done => { - sseServer(done, "/stream", (evtSource, done) => { - evtSource.addEventListener("bun", e => { - expect(e.data).toBe("Hello, World!"); - done(); - }); - }); - }); +// it("should call custom event", done => { +// sseServer(done, "/stream", (evtSource, done) => { +// evtSource.addEventListener("bun", e => { +// expect(e.data).toBe("Hello, World!"); +// done(); +// }); +// }); +// }); - it("should call event with multiple lines", done => { - sseServer(done, "/stream", (evtSource, done) => { - evtSource.addEventListener("lines", e => { - expect(e.data).toBe("Line 1!\nLine 2!"); - done(); - }); - }); - }); +// it("should call event with multiple lines", done => { +// sseServer(done, "/stream", (evtSource, done) => { +// evtSource.addEventListener("lines", e => { +// expect(e.data).toBe("Line 1!\nLine 2!"); +// done(); +// }); +// }); +// }); - it("should receive id", done => { - sseServer(done, "/stream", (evtSource, done) => { - evtSource.addEventListener("id_test", e => { - expect(e.lastEventId).toBe("1"); - done(); - }); - }); - }); +// it("should receive id", done => { +// sseServer(done, "/stream", (evtSource, done) => { +// evtSource.addEventListener("id_test", e => { +// expect(e.lastEventId).toBe("1"); +// done(); +// }); +// }); +// }); - it("should reconnect with id", done => { - sseServer(done, "/unstable", (evtSource, done) => { - const ids: string[] = []; - evtSource.onmessage = e => { - ids.push(e.lastEventId); - if (ids.length === 2) { - for (let i = 0; i < 2; i++) { - expect(ids[i]).toBe((i + 1).toString()); - } - done(); - } - }; - }); - }); +// it("should reconnect with id", done => { +// sseServer(done, "/unstable", (evtSource, done) => { +// const ids: string[] = []; +// evtSource.onmessage = e => { +// ids.push(e.lastEventId); +// if (ids.length === 2) { +// for (let i = 0; i < 2; i++) { +// expect(ids[i]).toBe((i + 1).toString()); +// } +// done(); +// } +// }; +// }); +// }); - it("should call error", done => { - sseServer(done, "/", (evtSource, done) => { - evtSource.onerror = e => { - expect(e.error.message).toBe( - `EventSource's response has a MIME type that is not "text/event-stream". Aborting the connection.`, - ); - done(); - }; - }); - }); -}); +// it("should call error", done => { +// sseServer(done, "/", (evtSource, done) => { +// evtSource.onerror = e => { +// expect(e.error.message).toBe( +// `EventSource's response has a MIME type that is not "text/event-stream". Aborting the connection.`, +// ); +// done(); +// }; +// }); +// }); +// }); diff --git a/test/js/bun/resolve/import-meta.test.js b/test/js/bun/resolve/import-meta.test.js index 5771aeb30..7d385148b 100644 --- a/test/js/bun/resolve/import-meta.test.js +++ b/test/js/bun/resolve/import-meta.test.js @@ -9,7 +9,7 @@ import sync from "./require-json.json"; const { path, dir } = import.meta; it("primordials are not here!", () => { - expect(import.meta.primordials === undefined).toBe(true); + expect(globalThis[Symbol.for("Bun.lazy")]("primordials") === undefined).toBe(true); }); it("import.meta.main", () => { diff --git a/test/js/node/assert/assert-test.test.ts b/test/js/node/assert/assert-test.test.ts deleted file mode 100644 index 1723b7d47..000000000 --- a/test/js/node/assert/assert-test.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import assert from "assert"; -import { expect, test } from "bun:test"; - -// https://github.com/oven-sh/bun/issues/941 -test("assert as a function does not throw", () => assert(true)); -test("assert as a function does throw", () => { - try { - assert(false); - expect(false).toBe(true); - } catch (e) {} -}); diff --git a/test/js/node/assert/assert.test.cjs b/test/js/node/assert/assert.test.cjs new file mode 100644 index 000000000..e9d472412 --- /dev/null +++ b/test/js/node/assert/assert.test.cjs @@ -0,0 +1,9 @@ +const assert = require("assert"); + +test("assert from require as a function does not throw", () => assert(true)); +test("assert from require as a function does throw", () => { + try { + assert(false); + expect(false).toBe(true); + } catch (e) {} +}); diff --git a/test/js/node/assert/assert.test.ts b/test/js/node/assert/assert.test.ts new file mode 100644 index 000000000..1723b7d47 --- /dev/null +++ b/test/js/node/assert/assert.test.ts @@ -0,0 +1,11 @@ +import assert from "assert"; +import { expect, test } from "bun:test"; + +// https://github.com/oven-sh/bun/issues/941 +test("assert as a function does not throw", () => assert(true)); +test("assert as a function does throw", () => { + try { + assert(false); + expect(false).toBe(true); + } catch (e) {} +}); diff --git a/test/js/node/disabled-module.test.cjs b/test/js/node/disabled-module.test.cjs new file mode 100644 index 000000000..bc4817b8d --- /dev/null +++ b/test/js/node/disabled-module.test.cjs @@ -0,0 +1,6 @@ +test("not implemented yet module masquerades as undefined in cjs and throws an error", () => { + const worker_threads = require("worker_threads"); + + expect(typeof worker_threads).toBe("undefined"); + expect(typeof worker_threads.getEnvironmentData).toBe("undefined"); +}); diff --git a/test/js/node/disabled-module.test.js b/test/js/node/disabled-module.test.js index d02a6b6df..bb707a122 100644 --- a/test/js/node/disabled-module.test.js +++ b/test/js/node/disabled-module.test.js @@ -1,15 +1,16 @@ import { expect, test } from "bun:test"; +import { AsyncResource, AsyncLocalStorage } from "async_hooks"; +import * as worker_threads from "worker_threads"; +import worker_threads_default from "worker_threads"; test("not implemented yet module masquerades as undefined and throws an error", () => { - const worker_threads = import.meta.require("worker_threads"); - - expect(typeof worker_threads).toBe("undefined"); + expect(typeof worker_threads.default).toBe("undefined"); + expect(typeof worker_threads_default).toBe("undefined"); expect(typeof worker_threads.getEnvironmentData).toBe("undefined"); + expect(typeof worker_threads_default.getEnvironmentData).toBe("undefined"); }); test("AsyncLocalStorage polyfill", () => { - const { AsyncLocalStorage } = import.meta.require("async_hooks"); - const store = new AsyncLocalStorage(); var called = false; expect(store.getStore()).toBe(null); @@ -22,8 +23,6 @@ test("AsyncLocalStorage polyfill", () => { }); test("AsyncResource polyfill", () => { - const { AsyncResource } = import.meta.require("async_hooks"); - const resource = new AsyncResource("prisma-client-request"); var called = false; resource.runInAsyncScope( @@ -36,3 +35,9 @@ test("AsyncResource polyfill", () => { ); expect(called).toBe(true); }); + +test("esbuild functions with worker_threads stub", async () => { + const esbuild = await import("esbuild"); + const result = await esbuild.transform('console . log( "hello world" )', { minify: true }); + expect(result.code).toBe('console.log("hello world");\n'); +}); diff --git a/test/js/node/events/event-emitter.test.ts b/test/js/node/events/event-emitter.test.ts index cef309d48..5a1385383 100644 --- a/test/js/node/events/event-emitter.test.ts +++ b/test/js/node/events/event-emitter.test.ts @@ -1,5 +1,6 @@ import { test, describe, expect } from "bun:test"; import { sleep } from "bun"; +import { createRequire } from "module"; // this is also testing that imports with default and named imports in the same statement work // our transpiler transform changes this to a var with import.meta.require @@ -534,4 +535,10 @@ describe("EventEmitter constructors", () => { expect(called).toBe(true); }); } + + test("with createRequire, events is callable", () => { + const req = createRequire(import.meta.path); + const events = req("events"); + new events(); + }); }); diff --git a/test/js/node/events/events-cjs.test.js b/test/js/node/events/events-cjs.test.js new file mode 100644 index 000000000..5bee9979f --- /dev/null +++ b/test/js/node/events/events-cjs.test.js @@ -0,0 +1,4 @@ +test("in cjs, events is callable", () => { + const events = require("events"); + new events(); +}); diff --git a/test/js/node/path/path.test.js b/test/js/node/path/path.test.js index 94b0568f6..8f5a76da7 100644 --- a/test/js/node/path/path.test.js +++ b/test/js/node/path/path.test.js @@ -1,7 +1,7 @@ const { file } = import.meta; import { describe, it, expect } from "bun:test"; -import * as path from "node:path"; +import path from "node:path"; import assert from "assert"; import { hideFromStackTrace } from "harness"; diff --git a/test/js/node/process/print-process-args.js b/test/js/node/process/print-process-args.js index 0ab238122..e9d2295c8 100644 --- a/test/js/node/process/print-process-args.js +++ b/test/js/node/process/print-process-args.js @@ -1,3 +1,11 @@ +import assert from "assert"; + +// ensure process.argv and Bun.argv are the same +assert.deepStrictEqual(process.argv, Bun.argv, "process.argv does not equal Bun.argv"); +assert(process.argv === process.argv, "process.argv isn't cached"); +// assert(Bun.argv === Bun.argv, 'Bun.argv isn\'t cached'); +// assert(Bun.argv === process.argv, 'Bun.argv doesnt share same ref as process.argv'); + var writer = Bun.stdout.writer(); writer.write(JSON.stringify(process.argv)); await writer.flush(true); diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index ee181e70c..61ac3839c 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -226,10 +226,9 @@ it("process.binding", () => { expect(() => process.binding("buffer")).toThrow(); }); -it("process.argv", () => { +it("process.argv in testing", () => { expect(process.argv).toBeInstanceOf(Array); expect(process.argv[0]).toBe(bunExe()); - expect(process.argv).toEqual(Bun.argv); // assert we aren't creating a new process.argv each call expect(process.argv).toBe(process.argv); diff --git a/test/js/node/stubs.test.js b/test/js/node/stubs.test.js index e6bce8aee..1025907ab 100644 --- a/test/js/node/stubs.test.js +++ b/test/js/node/stubs.test.js @@ -99,6 +99,9 @@ for (let specifier of specifiers) { } } } + } else { + // TODO: uncomment this after node:module can be default imported + // throw new Error(`Module ${specifier} has no default export`); } }); } diff --git a/test/js/node/util/test-util-types.test.js b/test/js/node/util/test-util-types.test.js index f33ab4b1a..a75b9eac0 100644 --- a/test/js/node/util/test-util-types.test.js +++ b/test/js/node/util/test-util-types.test.js @@ -1,6 +1,9 @@ -const assert = require("assert"); -import { test, expect } from "bun:test"; -const types = require("util/types"); +import assert from "assert"; +import { describe, test, expect } from "bun:test"; +import def from "util/types"; +import * as ns from "util/types"; +const req = require("util/types"); +const types = def; function inspect(val) { return Bun.inspect(val); @@ -52,15 +55,21 @@ for (const [value, _method] of [ assert(method in types, `Missing ${method} for ${inspect(value)}`); assert(types[method](value), `Want ${inspect(value)} to match ${method}`); - for (const key of Object.keys(types)) { - if ( - ((types.isArrayBufferView(value) || types.isAnyArrayBuffer(value)) && key.includes("Array")) || - key === "isBoxedPrimitive" - ) { - continue; - } + for (const [types, label] of [ + [def, "default import"], + [ns, "ns import"], + [req, "require esm"], + ]) { + for (const key of Object.keys(types).filter(x => x !== "default")) { + if ( + ((types.isArrayBufferView(value) || types.isAnyArrayBuffer(value)) && key.includes("Array")) || + key === "isBoxedPrimitive" + ) { + continue; + } - expect(types[key](value)).toBe(key === method); + expect(types[key](value)).toBe(key === method); + } } }); } @@ -238,3 +247,4 @@ test("isBoxedPrimitive", () => { }); } } +// */ diff --git a/test/package.json b/test/package.json index 480305013..b9aa55ae2 100644 --- a/test/package.json +++ b/test/package.json @@ -11,7 +11,7 @@ "bktree-fast": "^0.0.7", "body-parser": "^1.20.2", "dedent": "^0.7.0", - "esbuild": "^0.17.16", + "esbuild": "^0.18.6", "express": "^4.18.2", "iconv-lite": "^0.6.3", "jest-extended": "^4.0.0", -- cgit v1.2.3 From fdfbb18531828fc5dec329d5d9e5c828a3c83921 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 25 Jun 2023 16:32:27 -0700 Subject: Support reading embedded files in compiled executables (#3405) * Support reading embedded files in compiled executables * :nail_care: --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/api/bun.zig | 3 +++ src/bun.js/api/server.zig | 22 +++++++++------------- src/bun.js/javascript.zig | 5 ++++- src/bun.js/node/node_fs.zig | 30 ++++++++++++++++++++++++++++++ src/bun.js/webcore/blob.zig | 36 ++++++++++++++++++++++++++++++++++-- src/cli/build_command.zig | 1 + src/standalone_bun.zig | 44 +++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 124 insertions(+), 17 deletions(-) (limited to 'src/bun.js/webcore/blob.zig') diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 034aaa81f..2e6381c74 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -896,6 +896,9 @@ pub fn createNodeFS( ) js.JSValueRef { var module = ctx.allocator().create(JSC.Node.NodeJSFS) catch unreachable; module.* = .{}; + var vm = ctx.bunVM(); + if (vm.standalone_module_graph != null) + module.node_fs.vm = vm; return module.toJS(ctx).asObjectRef(); } diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index a56ff971f..ebfacdcc9 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -2744,19 +2744,15 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp // 1. Bun.file("foo") // 2. The content-disposition header is not present if (!has_content_disposition and content_type.category.autosetFilename()) { - if (this.blob.store()) |store| { - if (store.data == .file) { - if (store.data.file.pathlike == .path) { - const basename = std.fs.path.basename(store.data.file.pathlike.path.slice()); - if (basename.len > 0) { - var filename_buf: [1024]u8 = undefined; - - resp.writeHeader( - "content-disposition", - std.fmt.bufPrint(&filename_buf, "filename=\"{s}\"", .{basename[0..@min(basename.len, 1024 - 32)]}) catch "", - ); - } - } + if (this.blob.getFileName()) |filename| { + const basename = std.fs.path.basename(filename); + if (basename.len > 0) { + var filename_buf: [1024]u8 = undefined; + + resp.writeHeader( + "content-disposition", + std.fmt.bufPrint(&filename_buf, "filename=\"{s}\"", .{basename[0..@min(basename.len, 1024 - 32)]}) catch "", + ); } } } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 3baa25e22..cb1a50f1d 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -593,7 +593,10 @@ pub const VirtualMachine = struct { pub inline fn nodeFS(this: *VirtualMachine) *Node.NodeFS { return this.node_fs orelse brk: { this.node_fs = bun.default_allocator.create(Node.NodeFS) catch unreachable; - this.node_fs.?.* = Node.NodeFS{}; + this.node_fs.?.* = Node.NodeFS{ + // only used when standalone module graph is enabled + .vm = if (this.standalone_module_graph != null) this else null, + }; break :brk this.node_fs.?; }; } diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 21a65251a..35c616a89 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -2492,6 +2492,7 @@ pub const NodeFS = struct { /// That means a stack-allocated buffer won't suffice. Instead, we re-use /// the heap allocated buffer on the NodefS struct sync_error_buf: [bun.MAX_PATH_BYTES]u8 = undefined, + vm: ?*JSC.VirtualMachine = null, pub const ReturnType = Return; @@ -3442,6 +3443,35 @@ pub const NodeFS = struct { const fd = switch (args.path) { .path => brk: { path = args.path.path.sliceZ(&this.sync_error_buf); + if (this.vm) |vm| { + if (vm.standalone_module_graph) |graph| { + if (graph.find(path)) |file| { + if (args.encoding == .buffer) { + return .{ + .result = .{ + .buffer = Buffer.fromBytes( + bun.default_allocator.dupe(u8, file.contents) catch @panic("out of memory"), + bun.default_allocator, + .Uint8Array, + ), + }, + }; + } else if (comptime string_type == .default) + .{ + .result = .{ + .string = bun.default_allocator.dupe(u8, file.contents) catch @panic("out of memory"), + }, + } + else + .{ + .result = .{ + .null_terminated = bun.default_allocator.dupeZ(u8, file.contents) catch @panic("out of memory"), + }, + }; + } + } + } + break :brk switch (Syscall.open( path, os.O.RDONLY | os.O.NOCTTY, diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index 1e63ea3a2..868acbb80 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -952,6 +952,13 @@ pub const Blob = struct { switch (path_) { .path => { const slice = path_.path.slice(); + + if (vm.standalone_module_graph) |graph| { + if (graph.find(slice)) |file| { + return file.blob(globalThis).dupe(); + } + } + var cloned = (allocator.dupeZ(u8, slice) catch unreachable)[0..slice.len]; break :brk .{ @@ -2195,6 +2202,9 @@ pub const Blob = struct { cap: SizeType = 0, allocator: std.mem.Allocator, + /// Used by standalone module graph + stored_name: bun.PathString = bun.PathString.empty, + pub fn init(bytes: []u8, allocator: std.mem.Allocator) ByteStore { return .{ .ptr = bytes.ptr, @@ -2528,17 +2538,31 @@ pub const Blob = struct { this: *Blob, globalThis: *JSC.JSGlobalObject, ) callconv(.C) JSValue { + if (this.getFileName()) |path| { + var str = bun.String.create(path); + return str.toJS(globalThis); + } + + return JSValue.undefined; + } + + pub fn getFileName( + this: *const Blob, + ) ?[]const u8 { if (this.store) |store| { if (store.data == .file) { if (store.data.file.pathlike == .path) { - return ZigString.fromUTF8(store.data.file.pathlike.path.slice()).toValueGC(globalThis); + return store.data.file.pathlike.path.slice(); } // we shouldn't return Number here. + } else if (store.data == .bytes) { + if (store.data.bytes.stored_name.slice().len > 0) + return store.data.bytes.stored_name.slice(); } } - return JSC.JSValue.jsUndefined(); + return null; } // TODO: Move this to a separate `File` object or BunFile @@ -3469,6 +3493,14 @@ pub const AnyBlob = union(enum) { InternalBlob: InternalBlob, WTFStringImpl: bun.WTF.StringImpl, + pub fn getFileName(this: *const AnyBlob) ?[]const u8 { + return switch (this.*) { + .Blob => this.Blob.getFileName(), + .WTFStringImpl => null, + .InternalBlob => null, + }; + } + pub inline fn fastSize(this: *const AnyBlob) Blob.SizeType { return switch (this.*) { .Blob => this.Blob.size, diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig index 44e512996..ef99f7765 100644 --- a/src/cli/build_command.zig +++ b/src/cli/build_command.zig @@ -107,6 +107,7 @@ pub const BuildCommand = struct { // We never want to hit the filesystem for these files // This "compiled" protocol is specially handled by the module resolver. this_bundler.options.public_path = "compiled://root/"; + this_bundler.resolver.opts.public_path = "compiled://root/"; if (outfile.len == 0) { outfile = std.fs.path.basename(this_bundler.options.entry_points[0]); diff --git a/src/standalone_bun.zig b/src/standalone_bun.zig index e7363fb58..b18fe384e 100644 --- a/src/standalone_bun.zig +++ b/src/standalone_bun.zig @@ -18,6 +18,14 @@ pub const StandaloneModuleGraph = struct { return &this.files.values()[this.entry_point_id]; } + pub fn find(this: *const StandaloneModuleGraph, name: []const u8) ?*File { + if (!bun.strings.hasPrefixComptime(name, "compiled://root/")) { + return null; + } + + return this.files.getPtr(name); + } + pub const CompiledModuleGraphFile = struct { name: Schema.StringPointer = .{}, loader: bun.options.Loader = .file, @@ -30,6 +38,32 @@ pub const StandaloneModuleGraph = struct { loader: bun.options.Loader, contents: []const u8 = "", sourcemap: LazySourceMap, + blob_: ?*bun.JSC.WebCore.Blob = null, + + pub fn blob(this: *File, globalObject: *bun.JSC.JSGlobalObject) *bun.JSC.WebCore.Blob { + if (this.blob_ == null) { + var store = bun.JSC.WebCore.Blob.Store.init(@constCast(this.contents), bun.default_allocator) catch @panic("out of memory"); + // make it never free + store.ref(); + + var blob_ = bun.default_allocator.create(bun.JSC.WebCore.Blob) catch @panic("out of memory"); + blob_.* = bun.JSC.WebCore.Blob.initWithStore(store, globalObject); + blob_.allocator = bun.default_allocator; + + if (bun.HTTP.MimeType.byExtensionNoDefault(bun.strings.trimLeadingChar(std.fs.path.extension(this.name), '.'))) |mime| { + store.mime_type = mime; + blob_.content_type = mime.value; + blob_.content_type_was_set = true; + blob_.content_type_allocated = false; + } + + store.data.bytes.stored_name = bun.PathString.init(this.name); + + this.blob_ = blob_; + } + + return this.blob_.?; + } }; pub const LazySourceMap = union(enum) { @@ -152,8 +186,16 @@ pub const StandaloneModuleGraph = struct { continue; } + var dest_path = output_file.dest_path; + if (bun.strings.hasPrefixComptime(dest_path, "./")) { + dest_path = dest_path[2..]; + } + var module = CompiledModuleGraphFile{ - .name = string_builder.fmtAppendCount("{s}{s}", .{ prefix, output_file.dest_path }), + .name = string_builder.fmtAppendCount("{s}{s}", .{ + prefix, + dest_path, + }), .loader = output_file.loader, .contents = string_builder.appendCount(output_file.value.buffer.bytes), }; -- cgit v1.2.3 From 292647bd531c154f81d2d3d8f3344e01752549f6 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 28 Jun 2023 16:09:08 -0700 Subject: Introduce `await Bun.file(path).exists()` (#3446) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- packages/bun-types/bun.d.ts | 24 +++++++++++++++++++++- src/bun.js/bindings/ZigGeneratedClasses.cpp | 31 +++++++++++++++++++++++++++++ src/bun.js/bindings/generated_classes.zig | 3 +++ src/bun.js/webcore/blob.zig | 29 +++++++++++++++++++++++++++ src/bun.js/webcore/response.classes.ts | 1 + test/js/bun/util/bun-file-exists.test.js | 8 ++++++++ 6 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 test/js/bun/util/bun-file-exists.test.js (limited to 'src/bun.js/webcore/blob.zig') diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 306971d4c..4c10212f2 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -673,7 +673,29 @@ declare module "bun" { /** * The name or path of the file, as specified in the constructor. */ - name?: number; + readonly name?: string; + + /** + * Does the file exist? + * + * This returns true for regular files and FIFOs. It returns false for + * directories. Note that a race condition can occur where the file is + * deleted or renamed after this is called but before you open it. + * + * This does a system call to check if the file exists, which can be + * slow. + * + * If using this in an HTTP server, it's faster to instead use `return new + * Response(Bun.file(path))` and then an `error` handler to handle + * exceptions. + * + * Instead of checking for a file's existence and then performing the + * operation, it is faster to just perform the operation and handle the + * error. + * + * For empty Blob, this always returns true. + */ + exists(): Promise; } /** diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp index 387580d54..b7461b5f0 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.cpp +++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp @@ -103,6 +103,9 @@ extern "C" void BlobClass__finalize(void*); extern "C" EncodedJSValue BlobPrototype__getArrayBuffer(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(BlobPrototype__arrayBufferCallback); +extern "C" EncodedJSValue BlobPrototype__getExists(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(BlobPrototype__existsCallback); + extern "C" EncodedJSValue BlobPrototype__getFormData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(BlobPrototype__formDataCallback); @@ -137,6 +140,7 @@ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBlobPrototype, JSBlobPrototype::Base); static const HashTableValue JSBlobPrototypeTableValues[] = { { "arrayBuffer"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__arrayBufferCallback, 0 } }, + { "exists"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__existsCallback, 0 } }, { "formData"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__formDataCallback, 0 } }, { "json"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__jsonCallback, 0 } }, { "lastModified"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BlobPrototype__lastModifiedGetterWrap, 0 } }, @@ -190,6 +194,33 @@ JSC_DEFINE_HOST_FUNCTION(BlobPrototype__arrayBufferCallback, (JSGlobalObject * l return BlobPrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame); } +JSC_DEFINE_HOST_FUNCTION(BlobPrototype__existsCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSBlob* thisObject = jsDynamicCast(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + return throwVMTypeError(lexicalGlobalObject, throwScope); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + +#ifdef BUN_DEBUG + /** View the file name of the JS file that called this function + * from a debugger */ + SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); + const char* fileName = sourceOrigin.string().utf8().data(); + static const char* lastFileName = nullptr; + if (lastFileName != fileName) { + lastFileName = fileName; + } +#endif + + return BlobPrototype__getExists(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + JSC_DEFINE_HOST_FUNCTION(BlobPrototype__formDataCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { auto& vm = lexicalGlobalObject->vm(); diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig index bdde69c1a..04a72d7ed 100644 --- a/src/bun.js/bindings/generated_classes.zig +++ b/src/bun.js/bindings/generated_classes.zig @@ -108,6 +108,8 @@ pub const JSBlob = struct { if (@TypeOf(Blob.getArrayBuffer) != CallbackType) @compileLog("Expected Blob.getArrayBuffer to be a callback but received " ++ @typeName(@TypeOf(Blob.getArrayBuffer))); + if (@TypeOf(Blob.getExists) != CallbackType) + @compileLog("Expected Blob.getExists to be a callback but received " ++ @typeName(@TypeOf(Blob.getExists))); if (@TypeOf(Blob.getFormData) != CallbackType) @compileLog("Expected Blob.getFormData to be a callback but received " ++ @typeName(@TypeOf(Blob.getFormData))); if (@TypeOf(Blob.getJSON) != CallbackType) @@ -136,6 +138,7 @@ pub const JSBlob = struct { @export(Blob.constructor, .{ .name = "BlobClass__construct" }); @export(Blob.finalize, .{ .name = "BlobClass__finalize" }); @export(Blob.getArrayBuffer, .{ .name = "BlobPrototype__getArrayBuffer" }); + @export(Blob.getExists, .{ .name = "BlobPrototype__getExists" }); @export(Blob.getFormData, .{ .name = "BlobPrototype__getFormData" }); @export(Blob.getJSON, .{ .name = "BlobPrototype__getJSON" }); @export(Blob.getLastModified, .{ .name = "BlobPrototype__getLastModified" }); diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index 868acbb80..faf503a3f 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -319,6 +319,7 @@ pub const Blob = struct { }, ); } + pub fn writeFormat(this: *const Blob, comptime Formatter: type, formatter: *Formatter, writer: anytype, comptime enable_ansi_colors: bool) !void { const Writer = @TypeOf(writer); @@ -2324,6 +2325,34 @@ pub const Blob = struct { return promisified(this.toFormData(globalThis, .temporary), globalThis); } + fn getExistsSync(this: *Blob) JSC.JSValue { + if (this.size == Blob.max_size) { + this.resolveSize(); + } + + // If there's no store that means it's empty and we just return true + // it will not error to return an empty Blob + var store = this.store orelse return JSValue.jsBoolean(true); + + if (store.data == .bytes) { + // Bytes will never error + return JSValue.jsBoolean(true); + } + + // We say regular files and pipes exist. + // This is mostly meant for "Can we use this in new Response(file)?" + return JSValue.jsBoolean(std.os.S.ISREG(store.data.file.mode) or std.os.S.ISFIFO(store.data.file.mode)); + } + + // This mostly means 'can it be read?' + pub fn getExists( + this: *Blob, + globalThis: *JSC.JSGlobalObject, + _: *JSC.CallFrame, + ) callconv(.C) JSValue { + return JSC.JSPromise.resolvedPromiseValue(globalThis, this.getExistsSync()); + } + pub fn getWriter( this: *Blob, globalThis: *JSC.JSGlobalObject, diff --git a/src/bun.js/webcore/response.classes.ts b/src/bun.js/webcore/response.classes.ts index b6ad452d2..c11cb10b2 100644 --- a/src/bun.js/webcore/response.classes.ts +++ b/src/bun.js/webcore/response.classes.ts @@ -132,6 +132,7 @@ export default [ slice: { fn: "getSlice", length: 2 }, stream: { fn: "getStream", length: 1 }, formData: { fn: "getFormData" }, + exists: { fn: "getExists", length: 0 }, type: { getter: "getType", diff --git a/test/js/bun/util/bun-file-exists.test.js b/test/js/bun/util/bun-file-exists.test.js new file mode 100644 index 000000000..da6dce192 --- /dev/null +++ b/test/js/bun/util/bun-file-exists.test.js @@ -0,0 +1,8 @@ +import { test, expect } from "bun:test"; + +test("bun-file-exists", async () => { + expect(await Bun.file(import.meta.path).exists()).toBeTrue(); + expect(await Bun.file(import.meta.path + "boop").exists()).toBeFalse(); + expect(await Bun.file(import.meta.dir).exists()).toBeFalse(); + expect(await Bun.file(import.meta.dir + "/").exists()).toBeFalse(); +}); -- cgit v1.2.3 From f00e2be548da21b9feaef178bb0ac22230801d6f Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 1 Jul 2023 17:37:44 -0700 Subject: Use `BunString` in `SystemError` (#3485) * Use `BunString` in SystemError * Use Bun::toStringRef when we will de-ref strings * Move `napi_create_error` to C++ to support `code` being a Symbol potentially * Update blob.zig * Make this test less flaky --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/api/bun/dns_resolver.zig | 8 ++-- src/bun.js/api/bun/socket.zig | 12 ++--- src/bun.js/api/ffi.zig | 6 +-- src/bun.js/api/server.zig | 12 ++--- src/bun.js/bindings/BunString.cpp | 48 +++++++++++++++++--- src/bun.js/bindings/bindings.cpp | 66 +++++++++++++--------------- src/bun.js/bindings/bindings.zig | 8 ++-- src/bun.js/bindings/headers-handwritten.h | 12 +++-- src/bun.js/bindings/helpers.h | 4 +- src/bun.js/bindings/napi.cpp | 29 +++++++++--- src/bun.js/bindings/webcore/JSCloseEvent.cpp | 2 +- src/bun.js/node/node_os.zig | 32 +++++++------- src/bun.js/node/syscall.zig | 8 ++-- src/bun.js/webcore/blob.zig | 55 +++++++++++------------ src/bun.js/webcore/response.zig | 14 +++--- src/bun.js/webcore/streams.zig | 6 +-- src/bundler/bundle_v2.zig | 16 +++++-- src/http.zig | 5 ++- src/napi/napi.zig | 11 +---- test/js/bun/util/error-gc-test.test.js | 41 ++++++++++++++++- 20 files changed, 242 insertions(+), 153 deletions(-) (limited to 'src/bun.js/webcore/blob.zig') diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig index fee834e5e..d0d4f5b7b 100644 --- a/src/bun.js/api/bun/dns_resolver.zig +++ b/src/bun.js/api/bun/dns_resolver.zig @@ -1925,8 +1925,8 @@ pub const DNSResolver = struct { .err => |err| { const system_error = JSC.SystemError{ .errno = -1, - .code = JSC.ZigString.init(err.code()), - .message = JSC.ZigString.init(err.label()), + .code = bun.String.static(err.code()), + .message = bun.String.static(err.label()), }; globalThis.throwValue(system_error.toErrorInstance(globalThis)); @@ -1972,8 +1972,8 @@ pub const DNSResolver = struct { .err => |err| { const system_error = JSC.SystemError{ .errno = -1, - .code = JSC.ZigString.init(err.code()), - .message = JSC.ZigString.init(err.label()), + .code = bun.String.static(err.code()), + .message = bun.String.static(err.label()), }; globalThis.throwValue(system_error.toErrorInstance(globalThis)); diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 00e34a77d..69d6611cb 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -1022,8 +1022,8 @@ fn NewSocket(comptime ssl: bool) type { var globalObject = handlers.globalObject; const err = JSC.SystemError{ .errno = errno, - .message = ZigString.init("Failed to connect"), - .syscall = ZigString.init("connect"), + .message = bun.String.static("Failed to connect"), + .syscall = bun.String.static("connect"), }; if (callback == .zero) { @@ -1232,8 +1232,8 @@ fn NewSocket(comptime ssl: bool) type { const reason = if (ssl_error.reason == null) "" else ssl_error.reason[0..bun.len(ssl_error.reason)]; const fallback = JSC.SystemError{ - .code = ZigString.init(code), - .message = ZigString.init(reason), + .code = bun.String.create(code), + .message = bun.String.create(reason), }; authorization_error = fallback.toErrorInstance(globalObject); @@ -1409,8 +1409,8 @@ fn NewSocket(comptime ssl: bool) type { const reason = if (ssl_error.reason == null) "" else ssl_error.reason[0..bun.len(ssl_error.reason)]; const fallback = JSC.SystemError{ - .code = ZigString.init(code), - .message = ZigString.init(reason), + .code = bun.String.create(code), + .message = bun.String.create(reason), }; return fallback.toErrorInstance(globalObject); diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig index e46e054ec..ba31b67ed 100644 --- a/src/bun.js/api/ffi.zig +++ b/src/bun.js/api/ffi.zig @@ -311,9 +311,9 @@ pub const FFI = struct { break :brk std.DynLib.open(backup_name) catch { // Then, if that fails, report an error. const system_error = JSC.SystemError{ - .code = ZigString.init(@tagName(JSC.Node.ErrorCode.ERR_DLOPEN_FAILED)), - .message = ZigString.init("Failed to open library. This is usually caused by a missing library or an invalid library path."), - .syscall = ZigString.init("dlopen"), + .code = bun.String.create(@tagName(JSC.Node.ErrorCode.ERR_DLOPEN_FAILED)), + .message = bun.String.create("Failed to open library. This is usually caused by a missing library or an invalid library path."), + .syscall = bun.String.create("dlopen"), }; return system_error.toErrorInstance(global); }; diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 136737069..140e62ce4 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -1796,7 +1796,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp .syscall = .sendfile, }; var sys = err.withPathLike(file.pathlike).toSystemError(); - sys.message = ZigString.init("MacOS does not support sending non-regular files"); + sys.message = bun.String.static("MacOS does not support sending non-regular files"); this.runErrorHandler(sys.toErrorInstance( this.server.globalThis, )); @@ -1815,7 +1815,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp .syscall = .sendfile, }; var sys = err.withPathLike(file.pathlike).toSystemError(); - sys.message = ZigString.init("File must be regular or FIFO"); + sys.message = bun.String.static("File must be regular or FIFO"); this.runErrorHandler(sys.toErrorInstance( this.server.globalThis, )); @@ -2375,8 +2375,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } const fallback = JSC.SystemError{ - .code = ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_UNHANDLED_ERROR))), - .message = ZigString.init("Unhandled error in ReadableStream"), + .code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_UNHANDLED_ERROR))), + .message = bun.String.static("Unhandled error in ReadableStream"), }; req.handleReject(fallback.toErrorInstance(globalThis)); } @@ -2422,8 +2422,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp if (stream.isLocked(this.server.globalThis)) { streamLog("was locked but it shouldn't be", .{}); var err = JSC.SystemError{ - .code = ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_STREAM_CANNOT_PIPE))), - .message = ZigString.init("Stream already used, please create a new one"), + .code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_STREAM_CANNOT_PIPE))), + .message = bun.String.static("Stream already used, please create a new one"), }; stream.value.unprotect(); this.runErrorHandler(err.toErrorInstance(this.server.globalThis)); diff --git a/src/bun.js/bindings/BunString.cpp b/src/bun.js/bindings/BunString.cpp index f590edd35..4c8ff384e 100644 --- a/src/bun.js/bindings/BunString.cpp +++ b/src/bun.js/bindings/BunString.cpp @@ -86,31 +86,69 @@ BunString toString(JSC::JSGlobalObject* globalObject, JSValue value) return fromJS(globalObject, value); } +BunString toStringRef(JSC::JSGlobalObject* globalObject, JSValue value) +{ + auto str = value.toWTFString(globalObject); + if (str.isEmpty()) { + return { BunStringTag::Empty }; + } + + str.impl()->ref(); + + return { BunStringTag::WTFStringImpl, { .wtf = str.impl() } }; +} + BunString toString(WTF::String& wtfString) { - if (wtfString.length() == 0) + if (wtfString.isEmpty()) return { BunStringTag::Empty }; return { BunStringTag::WTFStringImpl, { .wtf = wtfString.impl() } }; } BunString toString(const WTF::String& wtfString) { - if (wtfString.length() == 0) + if (wtfString.isEmpty()) return { BunStringTag::Empty }; return { BunStringTag::WTFStringImpl, { .wtf = wtfString.impl() } }; } BunString toString(WTF::StringImpl* wtfString) { - if (wtfString->length() == 0) + if (wtfString->isEmpty()) return { BunStringTag::Empty }; return { BunStringTag::WTFStringImpl, { .wtf = wtfString } }; } +BunString toStringRef(WTF::String& wtfString) +{ + if (wtfString.isEmpty()) + return { BunStringTag::Empty }; + + wtfString.impl()->ref(); + return { BunStringTag::WTFStringImpl, { .wtf = wtfString.impl() } }; +} +BunString toStringRef(const WTF::String& wtfString) +{ + if (wtfString.isEmpty()) + return { BunStringTag::Empty }; + + wtfString.impl()->ref(); + return { BunStringTag::WTFStringImpl, { .wtf = wtfString.impl() } }; +} +BunString toStringRef(WTF::StringImpl* wtfString) +{ + if (wtfString->isEmpty()) + return { BunStringTag::Empty }; + + wtfString->ref(); + + return { BunStringTag::WTFStringImpl, { .wtf = wtfString } }; +} + BunString fromString(WTF::String& wtfString) { - if (wtfString.length() == 0) + if (wtfString.isEmpty()) return { BunStringTag::Empty }; return { BunStringTag::WTFStringImpl, { .wtf = wtfString.impl() } }; @@ -118,7 +156,7 @@ BunString fromString(WTF::String& wtfString) BunString fromString(WTF::StringImpl* wtfString) { - if (wtfString->length() == 0) + if (wtfString->isEmpty()) return { BunStringTag::Empty }; return { BunStringTag::WTFStringImpl, { .wtf = wtfString } }; diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 96fcde303..9f9b20c1e 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -1279,15 +1279,14 @@ JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0, JSC__JSGlobalObject* globalObject) { - static const char* system_error_name = "SystemError"; SystemError err = *arg0; JSC::VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); JSC::JSValue message = JSC::jsUndefined(); - if (err.message.len > 0) { - message = Zig::toJSString(err.message, globalObject); + if (err.message.tag != BunStringTag::Empty) { + message = Bun::toJS(globalObject, err.message); } JSC::JSValue options = JSC::jsUndefined(); @@ -1297,8 +1296,8 @@ JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0, auto clientData = WebCore::clientData(vm); - if (err.code.len > 0 && !(err.code.len == 1 and err.code.ptr[0] == 0)) { - JSC::JSValue code = Zig::toJSStringGC(err.code, globalObject); + if (err.code.tag != BunStringTag::Empty) { + JSC::JSValue code = Bun::toJS(globalObject, err.code); result->putDirect(vm, clientData->builtinNames().codePublicName(), code, JSC::PropertyAttribute::DontDelete | 0); @@ -1307,13 +1306,12 @@ JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0, result->putDirect( vm, vm.propertyNames->name, - JSC::JSValue(JSC::jsOwnedString( - vm, WTF::String(WTF::StringImpl::createWithoutCopying(system_error_name, 11)))), + JSC::JSValue(jsString(vm, String("SystemError"_s))), JSC::PropertyAttribute::DontEnum | 0); } - if (err.path.len > 0) { - JSC::JSValue path = JSC::JSValue(Zig::toJSStringGC(err.path, globalObject)); + if (err.path.tag != BunStringTag::Empty) { + JSC::JSValue path = Bun::toJS(globalObject, err.path); result->putDirect(vm, clientData->builtinNames().pathPublicName(), path, JSC::PropertyAttribute::DontDelete | 0); } @@ -1324,8 +1322,8 @@ JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0, JSC::PropertyAttribute::DontDelete | 0); } - if (err.syscall.len > 0) { - JSC::JSValue syscall = JSC::JSValue(Zig::toJSString(err.syscall, globalObject)); + if (err.syscall.tag != BunStringTag::Empty) { + JSC::JSValue syscall = Bun::toJS(globalObject, err.syscall); result->putDirect(vm, clientData->builtinNames().syscallPublicName(), syscall, JSC::PropertyAttribute::DontDelete | 0); } @@ -3303,11 +3301,8 @@ bool JSC__JSValue__stringIncludes(JSC__JSValue value, JSC__JSGlobalObject* globa static void populateStackFrameMetadata(JSC::VM& vm, const JSC::StackFrame* stackFrame, ZigStackFrame* frame) { - String str = stackFrame->sourceURL(vm); - if (!str.isEmpty()) - str.impl()->ref(); - frame->source_url = Bun::toString(str); + frame->source_url = Bun::toStringRef(stackFrame->sourceURL(vm)); if (stackFrame->isWasmFrame()) { frame->code_type = ZigStackFrameCodeWasm; @@ -3344,10 +3339,7 @@ static void populateStackFrameMetadata(JSC::VM& vm, const JSC::StackFrame* stack JSC::JSObject* callee = JSC::jsCast(calleeCell); - String displayName = JSC::getCalculatedDisplayName(vm, callee); - if (!displayName.isEmpty()) - displayName.impl()->ref(); - frame->function_name = Bun::toString(displayName); + frame->function_name = Bun::toStringRef(JSC::getCalculatedDisplayName(vm, callee)); } // Based on // https://github.com/mceSystems/node-jsc/blob/master/deps/jscshim/src/shim/JSCStackTrace.cpp#L298 @@ -3421,7 +3413,7 @@ static void populateStackFramePosition(const JSC::StackFrame* stackFrame, BunStr // Most of the time, when you look at a stack trace, you want a couple lines above - source_lines[0] = Bun::toString(sourceString.substring(lineStart, lineStop - lineStart).toStringWithoutCopying()); + source_lines[0] = Bun::toStringRef(sourceString.substring(lineStart, lineStop - lineStart).toStringWithoutCopying()); source_line_numbers[0] = line; if (lineStart > 0) { @@ -3438,7 +3430,7 @@ static void populateStackFramePosition(const JSC::StackFrame* stackFrame, BunStr } // We are at the beginning of the line - source_lines[source_line_i] = Bun::toString(sourceString.substring(byte_offset_in_source_string, end_of_line_offset - byte_offset_in_source_string + 1).toStringWithoutCopying()); + source_lines[source_line_i] = Bun::toStringRef(sourceString.substring(byte_offset_in_source_string, end_of_line_offset - byte_offset_in_source_string + 1).toStringWithoutCopying()); source_line_numbers[source_line_i] = line - source_line_i; source_line_i++; @@ -3526,30 +3518,32 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, except->code = 8; } if (except->code == SYNTAX_ERROR_CODE) { - except->message = Bun::toString(err->sanitizedMessageString(global)); + except->message = Bun::toStringRef(err->sanitizedMessageString(global)); } else if (JSC::JSValue message = obj->getIfPropertyExists(global, vm.propertyNames->message)) { - except->message = Bun::toString(global, message); + except->message = Bun::toStringRef(global, message); } else { - except->message = Bun::toString(err->sanitizedMessageString(global)); + except->message = Bun::toStringRef(err->sanitizedMessageString(global)); } - except->name = Bun::toString(err->sanitizedNameString(global)); + + except->name = Bun::toStringRef(err->sanitizedNameString(global)); + except->runtime_type = err->runtimeTypeForCause(); auto clientData = WebCore::clientData(vm); if (except->code != SYNTAX_ERROR_CODE) { if (JSC::JSValue syscall = obj->getIfPropertyExists(global, clientData->builtinNames().syscallPublicName())) { - except->syscall = Bun::toString(global, syscall); + except->syscall = Bun::toStringRef(global, syscall); } if (JSC::JSValue code = obj->getIfPropertyExists(global, clientData->builtinNames().codePublicName())) { - except->code_ = Bun::toString(global, code); + except->code_ = Bun::toStringRef(global, code); } if (JSC::JSValue path = obj->getIfPropertyExists(global, clientData->builtinNames().pathPublicName())) { - except->path = Bun::toString(global, path); + except->path = Bun::toStringRef(global, path); } if (JSC::JSValue fd = obj->getIfPropertyExists(global, Identifier::fromString(vm, "fd"_s))) { @@ -3565,7 +3559,7 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, if (getFromSourceURL) { if (JSC::JSValue sourceURL = obj->getIfPropertyExists(global, vm.propertyNames->sourceURL)) { - except->stack.frames_ptr[0].source_url = Bun::toString(global, sourceURL); + except->stack.frames_ptr[0].source_url = Bun::toStringRef(global, sourceURL); if (JSC::JSValue column = obj->getIfPropertyExists(global, vm.propertyNames->column)) { except->stack.frames_ptr[0].position.column_start = column.toInt32(global); @@ -3577,7 +3571,7 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, if (JSC::JSValue lineText = obj->getIfPropertyExists(global, JSC::Identifier::fromString(vm, "lineText"_s))) { if (JSC::JSString* jsStr = lineText.toStringOrNull(global)) { auto str = jsStr->value(global); - except->stack.source_lines_ptr[0] = Bun::toString(str); + except->stack.source_lines_ptr[0] = Bun::toStringRef(str); except->stack.source_lines_numbers[0] = except->stack.frames_ptr[0].position.line; except->stack.source_lines_len = 1; except->remapped = true; @@ -3600,7 +3594,7 @@ void exceptionFromString(ZigException* except, JSC::JSValue value, JSC::JSGlobal if (JSC::JSObject* obj = JSC::jsDynamicCast(value)) { if (obj->hasProperty(global, global->vm().propertyNames->name)) { auto name_str = obj->getIfPropertyExists(global, global->vm().propertyNames->name).toWTFString(global); - except->name = Bun::toString(name_str); + except->name = Bun::toStringRef(name_str); if (name_str == "Error"_s) { except->code = JSErrorCodeError; } else if (name_str == "EvalError"_s) { @@ -3622,14 +3616,14 @@ void exceptionFromString(ZigException* except, JSC::JSValue value, JSC::JSGlobal if (JSC::JSValue message = obj->getIfPropertyExists(global, global->vm().propertyNames->message)) { if (message) { - except->message = Bun::toString( + except->message = Bun::toStringRef( message.toWTFString(global)); } } if (JSC::JSValue sourceURL = obj->getIfPropertyExists(global, global->vm().propertyNames->sourceURL)) { if (sourceURL) { - except->stack.frames_ptr[0].source_url = Bun::toString( + except->stack.frames_ptr[0].source_url = Bun::toStringRef( sourceURL.toWTFString(global)); except->stack.frames_len = 1; } @@ -3658,7 +3652,7 @@ void exceptionFromString(ZigException* except, JSC::JSValue value, JSC::JSGlobal } scope.release(); - except->message = Bun::toString(str); + except->message = Bun::toStringRef(str); } void JSC__VM__releaseWeakRefs(JSC__VM* arg0) @@ -3768,8 +3762,8 @@ void JSC__JSValue__toZigException(JSC__JSValue JSValue0, JSC__JSGlobalObject* ar JSC::JSValue value = JSC::JSValue::decode(JSValue0); if (value == JSC::JSValue {}) { exception->code = JSErrorCodeError; - exception->name = Bun::toString("Error"_s); - exception->message = Bun::toString("Unknown error"_s); + exception->name = Bun::toStringRef("Error"_s); + exception->message = Bun::toStringRef("Unknown error"_s); return; } diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 1c09378a8..777860d3c 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -1561,10 +1561,10 @@ pub const FetchHeaders = opaque { pub const SystemError = extern struct { errno: c_int = 0, /// label for errno - code: ZigString = ZigString.init(""), - message: ZigString = ZigString.init(""), - path: ZigString = ZigString.init(""), - syscall: ZigString = ZigString.init(""), + code: String = String.empty, + message: String = String.empty, + path: String = String.empty, + syscall: String = String.empty, fd: i32 = -1, pub fn Maybe(comptime Result: type) type { diff --git a/src/bun.js/bindings/headers-handwritten.h b/src/bun.js/bindings/headers-handwritten.h index c7429b633..90c8f86d2 100644 --- a/src/bun.js/bindings/headers-handwritten.h +++ b/src/bun.js/bindings/headers-handwritten.h @@ -84,10 +84,10 @@ typedef struct ErrorableResolvedSource { typedef struct SystemError { int errno_; - ZigString code; - ZigString message; - ZigString path; - ZigString syscall; + BunString code; + BunString message; + BunString path; + BunString syscall; int fd; } SystemError; @@ -246,6 +246,10 @@ BunString toString(WTF::String& wtfString); BunString toString(const WTF::String& wtfString); BunString toString(WTF::StringImpl* wtfString); +BunString toStringRef(JSC::JSGlobalObject* globalObject, JSC::JSValue value); +BunString toStringRef(WTF::String& wtfString); +BunString toStringRef(const WTF::String& wtfString); +BunString toStringRef(WTF::StringImpl* wtfString); } using Uint8Array_alias = JSC::JSUint8Array; diff --git a/src/bun.js/bindings/helpers.h b/src/bun.js/bindings/helpers.h index 402807f3d..00777c304 100644 --- a/src/bun.js/bindings/helpers.h +++ b/src/bun.js/bindings/helpers.h @@ -342,10 +342,10 @@ static const WTF::String toStringStatic(ZigString str) } if (isTaggedUTF16Ptr(str.ptr)) { - return WTF::String(WTF::ExternalStringImpl::createStatic(reinterpret_cast(untag(str.ptr)), str.len)); + return WTF::String(AtomStringImpl::add(reinterpret_cast(untag(str.ptr)), str.len)); } - return WTF::String(WTF::ExternalStringImpl::createStatic( + return WTF::String(AtomStringImpl::add( reinterpret_cast(untag(str.ptr)), str.len)); } diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp index a859e3ac5..bb62cb2a0 100644 --- a/src/bun.js/bindings/napi.cpp +++ b/src/bun.js/bindings/napi.cpp @@ -554,7 +554,6 @@ extern "C" napi_status napi_wrap(napi_env env, auto* globalObject = toJS(env); auto& vm = globalObject->vm(); - auto* val = jsDynamicCast(value); @@ -572,7 +571,7 @@ extern "C" napi_status napi_wrap(napi_env env, auto clientData = WebCore::clientData(vm); auto* ref = new NapiRef(globalObject, 1); - ref->strongRef.set(globalObject->vm(), value.getObject()); + ref->strongRef.set(globalObject->vm(), value.getObject()); if (finalize_cb) { ref->finalizer.finalize_cb = finalize_cb; @@ -816,7 +815,7 @@ extern "C" napi_status napi_create_reference(napi_env env, napi_value value, } } - if(object) { + if (object) { object->napiRef = ref; } @@ -1029,7 +1028,26 @@ extern "C" napi_status napi_create_type_error(napi_env env, napi_value code, auto error = JSC::createTypeError(globalObject, messageValue.toWTFString(globalObject)); if (codeValue) { - error->putDirect(vm, Identifier::fromString(vm, "code"_s), codeValue, 0); + error->putDirect(vm, WebCore::builtinNames(vm).codePublicName(), codeValue, 0); + } + + *result = reinterpret_cast(JSC::JSValue::encode(error)); + return napi_ok; +} + +extern "C" napi_status napi_create_error(napi_env env, napi_value code, + napi_value msg, + napi_value* result) +{ + Zig::GlobalObject* globalObject = toJS(env); + JSC::VM& vm = globalObject->vm(); + + JSC::JSValue codeValue = JSC::JSValue::decode(reinterpret_cast(code)); + JSC::JSValue messageValue = JSC::JSValue::decode(reinterpret_cast(msg)); + + auto error = JSC::createError(globalObject, messageValue.toWTFString(globalObject)); + if (codeValue) { + error->putDirect(vm, WebCore::builtinNames(vm).codePublicName(), codeValue, 0); } *result = reinterpret_cast(JSC::JSValue::encode(error)); @@ -1474,7 +1492,8 @@ extern "C" napi_status napi_get_property_names(napi_env env, napi_value object, return napi_ok; } -extern "C" napi_status napi_create_object(napi_env env, napi_value* result){ +extern "C" napi_status napi_create_object(napi_env env, napi_value* result) +{ if (UNLIKELY(result == nullptr)) { return napi_invalid_arg; diff --git a/src/bun.js/bindings/webcore/JSCloseEvent.cpp b/src/bun.js/bindings/webcore/JSCloseEvent.cpp index be07cbcfe..ad7b6ed57 100644 --- a/src/bun.js/bindings/webcore/JSCloseEvent.cpp +++ b/src/bun.js/bindings/webcore/JSCloseEvent.cpp @@ -99,7 +99,7 @@ template<> CloseEvent::Init convertDictionary(JSGlobalObject& if (isNullOrUndefined) codeValue = jsUndefined(); else { - codeValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "code"_s)); + codeValue = object->get(&lexicalGlobalObject, WebCore::builtinNames(vm).codePublicName()); RETURN_IF_EXCEPTION(throwScope, {}); } if (!codeValue.isUndefined()) { diff --git a/src/bun.js/node/node_os.zig b/src/bun.js/node/node_os.zig index f71143315..483acb3e2 100644 --- a/src/bun.js/node/node_os.zig +++ b/src/bun.js/node/node_os.zig @@ -78,8 +78,8 @@ pub const Os = struct { return if (comptime Environment.isLinux) cpusImplLinux(globalThis) catch { const err = JSC.SystemError{ - .message = JSC.ZigString.init("Failed to get cpu information"), - .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), + .message = bun.String.static("Failed to get cpu information"), + .code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), }; globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis)); @@ -88,8 +88,8 @@ pub const Os = struct { else if (comptime Environment.isMac) cpusImplDarwin(globalThis) catch { const err = JSC.SystemError{ - .message = JSC.ZigString.init("Failed to get cpu information"), - .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), + .message = bun.String.static("Failed to get cpu information"), + .code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), }; globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis)); @@ -318,11 +318,11 @@ pub const Os = struct { //info.put(globalThis, JSC.ZigString.static("syscall"), JSC.ZigString.init("uv_os_getpriority").withEncoding().toValueGC(globalThis)); const err = JSC.SystemError{ - .message = JSC.ZigString.init("A system error occurred: uv_os_getpriority returned ESRCH (no such process)"), - .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), + .message = bun.String.static("A system error occurred: uv_os_getpriority returned ESRCH (no such process)"), + .code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), //.info = info, .errno = -3, - .syscall = JSC.ZigString.init("uv_os_getpriority"), + .syscall = bun.String.static("uv_os_getpriority"), }; globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis)); @@ -377,10 +377,10 @@ pub const Os = struct { const rc = C.getifaddrs(&interface_start); if (rc != 0) { const err = JSC.SystemError{ - .message = JSC.ZigString.init("A system error occurred: getifaddrs returned an error"), - .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), + .message = bun.String.static("A system error occurred: getifaddrs returned an error"), + .code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), .errno = @intFromEnum(std.os.errno(rc)), - .syscall = JSC.ZigString.init("getifaddrs"), + .syscall = bun.String.static("getifaddrs"), }; globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis)); @@ -591,11 +591,11 @@ pub const Os = struct { switch (errcode) { .SRCH => { const err = JSC.SystemError{ - .message = JSC.ZigString.init("A system error occurred: uv_os_setpriority returned ESRCH (no such process)"), - .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), + .message = bun.String.static("A system error occurred: uv_os_setpriority returned ESRCH (no such process)"), + .code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), //.info = info, .errno = -3, - .syscall = JSC.ZigString.init("uv_os_setpriority"), + .syscall = bun.String.static("uv_os_setpriority"), }; globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis)); @@ -603,11 +603,11 @@ pub const Os = struct { }, .ACCES => { const err = JSC.SystemError{ - .message = JSC.ZigString.init("A system error occurred: uv_os_setpriority returned EACCESS (permission denied)"), - .code = JSC.ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), + .message = bun.String.static("A system error occurred: uv_os_setpriority returned EACCESS (permission denied)"), + .code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))), //.info = info, .errno = -13, - .syscall = JSC.ZigString.init("uv_os_setpriority"), + .syscall = bun.String.static("uv_os_setpriority"), }; globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis)); diff --git a/src/bun.js/node/syscall.zig b/src/bun.js/node/syscall.zig index 48c5b1305..5ff0b2f44 100644 --- a/src/bun.js/node/syscall.zig +++ b/src/bun.js/node/syscall.zig @@ -873,20 +873,20 @@ pub const Error = struct { pub fn toSystemError(this: Error) SystemError { var err = SystemError{ .errno = @as(c_int, this.errno) * -1, - .syscall = JSC.ZigString.init(@tagName(this.syscall)), + .syscall = bun.String.static(@tagName(this.syscall)), }; // errno label if (this.errno > 0 and this.errno < C.SystemErrno.max) { const system_errno = @enumFromInt(C.SystemErrno, this.errno); - err.code = JSC.ZigString.init(@tagName(system_errno)); + err.code = bun.String.static(@tagName(system_errno)); if (C.SystemErrno.labels.get(system_errno)) |label| { - err.message = JSC.ZigString.init(label); + err.message = bun.String.static(label); } } if (this.path.len > 0) { - err.path = JSC.ZigString.init(this.path); + err.path = bun.String.create(this.path); } if (this.fd != -1) { diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index faf503a3f..86b5414e3 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -1194,9 +1194,6 @@ pub const Blob = struct { .syscall = .open, }).toSystemError(); - // assert we never end up reusing the memory - std.debug.assert(@intFromPtr(this.system_error.?.path.slice().ptr) != @intFromPtr(path_buffer)); - callback(this, null_fd); return; }; @@ -1359,12 +1356,13 @@ pub const Blob = struct { return; } else if (this.store == null) { bun.default_allocator.destroy(this); - cb(cb_ctx, ResultType{ .err = SystemError{ - .code = ZigString.init("INTERNAL_ERROR"), - .path = ZigString.Empty, - .message = ZigString.init("assertion failure - store should not be null"), - .syscall = ZigString.init("read"), - } }); + cb(cb_ctx, ResultType{ + .err = SystemError{ + .code = bun.String.static("INTERNAL_ERROR"), + .message = bun.String.static("assertion failure - store should not be null"), + .syscall = bun.String.static("read"), + }, + }); return; } @@ -1396,12 +1394,12 @@ pub const Blob = struct { }).toSystemError(); } else { this.system_error = JSC.SystemError{ - .code = ZigString.init(bun.asByteSlice(@errorName(err))), + .code = bun.String.static(bun.asByteSlice(@errorName(err))), .path = if (this.file_store.pathlike == .path) - ZigString.init(this.file_store.pathlike.path.slice()) + bun.String.create(this.file_store.pathlike.path.slice()) else - ZigString.Empty, - .syscall = ZigString.init("read"), + bun.String.empty, + .syscall = bun.String.static("read"), }; this.errno = err; @@ -1458,13 +1456,13 @@ pub const Blob = struct { if (std.os.S.ISDIR(stat.mode)) { this.errno = error.EISDIR; this.system_error = JSC.SystemError{ - .code = ZigString.init("EISDIR"), + .code = bun.String.static("EISDIR"), .path = if (this.file_store.pathlike == .path) - ZigString.init(this.file_store.pathlike.path.slice()) + bun.String.create(this.file_store.pathlike.path.slice()) else - ZigString.Empty, - .message = ZigString.init("Directories cannot be read like files"), - .syscall = ZigString.init("read"), + bun.String.empty, + .message = bun.String.static("Directories cannot be read like files"), + .syscall = bun.String.static("read"), }; return; } @@ -1643,8 +1641,8 @@ pub const Blob = struct { this.wrote += @truncate(SizeType, result catch |errno| { this.errno = errno; this.system_error = this.system_error orelse JSC.SystemError{ - .code = ZigString.init(bun.asByteSlice(@errorName(errno))), - .syscall = ZigString.init("write"), + .code = bun.String.static(bun.asByteSlice(@errorName(errno))), + .syscall = bun.String.static("write"), }; this.wrote = 0; @@ -1703,13 +1701,13 @@ pub const Blob = struct { const unsupported_directory_error = SystemError{ .errno = @intCast(c_int, @intFromEnum(bun.C.SystemErrno.EISDIR)), - .message = ZigString.init("That doesn't work on folders"), - .syscall = ZigString.init("fstat"), + .message = bun.String.static("That doesn't work on folders"), + .syscall = bun.String.static("fstat"), }; const unsupported_non_regular_file_error = SystemError{ .errno = @intCast(c_int, @intFromEnum(bun.C.SystemErrno.ENOTSUP)), - .message = ZigString.init("Non-regular files aren't supported yet"), - .syscall = ZigString.init("fstat"), + .message = bun.String.static("Non-regular files aren't supported yet"), + .syscall = bun.String.static("fstat"), }; // blocking, but off the main thread @@ -1777,13 +1775,12 @@ pub const Blob = struct { pub fn reject(this: *CopyFile, promise: *JSC.JSPromise) void { var globalThis = this.globalThis; var system_error: SystemError = this.system_error orelse SystemError{}; - if (this.source_file_store.pathlike == .path and system_error.path.len == 0) { - system_error.path = ZigString.init(this.source_file_store.pathlike.path.slice()); - system_error.path.mark(); + if (this.source_file_store.pathlike == .path and system_error.path.isEmpty()) { + system_error.path = bun.String.create(this.source_file_store.pathlike.path.slice()); } - if (system_error.message.len == 0) { - system_error.message = ZigString.init("Failed to copy file"); + if (system_error.message.isEmpty()) { + system_error.message = bun.String.static("Failed to copy file"); } var instance = system_error.toErrorInstance(this.globalThis); diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig index b4ea08579..e888ffa5a 100644 --- a/src/bun.js/webcore/response.zig +++ b/src/bun.js/webcore/response.zig @@ -777,15 +777,15 @@ pub const Fetch = struct { } const fetch_error = JSC.SystemError{ - .code = ZigString.init(@errorName(this.result.fail)), + .code = bun.String.static(@errorName(this.result.fail)), .message = switch (this.result.fail) { - error.ConnectionClosed => ZigString.init("The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()"), - error.FailedToOpenSocket => ZigString.init("Was there a typo in the url or port?"), - error.TooManyRedirects => ZigString.init("The response redirected too many times. For more information, pass `verbose: true` in the second argument to fetch()"), - error.ConnectionRefused => ZigString.init("Unable to connect. Is the computer able to access the url?"), - else => ZigString.init("fetch() failed. For more information, pass `verbose: true` in the second argument to fetch()"), + error.ConnectionClosed => bun.String.static("The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()"), + error.FailedToOpenSocket => bun.String.static("Was there a typo in the url or port?"), + error.TooManyRedirects => bun.String.static("The response redirected too many times. For more information, pass `verbose: true` in the second argument to fetch()"), + error.ConnectionRefused => bun.String.static("Unable to connect. Is the computer able to access the url?"), + else => bun.String.static("fetch() failed. For more information, pass `verbose: true` in the second argument to fetch()"), }, - .path = ZigString.init(this.http.?.url.href), + .path = bun.String.create(this.http.?.url.href), }; return fetch_error.toErrorInstance(this.global_this); diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 5986afac7..343ce37ab 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -1964,10 +1964,10 @@ pub fn NewJSSink(comptime SinkType: type, comptime name_: []const u8) type { pub const message = std.fmt.comptimePrint("{s} is not constructable", .{SinkType.name}); }; const err = JSC.SystemError{ - .message = ZigString.init(Static.message), - .code = ZigString.init(@as(string, @tagName(JSC.Node.ErrorCode.ERR_ILLEGAL_CONSTRUCTOR))), + .message = bun.String.static(Static.message), + .code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_ILLEGAL_CONSTRUCTOR))), }; - globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis)); + globalThis.throwValue(err.toErrorInstance(globalThis)); return JSC.JSValue.jsUndefined(); } diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index 814e49a20..f534e4184 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -9174,8 +9174,10 @@ const LinkerContext = struct { }, )) { .err => |err| { + var message = err.toSystemError().message.toUTF8(bun.default_allocator); + defer message.deinit(); c.log.addErrorFmt(null, Logger.Loc.Empty, bun.default_allocator, "{} writing sourcemap for chunk {}", .{ - bun.fmt.quote(err.toSystemError().message.slice()), + bun.fmt.quote(message.slice()), bun.fmt.quote(chunk.final_rel_path), }) catch unreachable; return error.WriteFailed; @@ -9242,8 +9244,10 @@ const LinkerContext = struct { }, )) { .err => |err| { + var message = err.toSystemError().message.toUTF8(bun.default_allocator); + defer message.deinit(); c.log.addErrorFmt(null, Logger.Loc.Empty, bun.default_allocator, "{} writing chunk {}", .{ - bun.fmt.quote(err.toSystemError().message.slice()), + bun.fmt.quote(message.slice()), bun.fmt.quote(chunk.final_rel_path), }) catch unreachable; return error.WriteFailed; @@ -9309,8 +9313,10 @@ const LinkerContext = struct { }, )) { .err => |err| { + const utf8 = err.toSystemError().message.toUTF8(bun.default_allocator); + defer utf8.deinit(); c.log.addErrorFmt(null, Logger.Loc.Empty, bun.default_allocator, "{} writing chunk {}", .{ - bun.fmt.quote(err.toSystemError().message.slice()), + bun.fmt.quote(utf8.slice()), bun.fmt.quote(components_manifest_path), }) catch unreachable; return error.WriteFailed; @@ -9383,8 +9389,10 @@ const LinkerContext = struct { }, )) { .err => |err| { + const utf8 = err.toSystemError().message.toUTF8(bun.default_allocator); + defer utf8.deinit(); c.log.addErrorFmt(null, Logger.Loc.Empty, bun.default_allocator, "{} writing file {}", .{ - bun.fmt.quote(err.toSystemError().message.slice()), + bun.fmt.quote(utf8.slice()), bun.fmt.quote(src.src_path.text), }) catch unreachable; return error.WriteFailed; diff --git a/src/http.zig b/src/http.zig index 80718db2f..b1d97c382 100644 --- a/src/http.zig +++ b/src/http.zig @@ -684,8 +684,9 @@ pub const RequestContext = struct { if (erro == error.EBADF or erro == error.ECONNABORTED or erro == error.ECONNREFUSED) { return error.SocketClosed; } - - Output.prettyErrorln("send() error: {s}", .{err.toSystemError().message.slice()}); + const msg = err.toSystemError().message.toUTF8(bun.default_allocator); + defer msg.deinit(); + Output.prettyErrorln("send() error: {s}", .{msg.slice()}); return erro; }, diff --git a/src/napi/napi.zig b/src/napi/napi.zig index 0973ca559..439319489 100644 --- a/src/napi/napi.zig +++ b/src/napi/napi.zig @@ -303,16 +303,7 @@ pub export fn napi_create_string_utf16(env: napi_env, str: [*]const char16_t, le return .ok; } pub extern fn napi_create_symbol(env: napi_env, description: napi_value, result: *napi_value) napi_status; -pub export fn napi_create_error(env: napi_env, code: napi_value, msg: napi_value, result: *napi_value) napi_status { - log("napi_create_error: \"{any}\"", .{msg.getZigString(env)}); - const system_error = JSC.SystemError{ - .code = if (!code.isEmptyOrUndefinedOrNull()) code.getZigString(env) else ZigString.Empty, - .message = msg.getZigString(env), - }; - result.* = system_error.toErrorInstance(env); - return .ok; -} - +pub extern fn napi_create_error(env: napi_env, code: napi_value, msg: napi_value, result: *napi_value) napi_status; pub extern fn napi_create_type_error(env: napi_env, code: napi_value, msg: napi_value, result: *napi_value) napi_status; pub extern fn napi_create_range_error(env: napi_env, code: napi_value, msg: napi_value, result: *napi_value) napi_status; pub extern fn napi_typeof(env: napi_env, value: napi_value, result: *napi_valuetype) napi_status; diff --git a/test/js/bun/util/error-gc-test.test.js b/test/js/bun/util/error-gc-test.test.js index 247bd68ef..4a45346b6 100644 --- a/test/js/bun/util/error-gc-test.test.js +++ b/test/js/bun/util/error-gc-test.test.js @@ -1,5 +1,5 @@ import { test, expect } from "bun:test"; - +import { readFileSync } from "fs"; // This test checks that printing stack traces increments and decrements // reference-counted strings test("error gc test", () => { @@ -34,7 +34,7 @@ test("error gc test #2", () => { } }); -test("error gc test #2", () => { +test("error gc test #3", () => { for (let i = 0; i < 1000; i++) { var err = new Error(); Error.captureStackTrace(err); @@ -42,3 +42,40 @@ test("error gc test #2", () => { Bun.gc(); } }); + +// This test fails if: +// - it crashes +// - The test failure message gets a non-sensical error +test("error gc test #4", () => { + for (let i = 0; i < 1000; i++) { + let path = + // Use a long-enough string for it to be obvious if we leak memory + "/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/ii/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/ii/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i/don/t/exist/tmp/i"; + try { + readFileSync(path); + throw new Error("unreachable"); + } catch (e) { + if (e.message === "unreachable") { + throw e; + } + + const inspected = Bun.inspect(e); + Bun.gc(true); + + // Deliberately avoid using .toContain() directly to avoid + // BunString shenanigins. + // + // Only JSC builtin functions to operate on the string after inspecting it. + // + if (!inspected.includes(path)) { + expect(inspected).toContain(path); + } + + if (!inspected.includes("ENOENT")) { + expect(inspected).toContain("ENOENT"); + } + } finally { + Bun.gc(true); + } + } +}); -- cgit v1.2.3 From 565d1689e9f2c1f6b657f14b07fa9b95e50a5a56 Mon Sep 17 00:00:00 2001 From: Ai Hoshino Date: Sun, 9 Jul 2023 22:20:52 +0800 Subject: fix metadata bits of uuid (`randomUUID()`) (#3583) * fix uuid version Close: https://github.com/oven-sh/bun/issues/3575 * add unittest * small fix * avoid unnecessary copying --- src/bun.js/rare_data.zig | 8 ++++++-- src/bun.js/uuid.zig | 10 ++++++++++ src/bun.js/webcore.zig | 11 ++++------- src/bun.js/webcore/blob.zig | 2 +- src/http/websocket_http_client.zig | 2 +- test/js/web/web-globals.test.js | 19 +++++++++++++++++++ 6 files changed, 41 insertions(+), 11 deletions(-) (limited to 'src/bun.js/webcore/blob.zig') diff --git a/src/bun.js/rare_data.zig b/src/bun.js/rare_data.zig index ddda96bf4..3b29896a4 100644 --- a/src/bun.js/rare_data.zig +++ b/src/bun.js/rare_data.zig @@ -9,6 +9,7 @@ const std = @import("std"); const BoringSSL = @import("root").bun.BoringSSL; const bun = @import("root").bun; const WebSocketClientMask = @import("../http/websocket_http_client.zig").Mask; +const UUID = @import("./uuid.zig"); boring_ssl_engine: ?*BoringSSL.ENGINE = null, editor_context: EditorContext = EditorContext{}, @@ -47,13 +48,16 @@ pub fn filePolls(this: *RareData, vm: *JSC.VirtualMachine) *JSC.FilePoll.HiveArr }; } -pub fn nextUUID(this: *RareData) [16]u8 { +pub fn nextUUID(this: *RareData) UUID { if (this.entropy_cache == null) { this.entropy_cache = default_allocator.create(EntropyCache) catch unreachable; this.entropy_cache.?.init(); } - return this.entropy_cache.?.get(); + this.entropy_cache.?.fill(); + + const bytes = this.entropy_cache.?.get(); + return UUID.initWith(&bytes); } pub fn entropySlice(this: *RareData, len: usize) []u8 { diff --git a/src/bun.js/uuid.zig b/src/bun.js/uuid.zig index e8bdff661..e38ed567f 100644 --- a/src/bun.js/uuid.zig +++ b/src/bun.js/uuid.zig @@ -18,6 +18,16 @@ pub fn init() UUID { uuid.bytes[6] = (uuid.bytes[6] & 0x0f) | 0x40; // Variant 1 uuid.bytes[8] = (uuid.bytes[8] & 0x3f) | 0x80; + + return uuid; +} + +pub fn initWith(bytes: *const [16]u8) UUID { + var uuid = UUID{ .bytes = bytes.* }; + + uuid.bytes[6] = (uuid.bytes[6] & 0x0f) | 0x40; + uuid.bytes[8] = (uuid.bytes[8] & 0x3f) | 0x80; + return uuid; } diff --git a/src/bun.js/webcore.zig b/src/bun.js/webcore.zig index fd69b0262..8cb9ec80a 100644 --- a/src/bun.js/webcore.zig +++ b/src/bun.js/webcore.zig @@ -366,7 +366,6 @@ pub const Prompt = struct { }; pub const Crypto = struct { - const UUID = @import("./uuid.zig"); const BoringSSL = @import("root").bun.BoringSSL; pub const Class = JSC.NewClass( void, @@ -693,9 +692,8 @@ pub const Crypto = struct { _: []const JSC.JSValue, ) JSC.JSValue { var out: [36]u8 = undefined; - const uuid: UUID = .{ - .bytes = globalThis.bunVM().rareData().nextUUID(), - }; + const uuid = globalThis.bunVM().rareData().nextUUID(); + uuid.print(&out); return JSC.ZigString.init(&out).toValueGC(globalThis); } @@ -723,9 +721,8 @@ pub const Crypto = struct { _: *anyopaque, ) callconv(.C) JSC.JSValue { var out: [36]u8 = undefined; - const uuid: UUID = .{ - .bytes = globalThis.bunVM().rareData().nextUUID(), - }; + const uuid = globalThis.bunVM().rareData().nextUUID(); + uuid.print(&out); return JSC.ZigString.init(&out).toValueGC(globalThis); } diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index 86b5414e3..ef2520049 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -249,7 +249,7 @@ pub const Blob = struct { var hex_buf: [70]u8 = undefined; const boundary = brk: { - var random = globalThis.bunVM().rareData().nextUUID(); + var random = globalThis.bunVM().rareData().nextUUID().bytes; var formatter = std.fmt.fmtSliceHexLower(&random); break :brk std.fmt.bufPrint(&hex_buf, "-WebkitFormBoundary{any}", .{formatter}) catch unreachable; }; diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index f495af3b7..ae8e40763 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -60,7 +60,7 @@ fn buildRequestBody( extra_headers: NonUTF8Headers, ) std.mem.Allocator.Error![]u8 { const allocator = vm.allocator; - const input_rand_buf = vm.rareData().nextUUID(); + const input_rand_buf = vm.rareData().nextUUID().bytes; const temp_buf_size = comptime std.base64.standard.Encoder.calcSize(16); var encoded_buf: [temp_buf_size]u8 = undefined; const accept_key = std.base64.standard.Encoder.encode(&encoded_buf, &input_rand_buf); diff --git a/test/js/web/web-globals.test.js b/test/js/web/web-globals.test.js index b7a243190..d687a1290 100644 --- a/test/js/web/web-globals.test.js +++ b/test/js/web/web-globals.test.js @@ -138,6 +138,25 @@ it("crypto.randomUUID", () => { }); }); +it("crypto.randomUUID version, issues#3575", () => { + var uuid = crypto.randomUUID(); + + function validate(uuid) { + const regex = + /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; + return typeof uuid === "string" && regex.test(uuid); + } + function version(uuid) { + if (!validate(uuid)) { + throw TypeError("Invalid UUID"); + } + + return parseInt(uuid.slice(14, 15), 16); + } + + expect(version(uuid)).toBe(4); +}); + it("URL.prototype.origin", () => { const url = new URL("https://html.spec.whatwg.org/"); const { origin, host, hostname } = url; -- cgit v1.2.3